fatal error + inhibit read on TS preset (#1922)

* fatal error + inhibit read on preset

* inhibit more stuff when flag is set

* don't need that message

* extract function, improve msg

* changelog entry
This commit is contained in:
Matthew Kennedy 2020-11-03 16:03:46 -08:00 committed by GitHub
parent e8bb0cfd00
commit 5f11390f58
4 changed files with 41 additions and 10 deletions

View File

@ -35,6 +35,7 @@ All notable user-facing or behavior-altering changes will be documented in this
- High & low pressure fuel sensor channels
- Electronic throttle-style wastegate control found on some VW turbos (and VGTs)
- Improved TLE8888 driver on microRusEfi
- Improved setting ECU presets/defaults from TunerStudio
## October 2020 Release - "Sausage Pizza Day"

View File

@ -304,6 +304,11 @@ static bool validateOffsetCount(size_t offset, size_t count, ts_channel_s *tsCha
return false;
}
// This is used to prevent TS from reading/writing when we have just applied a preset, to prevent TS getting confused.
// At the same time an ECU reboot is forced by triggering a fatal error, informing the user to please restart
// the ECU. Forcing a reboot will force TS to re-read the tune CRC,
bool rebootForPresetPending = false;
/**
* This command is needed to make the whole transfer a bit faster
* @note See also handleWriteValueCommand
@ -318,9 +323,12 @@ static void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_
return;
}
uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
memcpy(addr, content, count);
onlineApplyWorkingCopyBytes(offset, count);
// Skip the write if a preset was just loaded - we don't want to overwrite it
if (!rebootForPresetPending) {
uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
memcpy(addr, content, count);
onlineApplyWorkingCopyBytes(offset, count);
}
sendOkResponse(tsChannel, mode);
}
@ -365,16 +373,22 @@ static void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_
scheduleMsg(&tsLogger, "offset %d: value=%d", offset, value);
}
getWorkingPageAddr()[offset] = value;
// Skip the write if a preset was just loaded - we don't want to overwrite it
if (!rebootForPresetPending) {
getWorkingPageAddr()[offset] = value;
onlineApplyWorkingCopyBytes(offset, 1);
// scheduleMsg(logger, "va=%d", configWorkingCopy.boardConfiguration.idleValvePin);
onlineApplyWorkingCopyBytes(offset, 1);
}
}
static void handlePageReadCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint16_t offset, uint16_t count) {
tsState.readPageCommandsCounter++;
if (rebootForPresetPending) {
sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND);
return;
}
#if EFI_TUNER_STUDIO_VERBOSE
scheduleMsg(&tsLogger, "READ mode=%d offset=%d size=%d", mode, offset, count);
#endif
@ -413,11 +427,15 @@ static void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode
scheduleMsg(&tsLogger, "got B (Burn) %s", mode == TS_PLAIN ? "plain" : "CRC");
// Skip the burn if a preset was just loaded - we don't want to overwrite it
if (!rebootForPresetPending) {
#if !defined(EFI_NO_CONFIG_WORKING_COPY)
memcpy(&persistentState.persistentConfiguration, &configWorkingCopy, sizeof(persistent_config_s));
memcpy(&persistentState.persistentConfiguration, &configWorkingCopy, sizeof(persistent_config_s));
#endif /* EFI_NO_CONFIG_WORKING_COPY */
requestBurn();
requestBurn();
}
sendResponseCode(mode, tsChannel, TS_RESPONSE_BURN_OK);
scheduleMsg(&tsLogger, "BURN in %dms", currentTimeMillis() - nowMs);
}

View File

@ -321,6 +321,17 @@ static void handleCommandX14(uint16_t index) {
}
}
extern bool rebootForPresetPending;
static void fatalErrorForPresetApply() {
rebootForPresetPending = true;
firmwareError(OBD_PCM_Processor_Fault,
"\n\nTo complete preset apply:\n"
" 1. Close TunerStudio\n"
" 2. Power cycle ECU\n"
" 3. Open TunerStudio and reconnect\n\n");
}
// todo: this is probably a wrong place for this method now
void executeTSCommand(uint16_t subsystem, uint16_t index) {
scheduleMsg(logger, "IO test subsystem=%d index=%d", subsystem, index);
@ -354,8 +365,10 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
// call to pit
setCallFromPitStop(30000);
} else if (subsystem == 0x30) {
fatalErrorForPresetApply();
setEngineType(index);
} else if (subsystem == 0x31) {
fatalErrorForPresetApply();
setEngineType(DEFAULT_ENGINE_TYPE);
} else if (subsystem == 0x79) {
scheduleStopEngine();

View File

@ -3183,7 +3183,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
commandButton = "ETB test bench", cmd_set_engine_type_etb_test@@if_show_test_presets
commandButton = "TLE8888 test bench", cmd_set_engine_type_8888_test@@if_show_test_presets
commandButton = "Reset firmware settings", cmd_set_engine_type_default
field = "#Please DO NOT hit 'Burn' - just press a command button above and disconnect TunerStudio!"
; Board->ECU stimulator