10

I've got this nice USB barcode scanner and I'd like to readthe input using the USB driver and not the keyboard input.

How can this be accomplished using .NET? any ready libraries? I couldn't find anything of real use...

Thanks!

Roman
  • 4,443
  • 14
  • 56
  • 81

2 Answers2

13

If it is a USB reader, you should find the .net drivers that come with it, such that you get a class which provides the IO and perhaps more functionality.

If the scanner has internally a USB to Serial converter, then you should see in your Device Manager which COM port is in use by the scanner. In that case, you can use the SerialPort class for communication to the device. Note that you should set the settings (i.e. baudrate, parity bit, stop bit, etc) correct before you can have any communication.

Henri
  • 5,065
  • 23
  • 24
  • +1. You beat me to it. That was almost word for word what I was about to suggest, and it's what we've done in our projects. – David Jun 08 '10 at 21:51
  • 1
    A lot of devices are interally high-speed serial with a USB connection, but without exposing an actual serial port. In this case, you may be able to determine the chipset and write against those drivers directly. FTDI is a very common choice, and they expose their devices via their [D2XX](http://www.ftdichip.com/Drivers/D2XX.htm) library. – Stephen Cleary Jun 08 '10 at 21:54
  • I never seen professional barcode reader who can't emulate serial port. Serial ports is always easier to read and most applications read com ports, not usb. – Tommix Mar 07 '16 at 08:26
4

You can read (and control) the device using USB HID reports.

http://www.codeproject.com/KB/cs/USB_HID.aspx

http://www.florian-leitner.de/index.php/2007/08/03/hid-usb-driver-library/

Thomas Kjørnes
  • 1,928
  • 1
  • 17
  • 17