Skip navigation

emUSB-Host Samples

Barcode Scanner

example-scan.jpg
General Information:

Connecting a barcode scanner to a target device is an easy task when using emUSB-Host. Most barcode scanners are simple HID devices that are supported out of the box.

These scanners behave like a keyboard. Each time a barcode is scanned, the scanner translates the code into a series of key presses and releases. So scanning a barcode indicating www.segger.com 

sends a sequence of key pressed and key released for each character. The sample USBH_HID_Start can visualize this:

'w'-key is pressed, 'w' is released
'w'-key is pressed, 'w' is released
'w'-key is pressed, 'w' is released
'.'-key is pressed, '.' is released
's'-key is pressed, 's' is released
'e'-key is pressed, 'e' is released
'g'-key is pressed, 'g' is released
'g'-key is pressed, 'g' is released
'e'-key is pressed, 'e' is released
'r'-key is pressed, 'r' is released
'.'-key is pressed, '.' is released
'c'-key is pressed, 'c' is released
'o'-key is pressed, 'o' is released
'm'-key is pressed, 'm' is released
'Enter'-key is pressed, 'Enter' is released

Using the USBH_HID_Keyboard sample project will display the following output:

The following text was entered: www.segger.com

The output can be seen in the Terminal window of a debugger such as Ozone, the Terminal Window of an IDE such as Embedded Studio or in J-Link RTT Viewer.

Text Display for PoS Systems

General Information:

POS Displays are available in different configurations. Those can be connected via RS232, RS484 or SPI but also via USB, in normal cases which will be recognized as either a CDC-ACM device (USB-to-UART) or a FTDI device.
Even though they use different connectors they all have in common that they support either a common command set and/or a vendor command set to output data on the display. One of the common used ones is ESC/POS which allows to send special commands such as initialize or put the following line on second line.

Displays with a USB interface are the easiest one as they allow plug'n'play, does not need to be parameterized (UART speed, parity,  data bits etc) and in case of a failure it can be replaced while the system is running.

Connecting such a target device where emUSB-Host with the CDC component and FT232 component enabled is running is very simple.
Using the USBH_TERM_API a POS display is detected automatically and can easily used to display text.

A simple application could be look like the following:

  USBH_TERM_Init();

  USBH_TERM_Print(0, 0, "     SEGGER     ");
  USBH_TERM_Print(1, 0, "It simply works!");

4G/LTE Data USB Stick

General Information:

4G/3G sticks are quite handy as they enable connections to the internet by simply plugging such a device into a PC, install the driver, and configure the device. Current LTE/4G sticks are connected just like a USB-to-Ethernet Adapter not requiring configuration at all.

Having a target system with emUSB-Host with the LAN component and embOS/IP allows you to use such a 4G stick. Currently the Huawei E3372-H is supported and with some little modification in one single file other 4G sticks will work.

In order to use the Huawei stick, please note, that a SIM card without PIN verification is necessary in order to connect automatically to Internet.

Ethernet-over-USB adapter

General Information:

Ethernet-over-USB adapters can be used to extend your embedded system with network connectivity.

Internally Ethernet-over-USB adapters use different protocols, depending on the vendor or model of the device. CDC-ECM or protocols from the company ASIX are most common in Ethernet-over-USB adapters, Android phones often use RNDIS to communicate. emUSB-Host LAN supports all these protocols.

The demo is configured with a webserver, after programming the device and connecting it to your local network via an Ethernet-over-USB adapter you can use the URL "http://usbh.local" to open the web server demo.