处理来自 Delphi 应用程序 R/W 的 RFID

Handle a RFID from Delphi Application R/W

我需要 read/write 使用 RFID 的卡片 Reader 更具体地说:

https://www.parallax.com/product/28440

我不是很清楚如何做到这一点,因为这是我第一次将硬件设备连接到 USB 端口。

我发现有一个 TComPort 库,我已经在我的 Delphi Berlin 10.1

上安装了它

我从视差文档中发现:

Serial Communication (9600 baud default) Timeout is 100ms

Write to RFID card:

Send ASCII character 'w' to initiate write mode.

Device will respond with 0x01 and will expect 4 bytes of data in return which will be the information entered in the 'Membership Year' Text box.

Device will respond with 0x02 and will expect 4 bytes of data in return which will be the information entered in the 'Membership ID' Text box.

Read:

Send ASCII character 'r' to initiate read mode.

Device will send 4 bytes of data (send to Card ID text box) and wait for a 0x01 response. Device will send a further 4 bytes of data (Membership Year), and wait for a 0x01 response. Device will send a final 4 bytes of data (Membership ID Number)

这里的问题是,如何使用 TComPort 组件对 write/read 执行这些操作?

通过使用 Windows' CreateFile 调用,您可以直接连接到已连接的 USB 设备。您只需要完整、正确的 'port name',请参阅 GetPortName 方法 here