Commit 0016f807 authored by tonyg@chromium.org's avatar tonyg@chromium.org

[Telemetry] Allow the Monsoon to power the device under test.

The monsoon provides power for the device, so for devices with no
real battery, we need a chance to turn them on after the monsoon
enables voltage output to the device.

BUG=

Review URL: https://codereview.chromium.org/400863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285005 0039d316-1c4b-4281-b951-d872f2087c98
parent de212233
...@@ -18,6 +18,7 @@ from telemetry.core import util ...@@ -18,6 +18,7 @@ from telemetry.core import util
from telemetry.core.backends import adb_commands from telemetry.core.backends import adb_commands
from telemetry.core.backends.chrome import android_browser_backend from telemetry.core.backends.chrome import android_browser_backend
from telemetry.core.platform import android_platform_backend from telemetry.core.platform import android_platform_backend
from telemetry.core.platform.profiler import monsoon
CHROME_PACKAGE_NAMES = { CHROME_PACKAGE_NAMES = {
...@@ -176,6 +177,7 @@ def CanFindAvailableBrowsers(logging=real_logging): ...@@ -176,6 +177,7 @@ def CanFindAvailableBrowsers(logging=real_logging):
adb_works = False adb_works = False
return adb_works return adb_works
def FindAllAvailableBrowsers(finder_options, logging=real_logging): def FindAllAvailableBrowsers(finder_options, logging=real_logging):
"""Finds all the desktop browsers available on this machine.""" """Finds all the desktop browsers available on this machine."""
if not CanFindAvailableBrowsers(logging=logging): if not CanFindAvailableBrowsers(logging=logging):
...@@ -183,15 +185,38 @@ def FindAllAvailableBrowsers(finder_options, logging=real_logging): ...@@ -183,15 +185,38 @@ def FindAllAvailableBrowsers(finder_options, logging=real_logging):
'Will not try searching for Android browsers.') 'Will not try searching for Android browsers.')
return [] return []
device = None def _GetDevices():
if finder_options.android_device: if finder_options.android_device:
devices = [finder_options.android_device] return [finder_options.android_device]
else: else:
devices = adb_commands.GetAttachedDevices() return adb_commands.GetAttachedDevices()
if len(devices) == 0: devices = _GetDevices()
logging.info('No android devices found.')
return [] if not devices:
try:
m = monsoon.Monsoon(wait=False)
m.SetUsbPassthrough(1)
m.SetVoltage(3.8)
m.SetMaxCurrent(8)
logging.warn("""
Monsoon power monitor detected, but no Android devices.
The Monsoon's power output has been enabled. Please now ensure that:
1. The Monsoon's front and back USB are connected to the host.
2. The Device is connected to the Monsoon's main and USB channels.
3. The Device is turned on.
Waiting for device...
""")
util.WaitFor(_GetDevices, 600)
devices = _GetDevices()
if not devices:
raise IOError()
except IOError:
logging.info('No android devices found.')
return []
if len(devices) > 1: if len(devices) > 1:
logging.warn( logging.warn(
......
...@@ -103,15 +103,16 @@ class MonsoonPowerMonitor(power_monitor.PowerMonitor): ...@@ -103,15 +103,16 @@ class MonsoonPowerMonitor(power_monitor.PowerMonitor):
""" """
power_samples = [] power_samples = []
total_energy_consumption_mwh = 0 total_energy_consumption_mwh = 0
result = json.loads(powermonitor_output) result = json.loads(powermonitor_output)
timedelta_h = result['duration_s'] / len(result['samples']) / 3600 if result['samples']:
for (current_a, voltage_v) in result['samples']: timedelta_h = result['duration_s'] / len(result['samples']) / 3600
energy_consumption_mw = current_a * voltage_v * 10**3 for (current_a, voltage_v) in result['samples']:
total_energy_consumption_mwh += energy_consumption_mw * timedelta_h energy_consumption_mw = current_a * voltage_v * 10**3
power_samples.append(energy_consumption_mw) total_energy_consumption_mwh += energy_consumption_mw * timedelta_h
# -------- Collect and Process Data ------------- power_samples.append(energy_consumption_mw)
out_dict = {} out_dict = {}
# Raw power usage samples.
out_dict['identifier'] = 'monsoon' out_dict['identifier'] = 'monsoon'
out_dict['power_samples_mw'] = power_samples out_dict['power_samples_mw'] = power_samples
out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh out_dict['energy_consumption_mwh'] = total_energy_consumption_mwh
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment