I'm working with BeagleBones Black Rev C from some time, and i use a lot UARTs interfaces (RS-232 and RS-485), and some time ago i start using the pyserial module 3.4, and i notice some difference in timeout behavior.
So in the module 2.7, when i open a port (ser = serial.Serial(port, baudrate, ..., timeout)), i usually set the timeout = 1, and if the port didn't receive nothing for 1 second, the function ser.read() closes.
In the module 3.4, with a timeout=1, even if the port is receiving data, the function ser.read(x) closes before receiving all data. There is an example, where i ask to input the timeout i want, and the bytes i receive for every timeout i choose, in the other side i'm sending a total of 240048 bytes with a 125000 baudrate.
timeout.py ...
baudrate_0 = 115200
parity_0 = 'N'
stopbits_0 = 1
timeout = input( ' Timeout? \n')
timeout_0 = timeout
uart = serial.Serial(port="/dev/ttyO1",baudrate=baudrate_0, parity=parity_0, stopbits=stopbits_0, timeout = timeout_0)
....
data = uart.read(240048)
print 'bytes read:', len(data)
Output:
root@beaglebone:# python timeout.py
Timeout?
1
bytes read: 11232
root@beaglebone:# python timeout.py
Timeout?
2
bytes read: 22656
root@beaglebone:# python timeout.py
Timeout?
10
bytes read: 113904
root@beaglebone:# python timeout.py
Timeout?
25
bytes read: 240048
So the question is: Can I change the timeout behaviour to same behaviour as before (module 2.7)