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

Unified Diff: tools/telemetry/telemetry/core/platform/profiler/monsoon.py

Issue 323853002: [PowerProfiler] Make monsoon profiler work on other platforms - windows & mac, apart from linu… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/profiler/monsoon.py
diff --git a/tools/telemetry/telemetry/core/platform/profiler/monsoon.py b/tools/telemetry/telemetry/core/platform/profiler/monsoon.py
index 21cb6d2fe7727f2e3c5067034f2f65ff108410b2..0b5ce1001431b71157577c5a04d30e82921cea2e 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/monsoon.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/monsoon.py
@@ -19,6 +19,7 @@ from telemetry.core import util
util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'pyserial')
import serial # pylint: disable=F0401
+import serial.tools.list_ports
Power = collections.namedtuple('Power', ['amps', 'volts'])
@@ -54,11 +55,12 @@ class Monsoon:
self.ser = serial.Serial(device, timeout=1)
return
- while 1: # Try all /dev/ttyACM* until we find one we can use.
- for dev in os.listdir('/dev'):
- if not dev.startswith('ttyACM'):
+ while 1:
+ devices = serial.tools.list_ports.comports()
+ for dev in devices:
tonyg 2014/06/09 16:51:56 This loop'd be a lot more readable as for port, d
+ if not dev[1].lower().startswith('mobile device power monitor'):
continue
- tmpname = '/tmp/monsoon.%s.%s' % (os.uname()[0], dev)
+ tmpname = '/tmp/monsoon.%s.%s' % (os.uname()[0], os.path.basename(dev[0]))
tonyg 2014/06/09 16:51:57 nit: please hold line length to 80 cols. http://g
self._tempfile = open(tmpname, 'w')
try: # Use a lockfile to ensure exclusive access.
# Put the import in here to avoid doing it on unsupported platforms.
@@ -69,7 +71,7 @@ class Monsoon:
continue
try: # Try to open the device.
- self.ser = serial.Serial('/dev/%s' % dev, timeout=1)
+ self.ser = serial.Serial(dev[0], timeout=1)
self.StopDataCollection() # Just in case.
self._FlushInput() # Discard stale input.
status = self.GetStatus()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698