0

I have a QR-Code Scanner Device which is connected via USB with my Computer. The device itself is set to the HID Keyboard Interface. I tried to detect a new QR-Code with the hidlibrary, but unfortunately I can't get it to work. I am using WPF, C# and .NET Core. I tried something like this:

devices = HidDevices.Enumerate(0x05E0, 0x1200).ToList();
SelectedDevice = devices.FirstOrDefault();

SelectedDevice.OpenDevice();
SelectedDevice.Inserted += SelectedDevice_Inserted;
SelectedDevice.Removed += SelectedDevice_Removed;
SelectedDevice.ReadReport(OnReport);

private void OnReport(HidReport report)
{
    if (!SelectedDevice.IsConnected) return;
    var byteFromDevice = report.Data;
    SelectedDevice.ReadReport(OnReport);
}

private void SelectedDevice_Removed()
{
    logger.Info("Scanner device removed!");
}

private void SelectedDevice_Inserted()
{
    logger.Info("Scanner device attached");
    SelectedDevice.ReadReport(OnReport);
}

I am pretty sure that the VendorID(0x05E0) and the ProductID(0x1200) are correct. For safety I'll attach a screenshot of the device settings from windows. When I try to run this code I get this error message: Operation is not supported on this platform.

I searched a lot on google on how to get the scanned data from a QR-Code Scanner but can't find anything working. This hidlibrary was my last chance but somehow it does not work.

I saw things like getting the KeyDownEvent from the QR-Code Scanner, but the problem is, that the code where I receive the events is not in a Form or Window. Therefore I can't receive these events.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Karl Wolf
  • 268
  • 2
  • 13
  • The self-answers in this article may be helpful. [Equivalent to a keypreview property in WPF](https://stackoverflow.com/q/1918642/9014308) – kunif Aug 05 '21 at 12:11
  • What is the manufacturer / model of your scanner? – Tu deschizi eu inchid Aug 05 '21 at 12:30
  • Well I have a Zebra DS3608 next to me. But I will need another one as it does not fit the requirements anymore. And I will probably don't have access to the Scanner SDK from Zebra itself. So I try to find a workaround. Usually all scanner do the same thing, so I can test it with this one and should be able to transfer it to the new one. – Karl Wolf Aug 05 '21 at 12:33
  • The following may be helpful: https://www.zebra.com/us/en/support-downloads/software/developer-tools/scanner-sdk-for-windows.html, https://www.zebra.com/us/en/support-downloads/scanners/ultra-rugged-scanners/ds3608-hd-ds3678-hd.html#pageandfilelist_aec , and https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/barcode-scanners/software/ssi-cordless-pg-en.pdf – Tu deschizi eu inchid Aug 05 '21 at 12:49
  • It would be when it would be possible for me to use the scanner sdk. I will very likely not be able to use it. So I try to find a workaround – Karl Wolf Aug 05 '21 at 12:52
  • Since you're using a wireless scanner, you may want to first get the scanner that you plan to use. – Tu deschizi eu inchid Aug 05 '21 at 12:56
  • Well all scanner use the same kind of interface to comunicate with the computer. It should be possible to test it with the zebra scanner and then use that code for another one. – Karl Wolf Aug 05 '21 at 12:57

1 Answers1

0

Change your device to "USB Serial" and then use SerialPort Class

See this post for how to read the data.

Tu deschizi eu inchid
  • 4,117
  • 3
  • 13
  • 24