#125 Undefined 'base' on list_ports_posix.py, function usb_lsusb

v1.0 (example)

Steps to reproduce:
- Plug a generic usb-serial adapter (e.g. prolific 2303)
- Try to list serials with list_ports.comports()

Bug: On list_ports_posix.py, function usb_lsusb_string is calling lsusb with parameter "-s X:Y". According to lsusb manual, X should be the bus number and Y should be the device number. However, on the python function, those values came from parsing of device path, from function "describe". This function is getting the correct bus number, but getting the port number, not the device number. In the end, lsusb is being called with Y being the port number, which causes it to return without the expected result.

Suggestion: get the bus and device numbers using another method that is not path parsing (e.g. on my box I have busnum file (with a 6 inside) and devnum file (with a 5 inside) on "/sys/devices/pci0000\:00/0000\:00\:1d.0/usb6/6-2/", for device plugged on bus 6, port 2).


  • Bruno

    Bruno - 2012-08-06

    Some versions and error output

  • Kris Hardy

    Kris Hardy - 2013-09-12

    Here is another point to add... The Undefined 'base' on line 80 of list_ports_posix.py (function usb_lsusb_string) is thrown because on an exception the function is returning an undefined variable 'base'.

    I didn't evaluate the code, but I hacked my way out of this by applying the following patch to list_ports_posix.py:

    <             return base
    >             return ""

    This needs to be fixed in the right way by someone more familiar with the code.

    Last edit: Kris Hardy 2013-09-12
  • Chris Liechti

    Chris Liechti - 2013-10-11

    fixed by reading device number from "devnum" file in sysfs path

  • Chris Liechti

    Chris Liechti - 2013-10-11
    • status: open --> closed-fixed
    • assigned_to: Chris Liechti
    • Group: --> v1.0 (example)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks