I'm trying to write a simple Python script to print RFID tag numbers to the terminal. Code example below. Using a Pi 2 Model B, with the reader here attached via USB.
I'm having difficulties understanding the output from the RFID reader. When displaying 15 characters, as in the example code above, consecutive reads of the same tag yield this output including line breaks (includes unicode start-of-text and end-of-text characters as [STX] and [ETX]):
Are these start & end-of-text characters distinct from "stop bits"? I'm unsure of why I'm not reading the end-of-text character on the first read, but all subsequent reads pick it up.
Any insight on the timing of line breaks?
Code:
import serial
device = serial.Serial("/dev/ttyUSB0", 9600, 8, "N", 1)
while True:
tag_id = device.read(15)
print tag_id