本文整理汇总了Python中serial.PARITY_ODD属性的典型用法代码示例。如果您正苦于以下问题:Python serial.PARITY_ODD属性的具体用法?Python serial.PARITY_ODD怎么用?Python serial.PARITY_ODD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类serial
的用法示例。
在下文中一共展示了serial.PARITY_ODD属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: establish_serial_connection
# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_ODD [as 别名]
def establish_serial_connection(port, speed=115200, timeout=10, writeTimeout=10000):
# Hack for USB connection
# There must be a way to do it cleaner, but I can't seem to find it
try:
temp = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_ODD)
if sys.platform == 'win32':
temp.close()
conn = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_NONE)
conn.setRTS(False)#needed on mac
if sys.platform != 'win32':
temp.close()
return conn
except SerialException as e:
print ("Could not connect to {0} at baudrate {1}\nSerial error: {2}".format(port, str(speed), e))
return None
except IOError as e:
print ("Could not connect to {0} at baudrate {1}\nIO error: {2}".format(port, str(speed), e))
return None
示例2: establishSerialConnection
# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_ODD [as 别名]
def establishSerialConnection(port, speed=115200, timeout=10, writeTimeout=10000):
# Hack for USB connection
# There must be a way to do it cleaner, but I can't seem to find it
try:
temp = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_ODD)
if sys.platform == 'win32':
temp.close()
conn = Serial(port, speed, timeout=timeout, writeTimeout=writeTimeout, parity=PARITY_NONE)
conn.setRTS(False) #needed on mac
if sys.platform != 'win32':
temp.close()
return conn
except SerialException as e:
print ("Could not connect to {0} at baudrate {1}\nSerial error: {2}".format(port, str(speed), e))
raise e
except IOError as e:
print ("Could not connect to {0} at baudrate {1}\nIO error: {2}".format(port, str(speed), e))
raise e
示例3: getSerialOrNone
# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_ODD [as 别名]
def getSerialOrNone(portname):
try:
return serial.Serial(port=portname,baudrate=115200,parity=serial.PARITY_ODD,stopbits=serial.STOPBITS_TWO,bytesize=serial.SEVENBITS)
except:
return None
示例4: connect
# 需要导入模块: import serial [as 别名]
# 或者: from serial import PARITY_ODD [as 别名]
def connect(self):
if self.conn is None:
self.conn = serial.Serial(port = self.port,
baudrate = 19200,
parity = serial.PARITY_ODD,
stopbits = serial.STOPBITS_ONE,
bytesize = serial.EIGHTBITS,
timeout = 5,
xonxoff = 1)
elif not self.isConnected():
self.conn.open()