I have a rfid reader connected to Jetson ( reComputer J1010). Following are the connection details.
“type”: “rfid-reader”,
“connection_type”: “usb”,
usb_port": “3”,
“port”: “/dev/ttyUSB0”,
“baudrate”: 19200,
“timeout”: 2,
The reader is connected properly and I can locate it at /dev/ttyUSB0. I have given permission to the reader using chmod 777 ttyUSB0 so that it has all the permissions it needs. The task is to create a csv file of all the tags it picks up at specific time.
The serial port is open for the rfid reader when connected with the jetson. The jetson shows there is no incoming data from the rfid reader. But when the rfid reader is connected to laptop, its picking up all the tags that are passing by.
The python code is as follows
def rfid_reader(ser, today, time_string, rfid_file_path, rfid_reader_queue, RFID_reader):
while ser.is_open:
incomingByte = ser.readline(25)
try:
if (incomingByte != b''):
raw = codecs.encode(incomingByte, 'hex').decode('ascii')
hexa = codecs.encode(incomingByte[5:13], 'hex').decode('ascii')
reversedorder = "".join(reversed([hexa[i:i + 2] for i in range(0, len(hexa), 2)]))
binarystring = bin(int(reversedorder, 16))[2:]
binarystring = binarystring.zfill(64)
binaryID = binarystring[26:64]
binaryCountrycode = binarystring[16:26]
IDnumber = int(binaryID, 2)
Countrycodenumber = int(binaryCountrycode, 2)
Dict = {'Date': date.today().strftime("%d/%m/%Y"), 'Time': datetime.now().strftime('%H:%M:%S'),
'Countrycode': Countrycodenumber, 'EID': IDnumber, 'RAW': raw}
df = pd.DataFrame(Dict, index=[0])
# if file does not exist write header
if not os.path.isfile(rfid_file_path):
df.to_csv(rfid_file_path, header=('Date', 'Time', 'Countrycode', 'EID', 'RAW'))
else: # else it exists so append without writing the header
df.to_csv(rfid_file_path, mode='a', header=False)
except:
print('RFID data type is wrong')
RFID_reader.RFID_is_running = False
run_shell_command(
'echo RFID_status_not_running > /home/pi/RFIDstatus.txt', require_output=False)
It is coming inside the try block and checks the incoming byte. since the incoming byte is b’', it’s not creating the csv file. Could someone please help me to solve the error?