Skip to content
Hlab edited this page Mar 1, 2013 · 21 revisions

Version Tracking

Version 1.2

Changed the original serial_server_v1_1 found among provided LabRAD modules

  • support for both windows and linux
  • additional settings for flushing input and output

Troubleshooting

Port Names Keep Changing

Devices may get assigned a new port name (COM1 instead of COM0 or ttyUSB1 instead of ttyUSBO) if they are restarted while the port is open. This is the case when the serial server and the device server are both running. To avoid this issue, the device server has to be turned off before power cycling or disconnecting the device.

Alternatively, by defining udev rules, we can address each device using an alias regardless of which port it decides to connect to. Say, for example, that our Attocube piezo controller is currently assigned to /dev/ttyUSB1. Using udevadm, we can determine its full device path.

$ udevadm info -q path -n /dev/ttyUSB1
/devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.6/2-2.6:1.0/ttyUSB1/tty/ttyUSB1

We can then use this output to list all udev attributes of our device/all of its parent devices.

$ udevadm info -a -p /devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.6/2-2.6:1.0/ttyUSB1/tty/ttyUSB1
looking at device '/devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.6/2-2.6:1.0/ttyUSB1/tty/ttyUSB1':
    KERNEL=="ttyUSB1"
    SUBSYSTEM=="tty"
    DRIVER==""

 looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.6/2-2.6:1.0/ttyUSB1':
    KERNELS=="ttyUSB1"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ftdi_sio"
    ATTRS{latency_timer}=="1"
    ATTRS{port_number}=="0"

 looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.6/2-2.6:1.0':
    KERNELS=="2-2.6:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ftdi_sio"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceSubClass}=="ff"
    ATTRS{bInterfaceProtocol}=="ff"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{interface}=="USB Serial Converter"

 looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-2/2-2.6':
    KERNELS=="2-2.6"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bMaxPower}==" 44mA"
    ATTRS{urbnum}=="3731378"
    ATTRS{idVendor}=="0403"
    ATTRS{idProduct}=="6001"
    ATTRS{bcdDevice}=="0600"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="2"
    ATTRS{devnum}=="36"
    ATTRS{devpath}=="2.6"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="FTDI"
    ATTRS{product}=="USB Serial Converter"
    ATTRS{serial}=="FTF89AE9"

+Attributes of more parent devices...

In my brief experience, the KERNELS and ATTRS{serial} attributes of the 4th parent device has been enough to uniquely identify each usb device. We can then write these attributes, as well as an alias, to a .rules file in the /etc/udev/rules.d directory, e.g., /etc/udev/rules.d/assign-USB.rules.

KERNELS=="2-2.6",ATTRS{serial}=="FTF89AE9",SYMLINK+="attocube"

After triggering our new udev rule, the Attocube controller will be accessible accessible via /dev/attocube!

$ udevadm trigger

Ubuntu Ports Not Found

On Linux, if no serial ports are found, make sure the user has the right permissions to open the serial ports.

ls -l /dev/

For instance, one can add the user to the group dialout

adduser username dialout

To make sure one can open the port, use the python serial library, i.e

import serial
ser = serial.Serial('/dev/ttyUSB0')

Clone this wiki locally