(Incidentally, the third line is there simply to confirm that the write_timeout has been set and recognised correctly). I tested the program in 'loopback' mode (TX connected to RX) with a logic/protocol analyser connected to TX. Now, at 9600 baud, the character time is roughly 1ms, so my idea was that by setting write_timeout to 10ms, only the first ten characters of the "Hello World! Hello World!" string would be transmitted. Ser = serial.Serial(port='/dev/ttyS0', baudrate=9600, timeout=1, write_timeout=0.01) (I can't actually think of any reason why you would wish to do this, but I'm sure there must be a use for it somewhere).Įager to test the write_timeout function, I wrote the following simple program: In other words, I took it to mean that write_timeout allowed us to specify a 'time window' during which bytes would be transmitted and at the end of the window transmission would cease. I interpreted this to imply that, following a write command, characters would be transmitted only for the time duration specified by write_timeout, and that any subsequent characters waiting in the output buffer would be omitted. Read or write current write timeout setting. ![]() Getter: Get current write timeout setting ![]() ![]() The PySerial 3.4 documentation defines "write_timeout" thus: I'm slowly working my way through it, having lots of fun, but when I get to "write_timeout" I find it doesn't seem to do anything. ![]() I'm using a Pi3B+ to test the commands and functionality of PySerial.
0 Comments
Leave a Reply. |