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

Side by Side Diff: build/android/pylib/thermal_throttle.py

Issue 11499010: Print OMAP temperature data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: OMAP temperature data - code review response Created 8 years 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 (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
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
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