I'm trying to set up a program that reads an RFID chip with a RFID reader through a USB serial connection. With the following code, I can read the tag, but the result is returned as a single character on each line.
import serial
ser = serial.Serial(
port='COM4',\
baudrate=9600,\
parity=serial.PARITY_NONE,\
stopbits=serial.STOPBITS_ONE,\
bytesize=serial.EIGHTBITS,\
timeout=0)
print("connected to: " + ser.portstr)
while True:
for line in ser.read():
print(chr(line))
ser.close()
Output:
connected to: COM4
4
0
0
0
0
4
1
2
8
6
C
E
F
F
How do I read the full line at once? I have tried using ´ser.readline()`, but this does not make any difference. Also, I do not know what the square symbol in the end of the read means. As far as I have tested, the square symbol always comes at postion 15, but there are sometimes additional characters after it.
In the end, I need to be able to scan and RFID and then search for the tag in a predefined list to see if it is located in the list.