From f80968559ee60d6bec28ad5cfbae547f7d140430 Mon Sep 17 00:00:00 2001 From: stevenhowes <38082088+stevenhowes@users.noreply.github.com> Date: Mon, 6 May 2019 18:01:30 +0100 Subject: [PATCH] Clean up of debug prints, and safer CAS handling --- ECU.ino | 2 +- battery.ino | 6 ------ cas.ino | 12 +++++++----- data.h | 2 +- debug.ino | 12 ++++++++++-- map.ino | 4 ---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ECU.ino b/ECU.ino index c3ff20c..6c0d2a9 100644 --- a/ECU.ino +++ b/ECU.ino @@ -2,6 +2,7 @@ #include "data.h" #include "schedule.h" #include "tables.h" +void(* resetFunc) (void) = 0; //declare reset function @ address 0 void setup() { // Sensors @@ -45,4 +46,3 @@ void loop() { // Run scheduler schedule_process(); } - diff --git a/battery.ino b/battery.ino index 146b5b8..bf093c6 100644 --- a/battery.ino +++ b/battery.ino @@ -12,10 +12,6 @@ void battery_init() { Serial.println("ERR: Battery high"); } - else - { - Serial.println("INF: Battery ok"); - } } void task_battery_run() @@ -27,5 +23,3 @@ void task_battery_run() // Nudge it along so we have an index starting at 0 for tables etc battery_voltage_index = constrain(battery_voltage_value,7,16) - 7; } - - diff --git a/cas.ino b/cas.ino index 39deddd..d2e5f38 100644 --- a/cas.ino +++ b/cas.ino @@ -56,7 +56,13 @@ void cas_process() else { // Clear it if we're in sync, but don't clear log flag - cas_sync_fail = 0; + if(cas_sync_initial == 1) + { + cas_sync_initial = 0; + cas_sync_fail = 0; + cas_sync_fail_log = 0; + } + } // Use this number because we KNOW it's right @@ -137,7 +143,3 @@ void cas_process() } cas_sgc_lastvalue = sgc; } - - - - diff --git a/data.h b/data.h index ff9dc93..a9b9b1f 100644 --- a/data.h +++ b/data.h @@ -24,6 +24,7 @@ unsigned long cas_sgc_lastrise = 0; // micros() of the las unsigned long cas_sgc_lastfall = 0; // "" of the last fall byte cas_sgc_lastvalue = 0; // The state of SGC on the previous cycle +byte cas_sync_initial = 1; byte cas_sync_fail = 0; // We lost track of a cylinder byte cas_sync_fail_log = 0; // We need to output this in debug @@ -57,4 +58,3 @@ byte throttle_current_value = 0; // Percentage byte throttle_previous_1_value = 0; // Percentage byte throttle_previous_2_value = 0; // Percentage byte throttle_delta = 0; // Difference between current and delta - diff --git a/debug.ino b/debug.ino index d7a76d9..cebf3f2 100644 --- a/debug.ino +++ b/debug.ino @@ -18,7 +18,10 @@ void task_debug_run() // Log if we're out of sync timing-wise if(cas_sync_fail_log > 0) { - Serial.println("ERR: CAS sync fail"); + if(cas_sync_initial == 0) + { + Serial.println("ERR: CAS sync fail"); + } cas_sync_fail_log = 0; } @@ -138,8 +141,14 @@ void task_debug_run() }else if(readbyte == 'R') // Enable RPM output { debug_rpm = 1; + }else if(readbyte == 'S') // Arduino reset + { + resetFunc(); } } + + // Allow it to re-sync (i.e. reset CAS failure as it was intentional) + cas_sync_initial = 1; } // Outputs the fuel table as JSON @@ -200,4 +209,3 @@ void task_debug_safekill() cas_sync_fail=1; cas_sync_fail_log=0; } - diff --git a/map.ino b/map.ino index 3c9565e..da5bed8 100644 --- a/map.ino +++ b/map.ino @@ -7,8 +7,6 @@ void map_init() Serial.println("ERR: MAP low"); else if(map_current_value > 108) Serial.println("ERR: MAP high "); - else - Serial.println("INF: MAP ok"); } void task_map_run() @@ -17,5 +15,3 @@ void task_map_run() map_current_index = map(map_current_value, map_range_min, map_range_max, 0, 15); map_current_index = constrain(map_current_index,0,15); } - -