diff options
author | Sugandha Gupta <sugandha.gupta@ettus.com> | 2018-08-03 16:23:55 -0700 |
---|---|---|
committer | Brent Stapleton <bstapleton@g.hmc.edu> | 2018-08-09 17:39:14 -0700 |
commit | 2c91648c7f8f21e1d2e528e2c0a8bd28a1c89d7d (patch) | |
tree | 86765e59891a004cad712b4dcbbe45886b6e2c01 /mpm/python/usrp_mpm | |
parent | 79cad066ab849bdb773f1716c54acf61e601f0e8 (diff) | |
download | uhd-2c91648c7f8f21e1d2e528e2c0a8bd28a1c89d7d.tar.gz uhd-2c91648c7f8f21e1d2e528e2c0a8bd28a1c89d7d.tar.bz2 uhd-2c91648c7f8f21e1d2e528e2c0a8bd28a1c89d7d.zip |
mpm: sys_utils: Get list of temperatures from all thermal zones
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py b/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py index a5df76858..7409fbe17 100644 --- a/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py +++ b/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py @@ -8,6 +8,23 @@ sysfs thermal sensors API import pyudev +def read_thermal_sensors_value(sensor_type, data_probe): + """ + This function will return a list of all the float value of + the thermal sensor subsystem = 'thermal' and type = sensor_type + + Arguments: + sensor_type -- Is attribute "type" of udev. This can be fpga-thermal-zone, + magnesium-db0-zone, croc-ec-thermal etc. + data_probe -- is one of the attribute of that sensor. This can be 'temp' in + the case of thermal-zone or 'cur_state' in the case of a + cooling device. + """ + reading_sensors = [x.attributes.asint(data_probe) for x in pyudev.Context() + .list_devices(subsystem='thermal') + .match_attribute('type', sensor_type)] + return reading_sensors + def read_thermal_sensor_value(sensor_type, data_probe): """ This function will return the float value of the thermal sensor @@ -20,7 +37,7 @@ def read_thermal_sensor_value(sensor_type, data_probe): the case of thermal-zone or 'cur_state' in the case of a cooling device. """ - reading_sensors = [x.attributes.asint(data_probe) for x in pyudev.Context() - .list_devices(subsystem='thermal') - .match_attribute('type', sensor_type)] - return reading_sensors[0] + sensor_val = read_thermal_sensors_value(sensor_type, data_probe) + if not sensor_val: + raise IndexError("No {} attribute found for {} sensor.".format(data_probe, sensor_type)) + return sensor_val[0] |