Exemplo n.º 1
0
    def setUp(self):
        print "setUp - start"
        GaiaTestCase.setUp(self)

        print "setUp - about to lock"
        # Make sure the lock screen is up
        self.device.lock()

        # Make sure the screen brightness is full on, with auto turned off
        # Volume level adjust to 9 and turn on airplane mode
        self.data_layer.set_setting("screen.automatic-brightness", False)
        self.data_layer.set_setting("screen.brightness", 1.0)
        self.data_layer.set_setting("audio.volume.content", 9)
        self.data_layer.set_setting("airplaneMode.enabled", True)

        # Make sure USB charging is turned off
        cmd = []
        cmd.append("adb")
        cmd.append("shell")
        cmd.append("echo 0 > /sys/class/power_supply/battery/charging_enabled")
        subprocess.Popen(cmd)

        # Set up the ammeter
        self.ammeterFields = ('current', 'voltage', 'time')
        serialPortName = None  #we want powertool to figure out the port...
        self.ammeter = MozillaAmmeter(serialPortName, False)

        # Grab a sample, and calculate the timer offset from ammeter time to wall clock time
        sample = self.ammeter.getSample(self.ammeterFields)
        sampleTimeAfterEpochOffset = time.time()
        firstSampleMsCounter = sample['time'].value
        self.sampleTimeEpochOffset = int(
            sampleTimeAfterEpochOffset * 1000.0) - firstSampleMsCounter

        print "setUp - done"
Exemplo n.º 2
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from powertool.mozilla import MozillaAmmeter
import time
import json



ammeterFields = ('current','voltage','time')
serialPortName = "/dev/ttyACM0"
ammeter = MozillaAmmeter(serialPortName, False)


sampleLog = []
stopTime = time.time() + 25
done = False
total = 0.0
count = 0
while not done:
    sample = ammeter.getSample(ammeterFields)
    if sample is not None:
        sampleObj = {}
        sampleObj['current'] = sample['current'].value
        sampleObj['voltage'] = sample['voltage'].value
        sampleObj['time'] = sample['time'].value
        sampleLog.append(sampleObj)
        total = total + sampleObj['current']
        count = count + 1
        if count % 1000 == 0: