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

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

Issue 1013943002: Add SetStartupCurrent to monsoon profiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | no next file » | 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return status 149 return status
150 150
151 151
152 def SetVoltage(self, v): 152 def SetVoltage(self, v):
153 """Set the output voltage, 0 to disable.""" 153 """Set the output voltage, 0 to disable."""
154 if v == 0: 154 if v == 0:
155 self._SendStruct('BBB', 0x01, 0x01, 0x00) 155 self._SendStruct('BBB', 0x01, 0x01, 0x00)
156 else: 156 else:
157 self._SendStruct('BBB', 0x01, 0x01, int((v - 2.0) * 100)) 157 self._SendStruct('BBB', 0x01, 0x01, int((v - 2.0) * 100))
158 158
159 def SetStartupCurrent(self, i):
160 """Set the max startup output current."""
tonyg 2015/03/17 13:58:28 It'd be nice if this explain the units of |i| -- m
JungJik 2015/03/18 10:21:28 Done.
161 assert i >= 0 and i <= 8
162
163 val = 1023 - int((i/8)*1023)
tonyg 2015/03/17 13:58:28 I don't think this does what you want.
JungJik 2015/03/18 10:21:28 PTAL again. it looks like confusing |i| as integer
164 self._SendStruct('BBB', 0x01, 0x08, val & 0xff)
165 self._SendStruct('BBB', 0x01, 0x09, val >> 8)
159 166
160 def SetMaxCurrent(self, i): 167 def SetMaxCurrent(self, i):
161 """Set the max output current.""" 168 """Set the max output current."""
162 assert i >= 0 and i <= 8 169 assert i >= 0 and i <= 8
163 170
164 val = 1023 - int((i/8)*1023) 171 val = 1023 - int((i/8)*1023)
165 self._SendStruct('BBB', 0x01, 0x0a, val & 0xff) 172 self._SendStruct('BBB', 0x01, 0x0a, val & 0xff)
166 self._SendStruct('BBB', 0x01, 0x0b, val >> 8) 173 self._SendStruct('BBB', 0x01, 0x0b, val >> 8)
167 174
168 def SetUsbPassthrough(self, val): 175 def SetUsbPassthrough(self, val):
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 logging.error('exception from serial port') 286 logging.error('exception from serial port')
280 return None 287 return None
281 elif len(ready_r) > 0: 288 elif len(ready_r) > 0:
282 flushed += 1 289 flushed += 1
283 self.ser.read(1) # This may cause underlying buffering. 290 self.ser.read(1) # This may cause underlying buffering.
284 self.ser.flush() # Flush the underlying buffer too. 291 self.ser.flush() # Flush the underlying buffer too.
285 else: 292 else:
286 break 293 break
287 if flushed > 0: 294 if flushed > 0:
288 logging.debug('dropped >%d bytes', flushed) 295 logging.debug('dropped >%d bytes', flushed)
OLDNEW
« 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