Access to uninitialized table: tct fix #7300

fix to initialization sequence - noise or starter might get lucky and happen too soon?
only:uaefi
This commit is contained in:
rusefillc 2025-01-14 08:09:00 -05:00
parent 8a47382b9a
commit 9dac54ad17
3 changed files with 19 additions and 5 deletions

View File

@ -131,12 +131,9 @@ static void writeSdBlock(Writer& outBuffer) {
outBuffer.write(buffer, 1);
}
#if EFI_PROD_CODE
extern bool main_loop_started;
#endif //EFI_PROD_CODE
void writeSdLogLine(Writer& bufferedWriter) {
#if EFI_PROD_CODE
extern bool main_loop_started;
if (!main_loop_started)
return;
#endif //EFI_PROD_CODE

View File

@ -1843,7 +1843,7 @@ enum class ObdCode : uint16_t {
CUSTOM_ERR_DWELL_DURATION = 6118,
CUSTOM_ERR_NO_SHAPE = 6119,
CUSTOM_ERR_6121 = 6121,
CUSTOM_ERR_INPUT_DURING_INITIALISATION = 6121,
CUSTOM_ERR_6122 = 6122,
CUSTOM_ERR_6123 = 6123,
CUSTOM_ERR_6124 = 6124,

View File

@ -258,12 +258,26 @@ static void logVvtFront(bool useOnlyRise, bool isImportantFront, TriggerValue fr
}
}
static bool tooSoonToHandleSignal() {
#if EFI_PROD_CODE
extern bool main_loop_started;
if (!main_loop_started) {
warning(ObdCode::CUSTOM_ERR_INPUT_DURING_INITIALISATION, "event too early");
return true;
}
#endif //EFI_PROD_CODE
return false;
}
void hwHandleVvtCamSignal(bool isRising, efitick_t timestamp, int index) {
hwHandleVvtCamSignal(isRising ? TriggerValue::RISE : TriggerValue::FALL, timestamp, index);
}
// 'invertCamVVTSignal' is already accounted by the time this method is invoked
void hwHandleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index) {
if (tooSoonToHandleSignal()) {
return;
}
TriggerCentral *tc = getTriggerCentral();
if (tc->directSelfStimulation || !tc->hwTriggerInputEnabled) {
// sensor noise + self-stim = loss of trigger sync
@ -432,6 +446,9 @@ uint32_t triggerMaxDuration = 0;
* - Trigger replay from CSV (unit tests)
*/
void hwHandleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) {
if (tooSoonToHandleSignal()) {
return;
}
TriggerCentral *tc = getTriggerCentral();
ScopePerf perf(PE::HandleShaftSignal);