Linux

Revision as of 20 October 2020 17:06 by JGoss (Comments | Contribs) | (Using USB to Serial adapters in Linux)

Opticon does not officially endorse or support any Linux-based operating system, however we've noticed that the Linux kernel has good support for most of our devices. We can't guarentee that any of the below will work, as it's dependent on your particular distribution and version of the Linux kernel, but if you're running a modern distribution and you haven't modified and recompiled the kernel, there's a good chance the below will work for you.

USB-HID

Most of Opticon's scanners can be configured to transmit data as USB keyboards (This is the USB-HID mode). Since the Linux kernel provides good support for USB keyboards, this means that Opticon's scanners work very well under Linux in this mode. The scanner will act like a keyboard in this mode, meaning the bar code scanner will output scanned data into the Linux Host keyboard buffer. The output will be seen on the application that is open at the time. This mode is for one way communications only (i.e. thes scanner outputs data to the host ONLY.

If two way communication is necessary (i.e. send scanned data or receive commands from the host), then the scanner needs to be placed in USB-VCP mode and then two way communication is performed through the creation of a virtual COM port.

USB Serial Drivers for USB-COM Mode

There are two ways that Opticon's devices can be accessed in Linux while in USB-COM (Virtual COM Port mode). Our 1D devices (in USB-COM mode) do not need a separate driver for serial communication (Linux has the proper device driver). As well, our 2D products and some 1D use a generic CDC/ACM driver for serial communication. Since this is also well-supported in Linux, most of our products are supported.

  • The typical method for accessing our 1D laser products is to open the /dev/ttyUSB# file, where the # is a number, starting from 0 and counting up.
  • Our 2D products (and 1D CCD products) are accessed through a similar device file, with the exception that since they use the CDC drivers they are accessed through /dev/ttyACM#.

A quick method for testing data transmission is to open the file corresponding to your device with the "cat" utility, then scanning some bar codes. For example, if your 1D scanner is the only USB-COM device on the system, it can be accessed by typing "cat /dev/ttyUSB0" into the terminal. You may need adequate permissions on the device file in order to open it, but it should work once you have them.

It's also possible to use tools like ttylog to wedge keyboard data into a terminal from a serial port.

  • ACM = Abstract Control Model
  • CDC = Communications Device Class

Using USB to Serial adapters in Linux

For Linux operating systems, activate the CONFIG_USB_SERIAL_FTDI_SIO config option and rebuild the kernel, or:

# cd /usr/src/linux && make menuconfig

Linux > Device Drivers > USB > USB Serial Converter > USB FTDI Single Port Serial Driver

# make bzImage && make modules && make modules_install && make install

Should see something within syslog similar to the following:

  • Product: FT232R USB UART
  • Manufacturer: FTDI
  • SerialNumber: XXXXXXXX
  • Detected FT232RL
  • FTDI USB Serial Device converter now attached to ttyUSB0

Bluetooth

Many modern Linux distributions also provide good support for Bluetooth through the BlueZ stack, which has a comprehensive list of Bluetooth profiles that it supports. Opticon's devices transmit data over Bluetooth in one of two ways. They present themselves in either SPP-mode profile, with an accompanying serial port, or in HID-mode profile, where they present as any other HID device.

In either case, no driver is necessary as both SPP-mode and HID-mode communication use the generic profiles with no modification or adaptation. A modern Linux distribution running a window manager typically has packages available for managing Bluetooth devices. These packages are well-supported and in most cases work with Bluetooth devices quite well out of the box.