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

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..24417fb9b2d4bb88d77a19612a49a1c187c8b14d 100644
--- a/common/battor/battor/battor_wrapper.py
+++ b/common/battor/battor/battor_wrapper.py
@@ -14,6 +14,8 @@ import dependency_manager
from devil.utils import battor_device_mapping
from devil.utils import find_usb_devices
+import serial
+from serial.tools import list_ports
class BattorWrapper(object):
"""A class for communicating with a BattOr in python."""
@@ -128,9 +130,15 @@ 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'
+ # Right now, the BattOr agent binary isn't able to automatically detect
+ # the BattOr port on Windows. To get around this, we know that the BattOr
+ # shows up with a name of 'USB Serial Port', so use the COM port that
+ # corresponds to a device with that name.
+ 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):
« no previous file with comments | « common/battor/battor/battor_binary_dependencies.json ('k') | common/battor/battor/battor_wrapper_devicetest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698