python - rfid card reading is OK but not finished - Stack Overflow

I have an USB RFID reader (EF4100 125kHz) connected to Raspberry Pi 4 Model B. The RFID reader is act l

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()

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742330235a4423570.html

相关推荐

  • python - rfid card reading is OK but not finished - Stack Overflow

    I have an USB RFID reader (EF4100 125kHz) connected to Raspberry Pi 4 Model B. The RFID reader is act l

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信