A C program has the following serial settings:
tio.c_iflag = (BRKINT);
tio.c_oflag = 0;
tio.c_lflag = 0;
tio.c_cflag = ( B9600 | CS7 | PARENB | PARODD | CREAD );
tio.c_cc[VMIN] = 0;
tio.c_cc[VTIME] = 0;
I'm writing a python program to open a serial connection using PySerial. Here's the related code:
ser = serial.Serial(
port='/dev/ttyS0',
baudrate=9600,
parity=serial.PARITY_ODD,
#stopbits=serial.STOPBITS_ONE,
bytesize=serial.SEVENBITS
)
In the C code, I don't see the number of stop bits defined. Should it be set to one in the python code? Similarly, does CREAD to enable receiver need to be added to the python code? Am I missing anything else?
Thanks.
For terminal IO, if you don't specify the number of stop bits, it defaults to 1.
Remember that the stop bits are just used to signal the end of a frame - basically timing. If you specify 1.5 stop bits, it waits for the time taken to transmit 1.5 bits before looking for the next character.