Chromium Code Reviews| Index: common/battor/battor/battor_wrapper.py |
| diff --git a/common/battor/battor/battor_wrapper.py b/common/battor/battor/battor_wrapper.py |
| index e2966eb3c54e52e0232890b8d93dc03255580f7a..d2ca5c23ebb2cfbf27fd9e411d8164ad3df027cd 100644 |
| --- a/common/battor/battor/battor_wrapper.py |
| +++ b/common/battor/battor/battor_wrapper.py |
| @@ -14,6 +14,15 @@ import dependency_manager |
| from devil.utils import battor_device_mapping |
| from devil.utils import find_usb_devices |
| +sys.path.append( |
|
nednguyen
2016/04/26 03:47:14
sys.path.insert(1, ...)
It's using some serial li
|
| + os.path.join(os.path.dirname(__file__), '..', '..', '..', 'telemetry', |
| + 'third_party', 'pyserial')) |
| +try: |
| + import serial |
| + from serial.tools import list_ports |
| +except: |
| + print serial.__file__ |
| + raise |
| class BattorWrapper(object): |
| """A class for communicating with a BattOr in python.""" |
| @@ -128,9 +137,11 @@ class BattorWrapper(object): |
| raise battor_error.BattorError( |
| '%s is an unsupported platform.' % target_platform) |
| if target_platform in ['win']: |
| - # TODO: We need a way to automatically detect correct port. |
| - # crbug.com/60397 |
| - return 'COM3' |
| + for (port, desc, _) in serial.tools.list_ports.comports(): |
| + if 'USB Serial Port' in desc: |
| + return port |
| + raise battor_error.BattorError( |
| + 'Could not find BattOr attached to machine.') |
| device_tree = find_usb_devices.GetBusNumberToDeviceTreeMap(fast=True) |
| if battor_path: |
| if not isinstance(battor_path, basestring): |