I’m using this script:
import serial
ser = serial.Serial('/dev/ttyUSB0')
print 'Running..'
while True:
a=ser.read() # write a string
if a is not "":
print str(a)
break
ser.close()
..and when im running the script i’m getting this output:
/Documents/python$ python rfid.py
As you can see i’m getting this strange box instead of the ID-string, so i’m guessing it has to do with some codec? EDIT: actually you cant see it here, but the box i’m talking about contains three zeroes and a two, like this:
0 0
0 2
You’re seeing that because U+0002 is not a printable character. You’re receiving 0x02 as (part of?) the message from the device; you can use
odto see the whole message as output by the script. If you didn’t expect that then you may want to make sure that you’ve usedsetserialto set the appropriate properties for the serial line.