From a8260c83d6566fc46832c627ae32c996cfb76ea4 Mon Sep 17 00:00:00 2001 From: Yi Li Date: Wed, 16 Mar 2016 14:37:57 +0800 Subject: [PATCH] skeleton: Add dbus objects for adm1278 hwmon sensors Add dbus object for adm1278 Vout and Iout sensors. Add the sense resistor as scaling factor in skeleton. The sense resistor value is used while converting adm1278 'current' and 'power' register value to real world value. The adm1278 driver does the conversion, but without taking into account of the sense resistor. The resistor value need to be set according to Barreleye design. Signed-off-by: Yi Li --- bin/Barreleye.py | 22 ++++++++++++++++++++++ bin/Sensors.py | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/bin/Barreleye.py b/bin/Barreleye.py index 09fefa01..27698002 100755 --- a/bin/Barreleye.py +++ b/bin/Barreleye.py @@ -717,5 +717,27 @@ def convertGpio(name): '101' : { 'object_path' : 'temperature/membuf7','poll_interval' : 5000,'scale' : 1000,'units' : 'C' }, } }, + '4-0010' : { + 'names' : { + # Barreleye uses 0.25 millioohms sense resistor for adm1278 + # To convert Iout register value Y to real-world value X, use an equation: + # X= 1/m * (Y * 10^-R - b), here m = 800 * R_sense, and R_sense is expressed in milliohms. + # The adm1278 driver did the conversion, but the R_sense is set here as a scale factor. + 'curr1_input' : { 'object_path' : 'HSCA/Iout','poll_interval' : 5000,'scale' : 0.25,'units' : 'mA' }, + 'in2_input' : { 'object_path' : 'HSCA/Vout','poll_interval' : 5000,'scale' : 1,'units' : 'mV' }, + } + }, + '5-0010' : { + 'names' : { + 'curr1_input' : { 'object_path' : 'HSCB/Iout','poll_interval' : 5000,'scale' : 0.25,'units' : 'mA' }, + 'in2_input' : { 'object_path' : 'HSCB/Vout','poll_interval' : 5000,'scale' : 1,'units' : 'mV' }, + } + }, + '6-0010' : { + 'names' : { + 'curr1_input' : { 'object_path' : 'HSCC/Iout','poll_interval' : 5000,'scale' : 0.25,'units' : 'mA' }, + 'in2_input' : { 'object_path' : 'HSCC/Vout','poll_interval' : 5000,'scale' : 1,'units' : 'mV' }, + } + }, } diff --git a/bin/Sensors.py b/bin/Sensors.py index f951eeba..06e0b5f2 100755 --- a/bin/Sensors.py +++ b/bin/Sensors.py @@ -124,7 +124,8 @@ def setByPoll(self,value): val = (self.properties[SensorValue.IFACE_NAME]['value']-offset) * scale return [True,val] else: - val = (value/scale) + offset + # Keep the val as integer. scale may be floating point + val = int(value/scale + offset) if (val != self.value): SensorValue.setValue(self,val) self.check_thresholds(val)