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

Unified Diff: common/battor/battor/battor_wrapper.py

Issue 1920023002: [BattOr] Add real device smoke test (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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..483dc9ee1d6dcea197c5fb8bc8d8cfd00b6688b3 100644
--- a/common/battor/battor/battor_wrapper.py
+++ b/common/battor/battor/battor_wrapper.py
@@ -14,6 +14,11 @@ import dependency_manager
from devil.utils import battor_device_mapping
from devil.utils import find_usb_devices
+sys.path.insert(
charliea (OOO until 10-5) 2016/04/29 15:11:07 I think that this should be added here: https://c
rnephew (Reviews Here) 2016/04/29 17:05:57 Will that work, this being part of common? Or do y
charliea (OOO until 10-5) 2016/04/29 17:18:17 Uhhh... sure, let's pretend like I was smart enoug
+ 1, os.path.join(os.path.dirname(__file__), '..', '..', '..', 'telemetry',
+ 'third_party', 'pyserial'))
+import serial
+from serial.tools import list_ports
class BattorWrapper(object):
"""A class for communicating with a BattOr in python."""
@@ -128,9 +133,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:
charliea (OOO until 10-5) 2016/04/29 15:11:07 Can you add a comment describing why this is neces
rnephew (Reviews Here) 2016/04/29 17:05:57 Done.
+ 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):

Powered by Google App Engine
This is Rietveld 408576698