def __init__(self, port='/dev/ttyACM0', baudrate=9600,timeout=10):
"""Initialize internal variables and serial connection
:param port: The COM port to open. See the documentation for
`pyserial <http://pyserial.sourceforge.net/>`_ for an explanation
of the possible value. The default value is '/dev/ttyACM0'.
:type port: str or int
:param baudrate: 9600, 19200, 38400 where 9600 is the default
:type baudrate: int
"""
# The serial connection should be setup with the following parameters:
# 1 start bit, 8 data bits, No parity bit, 1 stop bit, no hardware
# handshake. These are all default for Serial and therefore not input
# below
#self.serial = serial.Serial(port=port, baudrate=baudrate, timeout=1)
self.serial = serial.Serial(port = port, baudrate=baudrate,
timeout=timeout, writeTimeout=timeout,stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,parity=serial.PARITY_NONE)
评论列表
文章目录