Capturing USB or serial traffic

It is sometimes useful to capture the data a touch device sends, or the whole exchange between the device and the system, to help troubleshoot. This document describes the ways to do it for USB and serial devices.

With USB devices this can be done in one of three ways: with the UPDD data capture function (see Capturing raw touch data only; the diagnostics package includes such a capture), with a software USB analyser, or by monitoring the data at the hardware level with a USB analyser. For serial devices see Serial port testing below.

One of the trickiest support issues is where the driver and system appear to be correctly configured but touch does not work as expected. The diagnostic and debug functions of the driver may show that the issue is with the hardware interface, such as a USB error in the middle of reading data:

2018/06/29-21:37:21: DBG: Read 56 bytes for  VID 0x222a PID 0x11e EP 0x82
2018/06/29-21:37:21: DBG: Read 56 bytes for  VID 0x222a PID 0x11e EP 0x82
2018/06/29-21:37:21: ***: USB: (LIBUSB_TRANSFER_ERROR)
2018/06/29-21:37:21: ***: USB: (LIBUSB_TRANSFER_ERROR closing device)

When investigating USB hardware issues it can then help to have a trace of the USB exchange between the driver and system and the device, to see why the error occurs.

Software USB capture

To capture the USB protocol between a device and the driver, use a software USB monitoring tool on the host. Most Windows USB monitoring tools can capture this information. We use USBlyzer; others exist, such as https://freeusbanalyzer.com/. A Windows capture can be useful even when the USB issue is on another operating system.

If the touch device is known to be capable of multi-touch output, it is best to capture the data in Windows (7 to 11) so that the device enters multi-touch mode.

Download and install USBlyzer, preferably the 64-bit version, as trace logs need to be created on a compatible system to be viewed. Before using USBlyzer, open a command window with admin rights, type

bcdedit -set testsigning on

and reboot. When finished, uninstall USBlyzer and type

bcdedit -set testsigning off

Taking a USBlyzer trace

  1. If you are using an external touch screen that can be plugged into a USB port, run USBlyzer and select Capture Hot-plugged:
  2. Now plug in the device or, for an internal USB device, find and select it in the device tree. In this example the touch screen cable of a Dell P2314T monitor has been plugged in and selected automatically:
  3. Start the capture and touch the screen:
  4. Stop and save the capture, and attach the .ulz log file to your ticket:

What to capture

With the capture tool we are trying to capture the following data from the controller:

Start the program and identify the touch screen in the list of USB devices. In this example the touch device is registered as a USB Composite Device comprising three USB Input devices, all of which list the vendor and product id of the touch device.

USB vendor and product id

This touch device registers as a composite device, meaning it has a number of interfaces, and the tree shows three USB Input Devices. The first entry is the touch entry on interface 0; this is the device we need to support. The other entries are likely to be tablet, mouse and even keyboard entries. Depending on the operating system the device outputs touch, tablet or mouse packets. With UPDD we try to configure devices to output touch data packets whatever the operating system, so we are only interested in the touch mode initialisation and the touch data format.

Some touch devices, such as non-HID devices or devices running in a HID mode other than 'touch' mode, may not be listed as a 'Touch' device. In this case identify the touch device as best you can; it may, for example, be listed as a digitiser, mouse or other type of device. This is easier if you know the vendor id of the device.

HID enumeration

Next, choose to capture the device information when the device is enumerated (hot-plugged), to see whether HID places the device in any special mode of operation:

Identify the touch device in the device tree and tick all the entries related to it, to indicate this is the device to capture.

Start the capture and disconnect and reconnect the device (or disable and enable it in the Device Manager if it cannot be unplugged). In this instance the device indicated in its USB descriptor that it is capable of more than one touch, and we can see below the USB feature request sent by the Windows HID driver to tell the controller that the driver supports multi-touch and that it should run in multi-touch mode. This captured data allows us to set up the correct USB request in UPDD asking the device to run in multi-touch mode whatever the operating system. Some controllers only output single touch (mouse) data, or none at all, on other operating systems.

Touch data packets

Touching the touch screen now records the touch data exchange, here with a single touch:

and with two touches:

Save the recordings at appropriate times and send us the log files for analysis.

Hardware USB analyser

Where a software capture is not enough, for example when the exact timing of the exchange matters, a hardware USB analyser is needed between the port and the device. Being external, it is independent of the operating system in use. Touch-Base has a Beagle USB analyser in house for such cases; raise a ticket at https://www.touch-base.com/contact if you think a hardware-level capture is needed.

Serial port testing

Successful support of a serial device depends on the RS232 communication settings being correct, the COM port being available (it exists and is not in use by another driver) and the data being seen at the port in the correct format.

The best way to test this is to use an external program to prove the above before you specify the port in the UPDD driver. For a quick test of an RS232 port, open a terminal or command window, type the command shown and touch the screen:

OSTerminal command
Windowstype com1:
Linuxcat < /dev/ttySn (or ttyUSBn if using a serial to USB adapter)
macOScat < /dev/[port]

In this macOS example a Keyspan serial adapter is listed and tested by touching an attached touch screen:

This does not show the actual data received, just that data is being received. To view the actual data use a serial terminal program, as described below.

Serial terminal programs

For all operating systems there is a simple serial port terminal program called CoolTerm. In this Windows example CoolTerm is connected to COM3 (a Keyspan serial to USB adapter) with a serial touch screen connected:

When capturing data it is important to match the baud rate to that expected by the device. The wrong baud rate results in strange, garbled data being captured and displayed. The most common baud rate is 9600, followed by 2400 and 19200:

Important: view the data in hex format.

This old serial device outputs a 'heartbeat' packet FF 80 00 00 and a 3 byte data packet when touched: D5 58 30 (touching packet) and 95 58 2F (lift off packet) in the data captured below:

When sending serial data to us for analysis, either send a screenshot of the captured hex data or select Capture to Text File:

For Linux, install instructions are included in the CoolTerm download package ('Linux System Requirements.txt').

Alternatively, on Windows you may wish to use one of the many available serial terminal programs, such as Terminal, and on the Mac the Serial application. A customer also reported that the CuteCom utility is really simple to use and made short work of determining the port and baud rate. It is available for Linux and macOS and can be installed on Linux with the command

sudo apt-get install cutecom

For review

  • The USBlyzer download link points to v6download.touch-base.com (a static download). Check the host still serves it, or whether the tool should be fetched elsewhere.
  • The USB basics link stays on 50434 (retired, not in the outline: verbatim text from Linux Device Drivers). Decide whether to keep a link to it at all.
  • 50431 and 50526 described USBlyzer twice; the steps of 50526 are now 'Taking a USBlyzer trace' and the detail of 50431 follows it. The libusb log example in the introduction is a V6 log (2018).