I am sending commands to Eddie using pySerial. I need to specify a carriage-return in my readline, but pySerial 2.6 got rid of it... Is there a workaround?
Here are
from pyserial's documentation:
(sic)
Note:
The eol
parameter for readline()
is no longer supported when pySerial is run with newer Python versions (V2.6+) where the module io
is available.
EOL
To specify the EOL
character for readline()
or to use universal newline mode, it is advised to use io.TextIOWrapper
:
import serial
import io
ser = serial.serial_for_url('loop://', timeout=1)
sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser))
sio.write(unicode("hello\n"))
sio.flush() # it is buffering. required to get the data out *now*
hello = sio.readline()
print hello == unicode("hello\n")