串行类中的字节大小属性被定义为该连接使用的数据位数。如果我启用奇偶校验,它会将其中一个已定义的数据位转换为表示奇偶校验吗?还是只是在起始位和停止位之间添加另一个位?
import serial
# Define a serial instance with 8 databits and no parity
my_com = serial.serial(bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE)
# My rs232 frame would now look something like:
[ START_BIT, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, STOP_BIT ]
# Change the parity settings
my_com.parity = serial.PARITY_ODD
# Do my frames now look like this
[ START_BIT, DB0, DB1, DB2, DB3, DB4, DB5, DB6, DB7, PARITY, STOP_BIT ]
# or do they look like this?
[ START_BIT, DB0, DB1, DB2, DB3, DB4, DB5, DB6, PARITY, STOP_BIT ]
非常感谢您提供的帮助。
谢谢。
serial
模块的行为也是如此。 - Mark Ransom