Symbol barcode scanner on Linux

Aug 09
2011

Motorola Symbol make some very nice barcode scanners that now come in USB models such as the MS4407.

Unfortunately these devices show up in Linux as Human Input Devices (HID), so basically they emulate a keyboard.  This makes it pretty easy to use them to scan text barcodes, they are keyboards after all, but scanning binary data can be nearly impossible. After some experimentation I found a way to make this work (on Ubuntu 10.04).  If you are the impatient type like me scroll down to the bulleted list below.

The scanner supports a couple of different modes on the USB HID interface.  One of the available options is so called “Simple COM Port Emulation”.  By the sound of it this should make the scanner emulate a serial port, but unfortunately it is not that simple.  Even when configured like this the device still show up in Linux as a HID, so it does not create a serial port.

But in this mode the scanner does send ASCII data down to the USB host after it has been connected to the windoze driver at least once.  Don’t ask me why it needs to be connected to windoze first, I can only assume that the windows drivers configure something in the scanner that is needed to make this work.

After connecting the scanner to a windoze box with the Symbol Virtual Com Port Driver installed, the scanner is still detected by Linux as an HID, but it sends ASCII down the USB wire to the host which is then usable by reading directly from the raw HID device.  In my case it was /dev/hidraw4 🙂

It seems to always send 64 bytes.  First byte is the type of barcode scanned followed by the barcode data which is null padded to 63 bytes.  Provided that you know how many bytes to expect or your barcodes do not contain null characters this data stream is then easy enough to decode.  I think it is possible to switch off sending the type of barcode using the configuration guide as well.

So here are the steps:

  1. Download and install the Symbol Virtual COM Port Driver on a windoze box or VM.
  2. Configure the scanner to do “Simple COM Port Emulation” using the barcodes in the configuration guide.
  3. Connect the scanner to the windoze box, open hyperterminal and scan some barcodes.
  4. Do “ls /dev/hidraw*” on your Linux box
  5. Plug the scanner back into the Linux box and do “ls /dev/hidraw*” again – there should be a new raw device /dev/hidrawX that was not there before.
  6. Now you can read the scanned barcodes from /dev/hidrawX.

You can download the Symbol Windoze Virtual COM Port Driver from here and the configuration manual from here. Simple COM Port emulation barcode is on page 10-4.

 

 

 

Not unto the swift…

The race is not to the swift or the battle to the strong, nor does food come to the wise or wealth to the brilliant or favor to the learned; but time and chance happen to them all.
— Ecclesiates 9:11 (NIV)