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

Side by Side Diff: tools/telemetry/telemetry/core/platform/profiler/monsoon.py

Issue 321773002: [PowerProfiler] Make sure correct version of pySerial is imported with monsoon profiler. (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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Interface for a USB-connected Monsoon power meter. 5 """Interface for a USB-connected Monsoon power meter.
6 6
7 http://msoon.com/LabEquipment/PowerMonitor/ 7 http://msoon.com/LabEquipment/PowerMonitor/
8 Currently Unix-only. Relies on fcntl, /dev, and /tmp. 8 Currently Unix-only. Relies on fcntl, /dev, and /tmp.
9 """ 9 """
10 10
11 import collections 11 import collections
12 import logging 12 import logging
13 import os 13 import os
14 import select 14 import select
15 import struct 15 import struct
16 import time 16 import time
17 17
18 from telemetry.core import util 18 from telemetry.core import util
19 19
20 util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'pyserial') 20 util.InsertDirInPythonPath(0, util.GetTelemetryDir(), 'third_party', 'pyserial')
21 import serial # pylint: disable=F0401 21 import serial # pylint: disable=F0401
22 22
23 23
24 Power = collections.namedtuple('Power', ['amps', 'volts']) 24 Power = collections.namedtuple('Power', ['amps', 'volts'])
25 25
26 26
27 class Monsoon: 27 class Monsoon:
28 """Provides a simple class to use the power meter. 28 """Provides a simple class to use the power meter.
29 29
30 mon = monsoon.Monsoon() 30 mon = monsoon.Monsoon()
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 logging.error('exception from serial port') 276 logging.error('exception from serial port')
277 return None 277 return None
278 elif len(ready_r) > 0: 278 elif len(ready_r) > 0:
279 flushed += 1 279 flushed += 1
280 self.ser.read(1) # This may cause underlying buffering. 280 self.ser.read(1) # This may cause underlying buffering.
281 self.ser.flush() # Flush the underlying buffer too. 281 self.ser.flush() # Flush the underlying buffer too.
282 else: 282 else:
283 break 283 break
284 if flushed > 0: 284 if flushed > 0:
285 logging.debug('dropped >%d bytes', flushed) 285 logging.debug('dropped >%d bytes', flushed)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698