Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/telemetry/third_party/pyserial/serial/tools/list_ports_linux.py

Issue 325663002: [PowerProfiler] pySerial module serial.tools.list_ports for linux should include the product inform… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing! Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/telemetry/third_party/pyserial/linux-product_info.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # portable serial port access with python 3 # portable serial port access with python
4 # 4 #
5 # This is a module that gathers a list of serial ports including details on 5 # This is a module that gathers a list of serial ports including details on
6 # GNU/Linux systems 6 # GNU/Linux systems
7 # 7 #
8 # (C) 2011-2013 Chris Liechti <cliechti@gmx.net> 8 # (C) 2011-2013 Chris Liechti <cliechti@gmx.net>
9 # this is distributed under a free software license, see license.txt 9 # this is distributed under a free software license, see license.txt
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 base = os.path.basename(device) 103 base = os.path.basename(device)
104 # USB-Serial devices 104 # USB-Serial devices
105 sys_dev_path = '/sys/class/tty/%s/device/driver/%s' % (base, base) 105 sys_dev_path = '/sys/class/tty/%s/device/driver/%s' % (base, base)
106 if os.path.exists(sys_dev_path): 106 if os.path.exists(sys_dev_path):
107 sys_usb = os.path.dirname(os.path.dirname(os.path.realpath(sys_dev_path) )) 107 sys_usb = os.path.dirname(os.path.dirname(os.path.realpath(sys_dev_path) ))
108 return usb_lsusb_string(sys_usb) 108 return usb_lsusb_string(sys_usb)
109 # USB-CDC devices 109 # USB-CDC devices
110 sys_dev_path = '/sys/class/tty/%s/device/interface' % (base,) 110 sys_dev_path = '/sys/class/tty/%s/device/interface' % (base,)
111 if os.path.exists(sys_dev_path): 111 if os.path.exists(sys_dev_path):
112 return read_line(sys_dev_path) 112 return read_line(sys_dev_path)
113
114 # USB Product Information
115 sys_dev_path = '/sys/class/tty/%s/device' % (base,)
116 if os.path.exists(sys_dev_path):
117 product_name_file = os.path.dirname(os.path.realpath(sys_dev_path)) + "/ product"
118 if os.path.exists(product_name_file):
119 return read_line(product_name_file)
120
113 return base 121 return base
114 122
115 def hwinfo(device): 123 def hwinfo(device):
116 """Try to get a HW identification using sysfs""" 124 """Try to get a HW identification using sysfs"""
117 base = os.path.basename(device) 125 base = os.path.basename(device)
118 if os.path.exists('/sys/class/tty/%s/device' % (base,)): 126 if os.path.exists('/sys/class/tty/%s/device' % (base,)):
119 # PCI based devices 127 # PCI based devices
120 sys_id_path = '/sys/class/tty/%s/device/id' % (base,) 128 sys_id_path = '/sys/class/tty/%s/device/id' % (base,)
121 if os.path.exists(sys_id_path): 129 if os.path.exists(sys_id_path):
122 return read_line(sys_id_path) 130 return read_line(sys_id_path)
(...skipping 11 matching lines...) Expand all
134 142
135 def comports(): 143 def comports():
136 devices = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/ dev/ttyACM*') 144 devices = glob.glob('/dev/ttyS*') + glob.glob('/dev/ttyUSB*') + glob.glob('/ dev/ttyACM*')
137 return [(d, describe(d), hwinfo(d)) for d in devices] 145 return [(d, describe(d), hwinfo(d)) for d in devices]
138 146
139 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 147 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
140 # test 148 # test
141 if __name__ == '__main__': 149 if __name__ == '__main__':
142 for port, desc, hwid in sorted(comports()): 150 for port, desc, hwid in sorted(comports()):
143 print "%s: %s [%s]" % (port, desc, hwid) 151 print "%s: %s [%s]" % (port, desc, hwid)
OLDNEW
« no previous file with comments | « tools/telemetry/third_party/pyserial/linux-product_info.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698