From a8afaf17e0b99e004a14e36806fc1cff139ee1f5 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Thu, 15 Feb 2018 22:02:42 -0800 Subject: [PATCH] Updated pwr flag names, Fixed pwr flag var --- src/jade/templates/indicators.jade | 12 ++++++------ src/pwr/config.h | 16 ++++++++-------- src/pwr/main.c | 6 +++--- src/py/bbctrl/Pwr.py | 27 +++++++++++++-------------- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/jade/templates/indicators.jade b/src/jade/templates/indicators.jade index b9a330a..cdab3a9 100644 --- a/src/jade/templates/indicators.jade +++ b/src/jade/templates/indicators.jade @@ -120,8 +120,8 @@ script#indicators-template(type="text/x-template") th Over current td {{state['over_current'] ? 'True' : 'False'}} th.separator - th Measurement error - td {{state['measurement_error'] ? 'True' : 'False'}} + th Sense error + td {{state['sense_error'] ? 'True' : 'False'}} tr th Shunt overload td {{state['shunt_overload'] ? 'True' : 'False'}} @@ -129,11 +129,11 @@ script#indicators-template(type="text/x-template") th Motor overload td {{state['motor_overload'] ? 'True' : 'False'}} tr - th Load 1 over temp - td {{state['load1_overtemp'] ? 'True' : 'False'}} + th Load 1 shutdown + td {{state['load1_shutdown'] ? 'True' : 'False'}} th.separator - th Load 2 over temp - td {{state['load2_overtemp'] ? 'True' : 'False'}} + th Load 2 shutdown + td {{state['load2_shutdown'] ? 'True' : 'False'}} table.measurements tr diff --git a/src/pwr/config.h b/src/pwr/config.h index 65433d0..854ef38 100644 --- a/src/pwr/config.h +++ b/src/pwr/config.h @@ -123,16 +123,16 @@ typedef enum { enum { - UNDER_VOLTAGE_FLAG = 1 << 0, - OVER_VOLTAGE_FLAG = 1 << 1, - OVER_CURRENT_FLAG = 1 << 2, - MEASUREMENT_ERROR_FLAG = 1 << 3, - SHUNT_OVERLOAD_FLAG = 1 << 4, - MOTOR_OVERLOAD_FLAG = 1 << 5, + UNDER_VOLTAGE_FLAG = 1 << 0, + OVER_VOLTAGE_FLAG = 1 << 1, + OVER_CURRENT_FLAG = 1 << 2, + SENSE_ERROR_FLAG = 1 << 3, + SHUNT_OVERLOAD_FLAG = 1 << 4, + MOTOR_OVERLOAD_FLAG = 1 << 5, // Non fatal - LOAD1_OVERTEMP_FLAG = 1 << 6, - LOAD2_OVERTEMP_FLAG = 1 << 7, + LOAD1_SHUTDOWN_FLAG = 1 << 6, + LOAD2_SHUTDOWN_FLAG = 1 << 7, }; diff --git a/src/pwr/main.c b/src/pwr/main.c index 8cab8d2..c5b1113 100644 --- a/src/pwr/main.c +++ b/src/pwr/main.c @@ -385,7 +385,7 @@ static void validate_measurements() { max_current < regs[LOAD1_REG] || max_current < regs[LOAD2_REG] || max_current < regs[VDD_REG]) - shutdown(MEASUREMENT_ERROR_FLAG); + shutdown(SENSE_ERROR_FLAG); } @@ -413,8 +413,8 @@ int main() { if (CURRENT_MAX < get_total_current()) flags |= OVER_CURRENT_FLAG; if (shunt_overload) flags |= SHUNT_OVERLOAD_FLAG; if (MOTOR_SHUTDOWN_THRESH <= motor_overload) flags |= MOTOR_OVERLOAD_FLAG; - if (loads[0].shutdown) flags |= LOAD1_OVERTEMP_FLAG; - if (loads[1].shutdown) flags |= LOAD2_OVERTEMP_FLAG; + if (loads[0].shutdown) flags |= LOAD1_SHUTDOWN_FLAG; + if (loads[1].shutdown) flags |= LOAD2_SHUTDOWN_FLAG; regs[FLAGS_REG] = flags; if (flags & FATAL_FLAG_MASK) shutdown(flags); diff --git a/src/py/bbctrl/Pwr.py b/src/py/bbctrl/Pwr.py index 96bf60a..337c85f 100644 --- a/src/py/bbctrl/Pwr.py +++ b/src/py/bbctrl/Pwr.py @@ -43,14 +43,14 @@ VDD_REG = 6 FLAGS_REG = 7 # Must be kept in sync with pwr firmware -UNDER_VOLTAGE_FLAG = 1 << 0 -OVER_VOLTAGE_FLAG = 1 << 1 -OVER_CURRENT_FLAG = 1 << 2 -MEASUREMENT_ERROR_FLAG = 1 << 3 -SHUNT_OVERLOAD_FLAG = 1 << 4 -MOTOR_OVERLOAD_FLAG = 1 << 5 -LOAD1_OVERTEMP_FLAG = 1 << 6 -LOAD2_OVERTEMP_FLAG = 1 << 7 +UNDER_VOLTAGE_FLAG = 1 << 0 +OVER_VOLTAGE_FLAG = 1 << 1 +OVER_CURRENT_FLAG = 1 << 2 +SENSE_ERROR_FLAG = 1 << 3 +SHUNT_OVERLOAD_FLAG = 1 << 4 +MOTOR_OVERLOAD_FLAG = 1 << 5 +LOAD1_SHUTDOWN_FLAG = 1 << 6 +LOAD2_SHUTDOWN_FLAG = 1 << 7 reg_names = 'temp vin vout motor load1 load2 vdd pwr_flags'.split() @@ -72,7 +72,7 @@ class Pwr(): def check_fault(self, var, status): status = bool(status) - if status != self.ctrl.state.get(var, False): + if not self.ctrl.state.has(var) or status != self.ctrl.state.get(var): self.ctrl.state.set(var, status) if status: return True @@ -91,9 +91,8 @@ class Pwr(): if self.check_fault('over_current', flags & OVER_CURRENT_FLAG): log.error('Device total current limit exceeded') - if self.check_fault('measurement_error', - flags & MEASUREMENT_ERROR_FLAG): - log.error('Power measurement error') + if self.check_fault('sense_error', flags & SENSE_ERROR_FLAG): + log.error('Power sense error') if self.check_fault('shunt_overload', flags & SHUNT_OVERLOAD_FLAG): log.error('Power shunt overload') @@ -101,10 +100,10 @@ class Pwr(): if self.check_fault('motor_overload', flags & MOTOR_OVERLOAD_FLAG): log.error('Motor power overload') - if self.check_fault('load1_overtemp', flags & LOAD1_OVERTEMP_FLAG): + if self.check_fault('load1_shutdown', flags & LOAD1_SHUTDOWN_FLAG): log.error('Load 1 over temperature shutdown') - if self.check_fault('load2_overtemp', flags & LOAD2_OVERTEMP_FLAG): + if self.check_fault('load2_shutdown', flags & LOAD2_SHUTDOWN_FLAG): log.error('Load 2 over temperature shutdown') -- 2.27.0