OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import logging | 5 import logging |
6 | 6 |
7 class ThermalThrottle(object): | 7 class ThermalThrottle(object): |
8 """Class to detect and track thermal throttling | 8 """Class to detect and track thermal throttling |
9 | 9 |
10 Usage: | 10 Usage: |
(...skipping 14 matching lines...) Expand all Loading... | |
25 """ | 25 """ |
26 return self._ReadLog() | 26 return self._ReadLog() |
27 | 27 |
28 def IsThrottled(self): | 28 def IsThrottled(self): |
29 """True if currently throttled""" | 29 """True if currently throttled""" |
30 self._ReadLog() | 30 self._ReadLog() |
31 return self._throttled | 31 return self._throttled |
32 | 32 |
33 def _ReadLog(self): | 33 def _ReadLog(self): |
34 has_been_throttled = False | 34 has_been_throttled = False |
35 serial_number = self._adb.Adb().GetSerialNumber() | |
35 log = self._adb.RunShellCommand('dmesg -c') | 36 log = self._adb.RunShellCommand('dmesg -c') |
36 for line in log: | 37 for line in log: |
37 if 'omap_thermal_throttle' in line: | 38 if 'omap_thermal_throttle' in line: |
38 if not self._throttled: | 39 if not self._throttled: |
39 logging.warning('>>> Thermally Throttled') | 40 logging.warning('>>> Device %s Thermally Throttled', serial_number) |
40 self._throttled = True | 41 self._throttled = True |
41 has_been_throttled = True | 42 has_been_throttled = True |
42 if 'omap_thermal_unthrottle' in line: | 43 if 'omap_thermal_unthrottle' in line: |
43 if self._throttled: | 44 if self._throttled: |
44 logging.warning('>>> Thermally Unthrottled') | 45 logging.warning('>>> Device %s Thermally Unthrottled', serial_number) |
45 self._throttled = False | 46 self._throttled = False |
46 has_been_throttled = True | 47 has_been_throttled = True |
48 if 'throttle_delayed_work_fn' in line: | |
49 temp = float([s for s in line.split() if s.isdigit()][0])/1000.0 | |
bulach
2012/12/11 13:30:14
nit: spaces around /
It's not quite clear the [0]
aberent
2012/12/11 14:03:05
Spacing done. The list expression splits the line
| |
50 # \u00B0 is the degree symbol | |
bulach
2012/12/11 13:30:14
nit: it'd be clearer and avoid the comment to have
aberent
2012/12/11 14:03:05
Done.
| |
51 logging.info(u' Device %s Thermally Thottled at %3.1f\u00B0C', | |
52 serial_number, temp) | |
53 | |
54 # Print temperature of CPU SoC. | |
55 omap_temp_file = '/sys/devices/platform/omap/omap_temp_sensor.0/temperature' | |
56 if self._adb.FileExistsOnDevice(omap_temp_file): | |
57 tempdata = self._adb.GetFileContents(omap_temp_file) | |
58 temp = float(tempdata[0])/1000.0 | |
bulach
2012/12/11 13:30:14
nit: spaces around /
aberent
2012/12/11 14:03:05
Done.
| |
59 logging.info(u'Current OMAP Temperature of %s = %3.1f\u00B0C', | |
60 serial_number, temp) | |
61 | |
62 # Print temperature of battery, to give a system temperature | |
63 dumpsys_log = self._adb.RunShellCommand('dumpsys battery') | |
64 for line in dumpsys_log: | |
65 if 'temperature' in line: | |
66 btemp = float([s for s in line.split() if s.isdigit()][0])/10.0 | |
bulach
2012/12/11 13:30:14
nit: same for [0] here..
aberent
2012/12/11 14:03:05
As above
On 2012/12/11 13:30:14, bulach wrote:
| |
67 logging.info(u'Current battery temperature of %s = %3.1f\u00B0C', | |
68 serial_number, btemp) | |
bulach
2012/12/11 13:30:14
nit: serial should be aligned with parens..
aberent
2012/12/11 14:03:05
Done.
| |
69 | |
47 return has_been_throttled | 70 return has_been_throttled |
OLD | NEW |