我正在尝试使用 Python 脚本从 USB RFID 阅读器读取数据。使用手机上的 NFC 工具将数据写入 RFID 标签。因此,当我在 RFID 阅读器上扫描 RFID 标签时,Python 脚本应该显示我写入 RFID 标签的数据。
例如,我在 RFID 标签中写入一个字符串“123456”。
我希望它显示字符串。
我参考本指南来阅读 RFID 阅读器:https ://github.com/charlysan/pyrfidhid
但这不起作用。我认为它不起作用,因为脚本用于不同的阅读器模型。我尝试使用这些命令在我的 Linux 上查找 RFID 阅读器信息。
须藤 lsusb
Bus 001 Device 004: ID ffff:0035 Sycreader USB HID READER
须藤 lsusb -vd ffff:0035
Bus 001 Device 003: ID ffff:0035 Sycreader USB HID READER
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0xffff
idProduct 0x0035
bcdDevice 1.10
iManufacturer 1 Sycreader
iProduct 2 USB HID READER
iSerial 3 20170320
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x001b
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 200mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 4 USB VENDER HID
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 33 US
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 38
Report Descriptor: (length is 38)
Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
(null)
Item(Local ): Usage, data= [ 0x01 ] 1
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Report ID, data= [ 0x01 ] 1
Item(Local ): Usage, data= [ 0x03 ] 3
(null)
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0xff ] 255
Item(Main ): Feature, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report ID, data= [ 0x02 ] 2
Item(Local ): Usage, data= [ 0x03 ] 3
(null)
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0xff ] 255
Item(Main ): Feature, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report ID, data= [ 0x03 ] 3
Item(Local ): Usage, data= [ 0x03 ] 3
(null)
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0xff ] 255
Item(Main ): Feature, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection, data=none
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
须藤树/开发/输入
/dev/input
├── by-id
│ ├── usb-Logitech_USB_Optical_Mouse-event-mouse -> ../event7
│ ├── usb-Logitech_USB_Optical_Mouse-mouse -> ../mouse0
│ ├── usb-SONiX_USB_DEVICE-event-if01 -> ../event6
│ └── usb-SONiX_USB_DEVICE-event-kbd -> ../event2
├── by-path
│ ├── pci-0000:03:00.0-usb-0:7:1.0-event-mouse -> ../event7
│ ├── pci-0000:03:00.0-usb-0:7:1.0-mouse -> ../mouse0
│ ├── pci-0000:27:00.3-usb-0:4:1.0-event-kbd -> ../event2
│ └── pci-0000:27:00.3-usb-0:4:1.1-event -> ../event6
├── event0
├── event1
├── event10
├── event11
├── event12
├── event13
├── event14
├── event15
├── event16
├── event17
├── event18
├── event2
├── event3
├── event4
├── event5
├── event6
├── event7
├── event8
├── event9
├── mice
└── mouse0
2 directories, 29 files
但是这个命令sudo tree /dev/input
没有显示任何与我的 RFID 阅读器相关的设备。
硬件:
- USB RFID 阅读器 EM4100
- RFID 贴纸 NXP MIFARE Ultralight (Ultralight C)
据我了解,USB 应该用作 Python 中的串行库,但阅读器充当 HID 设备。所以我尝试使用这个命令安装 Python 库。
须藤 pip 安装隐藏
任何人都知道如何制作 Python 脚本或任何可能相关的指南?我已经在作者的 GitHub 上打开了这个问题:https ://github.com/charlysan/pyrfidhid/issues/8
谢谢。