admin管理员组文章数量:1336632
I have an USB RFID reader (EF4100 125kHz) connected to Raspberry Pi 4 Model B. The RFID reader is act like a keyboard and it read the first 10 digit. When I debugging the code with Thonny. At the "buffer = f.read(8)" row reading the card ID code and write the 10 digit code in the shell window, but not step to the next program row. Every time I touch the card to the reader, it reads the card code as many times and write it in the shell window but does not continue in the program. What could be the problem?
Here is my code:
NUMBERS = {30: '1', 31: '2', 32: '3', 33: '4', 34: '5', 35: '6', 36: '7', 37: '8', 38: '9', 39: '0'}
ENDFLAG = 40
def read_rfid():
try:
with open('/dev/hidraw0', 'rb') as f:
print("Tedd oda a kartyat")
READING = True
ID=""
while READING:
buffer = f.read(8)
print("Reading")
for c in buffer:
if c == ENDFLAG:
READING = False
elif c > 0:
ID = ID + NUMBERS[c]
rfid_number = ID.hex().upper()
print(f"Kartya szama: {rfid_number}")
except Exception as e:
print(f"Hiba {e}")
if __name__ == "__main__":
read_rfid()
本文标签: pythonrfid card reading is OK but not finishedStack Overflow
版权声明:本文标题:python - rfid card reading is OK but not finished - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742330234a2454545.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论