Read RFID tag using LibUsbDotNet

2.1k Views Asked by At

I have a generic USB RFID card reader.

I am using code from How to read from a usb rfid reader? to read the data. It seems to read okay, however, the output is a byte array. What I want to get is the RFID number, the one that's printed on the card. How can I get this?

EDIT

I successfully retrieved the tag number by implementing a key logger. It seems that the reader does not directly send the tag number down the wire, but rather, sends a command to type the tag number out. This solution works but I'm still open to other, more direct approaches.

1

There are 1 best solutions below

1
kahveci On

After successfully reading the RFID tag, all you need to do is to convert the byte array into a string. Please refer to the following line of code and this link for more details.

// readBuffer: The byte array containing the sequence of bytes to decode.
// 0: The index of the first byte to decode.
// bytesRead: The number of bytes to decode.
var strRfidTag = System.Text.Encoding.Default.GetString(readBuffer, 0, bytesRead);