Recent site activity

Welcome‎ > ‎

USB Round-trip latency

posted 29 Nov 2009 13:01 by Chris Shucksmith
The USB port on the STM32 is now working! I now have Java -> RXTX -> USB /dev/ttyACM0 -> USB cable -> STM32 USB Library -> C-code. Here's the Java stdout console showing the round trip time for a simple protocol. The device consumes a byte, shifts it and sends the result back.

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
Opening /dev/ttyACM0
1259527875761 << sent 00000001 01
1259527875763 >> recv 00000010 02
1259527875763 << sent 00000001 01
1259527875766 >> recv 00000010 02
finished
Experimental:  JNI_OnLoad called.

A 3ms round trip seems reasonable, given the polling nature of USB IN endpoints and all the context switching/vm calls on the PC host. I'm sure the USB latency can be improved with other transfer modes than CONTROL, but that would require replacing RXTX with my own libusb (JNI) code.

Here's the result of dmesg when the device is inserted:

usb 4-1: USB disconnect, address 30
usb 4-1: new full speed USB device using uhci_hcd and address 31
usb 4-1: New USB device found, idVendor=0483, idProduct=5740
usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 4-1: Product: ShuckcByteshifter  
usb 4-1: Manufacturer: ShuckcMicroelectronics
usb 4-1: SerialNumber: 6
usb 4-1: configuration #1 chosen from 1 choice
cdc_acm 4-1:1.0: This device cannot do calls on its own. It is no modem.
cdc_acm 4-1:1.0: ttyACM0: USB ACM device

The code I've adapted presents itself as an ACM device to allow the host to send a lineconfig, i.e. port settings for a virtual com device, but I don't need that functionality.