Failure of set_safety_mode falls back to SILENT. Failure to set silent results in hanging
@@ -117,9 +117,16 @@ void EXTI3_IRQHandler(void) {
void set_safety_mode(uint16_t mode, int16_t param) {
int err = set_safety_hooks(mode, param);
if (err == -1) {
- puts("Error: safety set mode failed\n");
- while (true) {} // ERROR: we can't continue if safety mode isn't succesfully set
- } else {
+ puts("Error: safety set mode failed. Falling back to SILENT\n");
+ mode = SAFETY_SILENT;
+ err = set_safety_hooks(mode, 0);
+ if (err == -1) {
+ puts("Error: Failed setting SILENT mode. Hanging\n");
+ while (true) {
+ // TERMINAL ERROR: we can't continue if SILENT safety mode isn't succesfully set
+ }
+ }
+ }
switch (mode) {
case SAFETY_SILENT:
set_intercept_relay(false);
@@ -154,7 +161,6 @@ void set_safety_mode(uint16_t mode, int16_t param) {
}
can_init_all();
}
-}
// ***************************** USB port *****************************
