aboutsummaryrefslogtreecommitdiffstats
path: root/mpm
diff options
context:
space:
mode:
authorTrung Tran <trung.tran@ettus.com>2017-12-21 18:22:37 -0800
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:06:11 -0800
commit0db52a520bea056311c80a3e1eb7361ac9aa2b8e (patch)
treea189c4be7a58ebb4f5af05592431b548ea7f5e4d /mpm
parentaf0fe0f8dc7a8446d826364c3fc01791946497e5 (diff)
downloaduhd-0db52a520bea056311c80a3e1eb7361ac9aa2b8e.tar.gz
uhd-0db52a520bea056311c80a3e1eb7361ac9aa2b8e.tar.bz2
uhd-0db52a520bea056311c80a3e1eb7361ac9aa2b8e.zip
mpm: Add sysfs_thermal module
This will provide an API call to read thermal values via udev.
Diffstat (limited to 'mpm')
-rw-r--r--mpm/python/usrp_mpm/sys_utils/CMakeLists.txt1
-rw-r--r--mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py26
2 files changed, 27 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/sys_utils/CMakeLists.txt b/mpm/python/usrp_mpm/sys_utils/CMakeLists.txt
index 1b5a4ed0e..bb91418ac 100644
--- a/mpm/python/usrp_mpm/sys_utils/CMakeLists.txt
+++ b/mpm/python/usrp_mpm/sys_utils/CMakeLists.txt
@@ -10,6 +10,7 @@ SET(USRP_MPM_SYSUTILS_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dtoverlay.py
${CMAKE_CURRENT_SOURCE_DIR}/net.py
${CMAKE_CURRENT_SOURCE_DIR}/sysfs_gpio.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/sysfs_thermal.py
${CMAKE_CURRENT_SOURCE_DIR}/udev.py
${CMAKE_CURRENT_SOURCE_DIR}/uio.py
)
diff --git a/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py b/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py
new file mode 100644
index 000000000..8b1098469
--- /dev/null
+++ b/mpm/python/usrp_mpm/sys_utils/sysfs_thermal.py
@@ -0,0 +1,26 @@
+#
+# Copyright 2017 Ettus Research, A National Instruments Company
+#
+# SPDX-License-Identifier: GPL-3.0
+"""
+sysfs thermal sensors API
+"""
+
+import pyudev
+
+def read_thermal_sensor_value(sensor_type, data_probe):
+ """
+ This function will return the float value of the thermal sensor
+ which is under thermal subsystem.
+
+ Arguments:
+ sensor_type -- Is attribute "type" of udev. This can be fpga-thermal-zone,
+ magnesium-db0-zone, 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[0]