User:Uli/Serial port latency testing

Jump to: navigation, search

This describes how to determine the receive latency of a serial port, using a loopback cable. It is assumed that the serial port to be tested is connected through a USB-to-serial converter to a USB port on the same system. The receiving serial port is called /dev/ttySC1.

Make sure the python-serial package is installed. Run this Python script:

import time
import serial
ser_in = serial.Serial('/dev/ttySC1', 921600)
ser_out = serial.Serial('/dev/ttyUSB0', 921600)

t1 = time.time()
x =
t2 = time.time()
print x,(t2-t1)*1000000

It will output the time passing between sending of a character and it being available from the receiving character device, in microseconds.