etienne_marais
Honorary Master
So we have a couple of RFID readers (cheapies from China) which Windows detects and polls.
If we bring an RFID card near the new device it beeps and sometimes brings up something random, like open one of the pictures in the picture folder.
The RFID card goes hand in hand with a different RFID reader we have been using for years now, but they are explicitly read, not activated on contact (using our legacy RFID readers).
I am trying to see if I can read from the card using c#, I am not sure if I must deactivate something in Windows first to take control of the new RFID reader, I am also not sure if I am somehow forced to use polling mode (instead of the code below).
The initialization seems to work fine using the vendor and product ids as found in device manager.
It reads 0 bytes and the light on the device does not flash nor does it beep.
Any ideas ?
If we bring an RFID card near the new device it beeps and sometimes brings up something random, like open one of the pictures in the picture folder.
The RFID card goes hand in hand with a different RFID reader we have been using for years now, but they are explicitly read, not activated on contact (using our legacy RFID readers).
I am trying to see if I can read from the card using c#, I am not sure if I must deactivate something in Windows first to take control of the new RFID reader, I am also not sure if I am somehow forced to use polling mode (instead of the code below).
The initialization seems to work fine using the vendor and product ids as found in device manager.
Code:
namespace TestUSBRFIDReader
{
class Program
{
public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(65535,53);
static void Main(string[] args)
{
UsbDevice usbd = UsbDevice.OpenUsbDevice(MyUsbFinder);
bool c = MyUsbFinder.Check(usbd);
usbd.Open();
IUsbDevice wholeUSBDevice = usbd as IUsbDevice;
if (ReferenceEquals(wholeUSBDevice,null))
{
wholeUSBDevice.SetConfiguration(1);
wholeUSBDevice.ClaimInterface(0);
}
UsbEndpointReader r = usbd.OpenEndpointReader(ReadEndpointID.Ep01);
byte[] buff = new byte[1024];
ErrorCode ec = ErrorCode.None;
while (ec == ErrorCode.None)
{
int bytesRead;
ec = r.Read(buff, 5000, out bytesRead);
Console.WriteLine(bytesRead + " bytes read");
Console.WriteLine(Encoding.Default.GetString(buff, 0, bytesRead));
}
usbd.Close();
}
}
}
It reads 0 bytes and the light on the device does not flash nor does it beep.
Any ideas ?