Updated pwr flag names, Fixed pwr flag var
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Fri, 16 Feb 2018 06:02:42 +0000 (22:02 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Fri, 16 Feb 2018 06:02:42 +0000 (22:02 -0800)
src/jade/templates/indicators.jade
src/pwr/config.h
src/pwr/main.c
src/py/bbctrl/Pwr.py

index b9a330af2d37bef0450e0010e0665fdd9f274423..cdab3a92ec02d1f3017be62932c38c8e14094c62 100644 (file)
@@ -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
index 65433d0ba42c314cbd6236deefcc144fc70df820..854ef38aaece3b8a89b7b7638469e4567e275208 100644 (file)
@@ -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,
 };
 
 
index 8cab8d274f10f73cec69501ed6787ad5df596954..c5b1113ab634c34cfa6f59b1c2f3b262b29122b9 100644 (file)
@@ -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);
index 96bf60a8a56a1bdb06e6401003968de44f942d30..337c85f902150037c741b8726e55dc1836ab48d2 100644 (file)
@@ -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')