RFID reading using python via usb SyntaxError: invalid token -
i have 2 rfid card values 0004518403 , 000452738 after reading value in python terminal. want give them name 0004518403 "javed" , 000452738 "aquib". when next time when use card must not show me value must show me name i've defined them.
import serial import time serial = serial.serial('/dev/ttyusb0', baudrate = 9600) while true: if serial.inwaiting() > 0: read_result =serial.read(15) print("sleeping 2 seconds") if(read_result==0004520738): print "aquib" elif(read_result==0004518403): print "javed" time.sleep(2) serial.flushinput() # ignore errors, no data
i trying code show me error :
syntaxerror: invalid token
in first if condition. not getting problem.
you should compare read results strings, not numbers,
read_result=='0004520738'
0004520738 without quotes number. starts 0
sign, interpreted number of base 8. numbers of base 8 cannot contain digits 8
, 9
apparently.
>>> 01234567 342391 >>> 012345678 file "<stdin>", line 1 012345678 ^ syntaxerror: invalid token >>>
also don't why read 15 bytes, compare results 10 bytes string, that's smth wrong there
Comments
Post a Comment