For the life of me, I cannot figure out how to do a non-blocking serial read in Python 3 using my Raspberry Pi.
Here's my code:
import serial #for pySerial
ser = serial.Serial('/dev/ttyUSB0', 9600) #open serial port
print ('serial port = ' + ser.name) #print the port used
while (True):
if (ser.in_waiting>0):
ser.read(ser.in_waiting)
Result:
AttributeError: 'Serial' object has no attribute 'in_waiting'
Here's the reference page I'm referencing that told me "in_waiting" exists: http://pyserial.readthedocs.io/en/latest/pyserial_api.html