linux命令读取RFID usb端口

时间:2016-12-10 01:33:13

标签: linux bash usb cat rfid

我尝试从USB读取器读取数据。

airone@airone:~$ sudo tree /dev/input
/dev/input
├── by-id
│   ├── usb-413c_3010-event-mouse -> ../event2
│   ├── usb-413c_3010-mouse -> ../mouse0
│   ├── usb-Dell_Dell_USB_Keyboard-event-kbd -> ../event3
│   └── usb-Sycreader_RFID_Technology_Co.__Ltd_SYC_ID_IC_USB_Reader_08FF20140315-event-kbd -> ../event5
├── by-path
│   ├── pci-0000:00:1a.0-usb-0:1:1.0-event-kbd -> ../event5
│   ├── pci-0000:00:1d.1-usb-0:2:1.0-event-mouse -> ../event2
│   ├── pci-0000:00:1d.1-usb-0:2:1.0-mouse -> ../mouse0
│   └── pci-0000:00:1d.2-usb-0:1:1.0-event-kbd -> ../event3
├── event0
├── event1
├── event2
├── event3
├── event4
├── event5
├── mice
└── mouse0

2 directories, 16 files
airone@airone:~$ 

我的RIFD阅读器是:

usb-Sycreader_RFID_Technology_Co .__ Ltd_SYC_ID_IC_USB_Reader_08FF20140315-event-kbd - > ../ event5

当我将令牌放在RFID附近时,我得到了这个:

2 directories, 16 files
airone@airone:~$ sudo cat -v /dev/input/by-id/usb-Sycreader_RFID_Technology_Co.__Ltd_SYC_ID_IC_USB_Reader_08FF20140315-event-kbd 
M-1ZKX~M-m^A^@^D^@^D^@'^@^G^@M-1ZKX~M-m^A^@^A^@^K^@^A^@^@^@M-1ZKX~M-m^A^@^@^@^@^@^@^@^@^@M-1ZKXM-7^L^B^@^D^@^D^@'^@^G^@M-1ZKXM-7^L^B^@^A^@^K^@^@^@^@^@M-1ZKXM-7^L^B^@^@^@^@^@^@^@^@^@M-1ZKXM-s+^B^@^D^@^D^@'^@^G^@M-1ZKXM-s+^B^@^A^@^K^@^A^@^@^@M-1ZKXM-s+^B^@^@^@^@^@^@^@^@^@M-1ZKX1K^B^@^D^@^D^@'^@^G^@M-1ZKX1K^B^@^A^@^K^@^@^@^@^@M-1ZKX1K^B^@^@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@^@^@^@^@^@^@^@^@M-1ZKX0M-B^C^@^D^@^D^@%^@^G^@M-1ZKX0M-B^C^@^A^@    ^@^@^@^@^@M-1ZKX0M-B^C^@^@^@^@^@^@^@^@^@M-1ZKXtM-a^C^@^D^@^D^@"^@^G^@M-1ZKXtM-a^C^@^A^@^F^@^A^@^@^@M-1ZKXtM-a^C^@^@^@^@^@^@^@^@^@M-1ZKXM-1^@^D^@^D^@^D^@"^@^G^@M-1ZKXM-1^@^D^@^A^@^F^@^@^@^@^@M-1ZKXM-1^@^D^@^@^@^@^@^@^@^@^@M-1ZKXM-q^_^D^@^D^@^D^@&^@^G^@M-1ZKXM-q^_^D^@^A^@
^@^A^@^@^@M-1ZKXM-q^_^D^@^@^@^@^@^@^@^@^@M-1ZKX1?^D^@^D^@^D^@&^@^G^@M-1ZKX1?^D^@^A^@
^@^@^@^@^@M-1ZKX1?^D^@^@^@^@^@^@^@^@^@M-1ZKXr^^D^@^D^@^D^@(^@^G^@M-1ZKXr^^D^@^A^@^\^@^A^@^@^@M-1ZKXr^^D^@^@^@^@^@^@^@^@^@M-1ZKXM-2}^D^@^D^@^D^@(^@^G^@M-1ZKXM-2}^D^@^A^@^\^@^@^@^@^@M-1ZKXM-2}^D^@^@^@^@^@^@^@^@^@0005665859

我怎么能翻译这个?它可能吗?非常感谢帮助我

1 个答案:

答案 0 :(得分:2)

使用evdump解释原始数据: evdump /dev/input/by-id/usb-Sycreader_RFID_Technology_Co.__Ltd_SYC_ID_IC_USB_Reader_*

我假设你想阅读整个RFID代码。为此,请使用以下Python脚本,该脚本主要基于https://stackoverflow.com/a/27913707/5795026

from evdev import InputDevice, ecodes, list_devices
from select import select

keys = "X^1234567890XXXXqwertzuiopXXXXasdfghjklXXXXXyxcvbnmXXXXXXXXXXXXXXXXXXXXXXX"
dev = InputDevice("/dev/input/by-id/usb-Sycreader_RFID_Technology_Co.__Ltd_SYC_ID_IC_USB_Reader_08FF20140315-event-kbd")

barcode = ""
while True:
    r,w,x = select([dev], [], [])

    for event in dev.read():
        if event.type != 1 or event.value != 1:
            continue
        if event.code == 28:
            print(barcode)
            barcode = ""
            break
        barcode += keys[event.code]