Thursday, April 28, 2011

Python PySerial readline function wrong use

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:

  1. *#*3##
  2. *#*3##
  3. *#*3##

Unfortunalyy I found also

  1. *#*1##*1*1*99##

that I expected to read spleetted into 2 lines

  1. *#*1##
  2. *1*1*99##

Clearly readline is not working but why?

From stackoverflow
  • 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 using string.split() or re.split()

    DrFalk3n : resolved using EnhancedSerial into pySerial including readline function re-implemented.

0 comments:

Post a Comment