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: Patch for landing! 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
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/util.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 26 matching lines...) Expand all
37 """ 37 """
38 38
39 def __init__(self, device=None, serialno=None, wait=True): 39 def __init__(self, device=None, serialno=None, wait=True):
40 """Establish a connection to a Monsoon. 40 """Establish a connection to a Monsoon.
41 41
42 By default, opens the first available port, waiting if none are ready. 42 By default, opens the first available port, waiting if none are ready.
43 A particular port can be specified with 'device', or a particular Monsoon 43 A particular port can be specified with 'device', or a particular Monsoon
44 can be specified with 'serialno' (using the number printed on its back). 44 can be specified with 'serialno' (using the number printed on its back).
45 With wait=False, IOError is thrown if a device is not immediately available. 45 With wait=False, IOError is thrown if a device is not immediately available.
46 """ 46 """
47 assert float(serial.VERSION) >= 2.7, \
48 'Monsoon requires pyserial v2.7 or later. You have %s' % serial.VERSION
47 49
48 self._coarse_ref = self._fine_ref = self._coarse_zero = self._fine_zero = 0 50 self._coarse_ref = self._fine_ref = self._coarse_zero = self._fine_zero = 0
49 self._coarse_scale = self._fine_scale = 0 51 self._coarse_scale = self._fine_scale = 0
50 self._last_seq = 0 52 self._last_seq = 0
51 self._voltage_multiplier = None 53 self._voltage_multiplier = None
52 54
53 if device: 55 if device:
54 self.ser = serial.Serial(device, timeout=1) 56 self.ser = serial.Serial(device, timeout=1)
55 return 57 return
56 58
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 logging.error('exception from serial port') 278 logging.error('exception from serial port')
277 return None 279 return None
278 elif len(ready_r) > 0: 280 elif len(ready_r) > 0:
279 flushed += 1 281 flushed += 1
280 self.ser.read(1) # This may cause underlying buffering. 282 self.ser.read(1) # This may cause underlying buffering.
281 self.ser.flush() # Flush the underlying buffer too. 283 self.ser.flush() # Flush the underlying buffer too.
282 else: 284 else:
283 break 285 break
284 if flushed > 0: 286 if flushed > 0:
285 logging.debug('dropped >%d bytes', flushed) 287 logging.debug('dropped >%d bytes', flushed)
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698