Menu

#31 Add dict output to list_ports tool

pending
None
5
2015-09-22
2012-06-28
Matt Mets
No

Rather than pushing serial port descriptions into strings, and then using regex to identify them, it might be nice to instead return all descriptive features as a dictionary:

$ python list_ports.py
/dev/cu.usbserial-A400fZ3q : {'USB Serial Number': 'A400fZ3q', 'idVendor': 1027, 'USB Product Name': 'FT232R USB UART', 'idProduct': 24577}
/dev/cu.usbmodemfd1241 : {'USB Serial Number': '64935343133351305140', 'idVendor': 9153, 'USB Product Name': 'The Replicator', 'idProduct': 54036}
/dev/cu.usbmodemfd1211 : {'USB Serial Number': '64932343838351917111', 'idVendor': 9025, 'USB Product Name': 'Arduino Uno', 'idProduct': 1}
/dev/cu.Bluetooth-Modem : {}
/dev/cu.Bluetooth-PDA-Sync : {}
/dev/cu.usbserial-A700flx4 : {'USB Serial Number': 'A700flx4', 'idVendor': 1027, 'USB Product Name': 'FT232R USB UART', 'idProduct': 24577}

This could be implemented as an extra parameter to the existing interface, or as a replacement for the current interface. A backwards compatibility mode could be implemented so as not to break anything that was expecting the device strings.

It would also allow for other kinds of information (bluetooth/etc?) to be passed through, without breaking any expectations that the regex parsers might have.

If this looks interesting, i can put together a patch.

Discussion

  • Matt Mets

    Matt Mets - 2012-06-28

    My apologies, the above command should have had a -v tag for verbose mode.

    For reference, the current implementation looks like this:
    /dev/ttyACM0
    desc: ttyACM0
    hwid: USB VID:PID=2341:0001 SNR=64932343838351917111
    /dev/ttyS0
    desc: ttyS0
    hwid: n/a
    (continues)

     
  • Chris Liechti

    Chris Liechti - 2015-09-22

    the current implementation at https://github.com/pyserial/pyserial returns an info object (under Linux and Win32, OSX going to follow) it has attributes for some infos and still suports the old indexed access

     
  • Chris Liechti

    Chris Liechti - 2015-09-22
    • status: open --> pending
    • assigned_to: Chris Liechti
    • Group: --> Next Release (example)
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.