Menu

#32 Module list_ports for linux should include the product information as description.

v2.7
closed-accepted
None
3
2015-08-05
2014-06-20
vivekg
No

I work on chromium project and we have been using pyserial for our testing harness. Thank you for the wonderful library.

Currently I am working on making the testing harness seamless across various platforms. In doing so, I wrote a patch for list_ports. The patch can be found here [1]. Chromium side patch can be found here [2] with relevant contextual information.

I would like to upstream this patch to pyserial in general and then we will roll our version to the upstream version.

[1] http://paste.ubuntu.com/7621537/
[2] https://codereview.chromium.org/325663002/

=====RAW PATCH HERE=======

Index: list_ports_linux.py
===================================================================
--- list_ports_linux.py (revision 494)
+++ list_ports_linux.py (working copy)
@@ -110,6 +110,14 @@
     sys_dev_path = '/sys/class/tty/%s/device/interface' % (base,)
     if os.path.exists(sys_dev_path):
         return read_line(sys_dev_path)
+
+    # USB Product Information
+    sys_dev_path = '/sys/class/tty/%s/device' % (base,)
+    if os.path.exists(sys_dev_path):
+        product_name_file = os.path.dirname(os.path.realpath(sys_dev_path)) + "/product"
+        if os.path.exists(product_name_file):
+            return read_line(product_name_file)
+
     return base

 def hwinfo(device):

Discussion

  • Chris Liechti

    Chris Liechti - 2014-07-31
    • status: open --> pending-accepted
     
  • Chris Liechti

    Chris Liechti - 2014-07-31

    OK, committed. Though for, me it does not add information. The USB serial device catches the first return and the CDC device the second. When i comment out the second case, then the new code is run and returns the same information as the second case. So it certainly does not hurt and it may depend on the kernel version which case it takes.

     
  • Chris Liechti

    Chris Liechti - 2015-08-05
    • status: pending-accepted --> closed-accepted
     

Log in to post a comment.