Search code examples
delphiusbrfid

Handle a RFID from Delphi Application R/W


I need to read/write cards using a RFID Reader more specifically this:

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

I am not very clear about how to do this since it is my first time with hardware devices connected to the USB port.

I find out there is a TComPort library, I allready installed it on my Delphi Berlin 10.1

From the parallax documentation I found this:

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)

The question here is, how can I perfom these actions to write/read using the TComPort component?


Solution

  • By using Windows' CreateFile call you're able to connect to a connected USB device directly. All you need is the full, correct 'port name', see the GetPortName method here