OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 ''' | 7 ''' |
8 This script provides tools to map BattOrs to phones. | 8 This script provides tools to map BattOrs to phones. |
9 | 9 |
10 Phones are identified by the following string: | 10 Phones are identified by the following string: |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 Generates a dict of: | 153 Generates a dict of: |
154 {<phone serial 1>: <battor serial 1>, | 154 {<phone serial 1>: <battor serial 1>, |
155 <phone serial 2>: <battor serial 2>} | 155 <phone serial 2>: <battor serial 2>} |
156 indicating which phone serial numbers should be matched with | 156 indicating which phone serial numbers should be matched with |
157 which BattOr serial numbers. Mapping is based on the physical port numbers | 157 which BattOr serial numbers. Mapping is based on the physical port numbers |
158 of the hubs that the BattOrs and phones are connected to. | 158 of the hubs that the BattOrs and phones are connected to. |
159 | 159 |
160 Args: | 160 Args: |
161 hub_types: List of hub types to check for. | 161 hub_types: List of hub types to check for. |
162 Defaults to ['plugable_7port'] | 162 Defaults to ['plugable_7port', |
| 163 'plugable_7port_usb3_part2', |
| 164 'plugable_7port_usb3_part3'] |
| 165 (see usb_hubs.py for details) |
163 """ | 166 """ |
164 hub_types = [usb_hubs.GetHubType(x) | 167 hub_types = [usb_hubs.GetHubType(x) |
165 for x in hub_types or ['plugable_7port']] | 168 for x in hub_types or ['plugable_7port', |
| 169 'plugable_7port_usb3_part2', |
| 170 'plugable_7port_usb3_part3']] |
166 devtree = find_usb_devices.GetBusNumberToDeviceTreeMap() | 171 devtree = find_usb_devices.GetBusNumberToDeviceTreeMap() |
167 | 172 |
168 # List of serial numbers in the system that represent BattOrs. | 173 # List of serial numbers in the system that represent BattOrs. |
169 battor_serials = list(GetBattorSerialNumbers(devtree)) | 174 battor_serials = list(GetBattorSerialNumbers(devtree)) |
170 | 175 |
| 176 # If there's only one BattOr in the system, then a serial number ma |
| 177 # is not necessary. |
| 178 if len(battor_serials) == 1: |
| 179 return {} |
| 180 |
171 # List of dictionaries, one for each hub, that maps the physical | 181 # List of dictionaries, one for each hub, that maps the physical |
172 # port number to the serial number of that hub. For instance, in a 2 | 182 # port number to the serial number of that hub. For instance, in a 2 |
173 # hub system, this could return [{1:'ab', 2:'cd'}, {1:'jkl', 2:'xyz'}] | 183 # hub system, this could return [{1:'ab', 2:'cd'}, {1:'jkl', 2:'xyz'}] |
174 # where 'ab' and 'cd' are the phone serial numbers and 'jkl' and 'xyz' | 184 # where 'ab' and 'cd' are the phone serial numbers and 'jkl' and 'xyz' |
175 # are the BattOr serial numbers. | 185 # are the BattOr serial numbers. |
176 port_to_serial = find_usb_devices.GetAllPhysicalPortToSerialMaps( | 186 port_to_serial = find_usb_devices.GetAllPhysicalPortToSerialMaps( |
177 hub_types, device_tree_map=devtree) | 187 hub_types, device_tree_map=devtree) |
178 | 188 |
179 class serials(object): | 189 class serials(object): |
180 def __init__(self): | 190 def __init__(self): |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 299 |
290 if not tty_string: | 300 if not tty_string: |
291 raise battor_error.BattorError( | 301 raise battor_error.BattorError( |
292 'No device with given serial number detected.') | 302 'No device with given serial number detected.') |
293 | 303 |
294 if IsBattor(tty_string, devtree): | 304 if IsBattor(tty_string, devtree): |
295 return '/dev/' + tty_string | 305 return '/dev/' + tty_string |
296 else: | 306 else: |
297 raise battor_error.BattorError( | 307 raise battor_error.BattorError( |
298 'Device with given serial number is not a BattOr.') | 308 'Device with given serial number is not a BattOr.') |
OLD | NEW |