aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-12-21 18:30:26 -0800
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:06:11 -0800
commit29bff463b29f523f22aa1d4426eafa8d0e4a4706 (patch)
tree488e7e1fec2c85b137a62401f96d2bae622188a2
parent0db52a520bea056311c80a3e1eb7361ac9aa2b8e (diff)
downloaduhd-29bff463b29f523f22aa1d4426eafa8d0e4a4706.tar.gz
uhd-29bff463b29f523f22aa1d4426eafa8d0e4a4706.tar.bz2
uhd-29bff463b29f523f22aa1d4426eafa8d0e4a4706.zip
mpm: n310: Add temp and fan sensors
-rw-r--r--mpm/python/usrp_mpm/periph_manager/n310.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py
index 4a7997d75..33130dff9 100644
--- a/mpm/python/usrp_mpm/periph_manager/n310.py
+++ b/mpm/python/usrp_mpm/periph_manager/n310.py
@@ -22,6 +22,7 @@ from usrp_mpm.rpc_server import no_rpc
from usrp_mpm.sys_utils import dtoverlay
from usrp_mpm.sys_utils.sysfs_gpio import SysFSGPIO
from usrp_mpm.sys_utils.uio import UIO
+from usrp_mpm.sys_utils.sysfs_thermal import read_thermal_sensor_value
from usrp_mpm.xports import XportMgrUDP, XportMgrLiberio
N3XX_DEFAULT_EXT_CLOCK_FREQ = 10e6
@@ -250,6 +251,8 @@ class n310(PeriphManagerBase):
'gps_time': 'get_gps_time_sensor',
'gps_tpv': 'get_gps_tpv_sensor',
'gps_sky': 'get_gps_sky_sensor',
+ 'temp': 'get_temp_sensor',
+ 'fan': 'get_fan_sensor',
}
dboard_eeprom_addr = "e0004000.i2c"
dboard_eeprom_max_len = 64
@@ -658,6 +661,46 @@ class n310(PeriphManagerBase):
'value': str(lock_status).lower(),
}
+ def get_temp_sensor(self):
+ """
+ Get temperature sensor reading of the N3xx.
+ """
+ self.log.trace("Reading fpga temperature.")
+ return_val = '-1'
+ try:
+ raw_val = read_thermal_sensor_value('fpga-thermal-zone', 'temp')
+ return_val = str(raw_val/1000)
+ except ValueError:
+ self.log.warning("Error when converting temperature value")
+ except KeyError:
+ self.log.warning("Can't read temp on fpga-thermal-zone")
+ return {
+ 'name': 'temperature',
+ 'type': 'DOUBLE',
+ 'unit': 'C',
+ 'value': return_val
+ }
+
+ def get_fan_sensor(self):
+ """
+ Get cooling device reading of N3xx. In this case the speed of fan 0.
+ """
+ self.log.trace("Reading fpga cooling device.")
+ return_val = '-1'
+ try:
+ raw_val = read_thermal_sensor_value('ec-fan0', 'cur_state')
+ return_val = str(raw_val)
+ except ValueError:
+ self.log.warning("Error when converting fan speed value")
+ except KeyError:
+ self.log.warning("Can't read cur_state on ec-fan0")
+ return {
+ 'name': 'cooling fan',
+ 'type': 'INTEGER',
+ 'unit': 'rpm',
+ 'value': return_val
+ }
+
def get_gps_lock_sensor(self):
"""
Get lock status of GPS as a sensor dict