I am using pyserial to read data off a serial port and sometimes the data I received behaves unexpectedly
Here is the important code
def getResponse():
while ('\r' != rbuf[-1]):
rbuf += s.read(s.inWaiting())
print("b " + binascii.hexlify(rbuf))
rbuf = rbuf.split('\r')
rbuf = rbuf[:-1]
print rbuf
for char in rbuf:
if(char == AFTER):
print('a')
elif(char == 'W'):
print("Writing to the file")
elif(char != ''):
print char
return char
getResponse()
I understand that this isn't the best way to write the code, but somehting very stange happens.
When I receive the sequence ['a', 'A'] the value returned ends up being NONE.(which i check with a print statement elsewhere in the code
This does not happen when I receive ['W','a','A'] or when I recive ['A']
I figuired out a work around but I am really curious about this!!
Thanks
Ben