I’m using a script importing PySerial
to read from COM4
messages I would like to intercept end with a couple of #
so I tried to use
bus.readline(eol='##')
where bus is my connection.
I expected to read like:
- *#*3##
- *#*3##
- *#*3##
Unfortunalyy I found also
- *#*1##*1*1*99##
that I expected to read spleetted into 2 lines
- *#*1##
- *1*1*99##
Clearly readline is not working but why?
The
readline()method in pyserial reads one character at a time and compares it to the EOL character. You cannot specify multiple characters as the EOL. You’ll have to read in and then split later usingstring.split()orre.split()