本文整理匯總了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()