canned tunes button should tell TS to refresh #7250

only:uaefi
This commit is contained in:
rusefillc 2025-01-03 12:23:55 -05:00
parent 4b68967fdb
commit dc9021a3fa
9 changed files with 21 additions and 29 deletions

View File

@ -42,7 +42,8 @@ bit sd_active_wr;SD card writing
bit sd_active_rd;SD card reading bit sd_active_rd;SD card reading
bit isMapValid;MAP from sensor seems valid bit isMapValid;MAP from sensor seems valid
! 2 unused bits left here bit triggerPageRefreshFlag
! 1 unused bit left here
uint16_t RPMValue;@@GAUGE_NAME_RPM@@;"RPM",1, 0, 0, 8000, 0 uint16_t RPMValue;@@GAUGE_NAME_RPM@@;"RPM",1, 0, 0, 8000, 0

View File

@ -193,7 +193,9 @@ void TunerStudio::sendErrorCode(TsChannelBase* tsChannel, uint8_t code, const ch
bool validateOffsetCount(size_t offset, size_t count, TsChannelBase* tsChannel); bool validateOffsetCount(size_t offset, size_t count, TsChannelBase* tsChannel);
extern bool rebootForPresetPending; bool wasPresetJustApplied() {
return !engine->configBurnTimer.hasElapsedSec(1);
}
/** /**
* This command is needed to make the whole transfer a bit faster * This command is needed to make the whole transfer a bit faster
@ -218,7 +220,7 @@ void TunerStudio::handleWriteChunkCommand(TsChannelBase* tsChannel, uint16_t pag
} }
// Skip the write if a preset was just loaded - we don't want to overwrite it // Skip the write if a preset was just loaded - we don't want to overwrite it
if (!rebootForPresetPending) { if (!wasPresetJustApplied()) {
uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset); uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
memcpy(addr, content, count); memcpy(addr, content, count);
} }
@ -315,11 +317,6 @@ void TunerStudio::handlePageReadCommand(TsChannelBase* tsChannel, uint16_t page,
efiPrintf("TS <- Page %d read chunk offset %d count %d", page, offset, count); efiPrintf("TS <- Page %d read chunk offset %d count %d", page, offset, count);
if (page == 0) { if (page == 0) {
if (rebootForPresetPending) {
sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "reboot");
return;
}
if (validateOffsetCount(offset, count, tsChannel)) { if (validateOffsetCount(offset, count, tsChannel)) {
tunerStudioError(tsChannel, "ERROR: RD out of range"); tunerStudioError(tsChannel, "ERROR: RD out of range");
sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE); sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
@ -369,7 +366,7 @@ static void handleBurnCommand(TsChannelBase* tsChannel) {
validateConfigOnStartUpOrBurn(); validateConfigOnStartUpOrBurn();
// Skip the burn if a preset was just loaded - we don't want to overwrite it // Skip the burn if a preset was just loaded - we don't want to overwrite it
if (!rebootForPresetPending) { if (!wasPresetJustApplied()) {
requestBurn(); requestBurn();
} }
@ -906,7 +903,7 @@ static char tsErrorBuff[80];
#endif // EFI_PROD_CODE || EFI_SIMULATOR #endif // EFI_PROD_CODE || EFI_SIMULATOR
void startTunerStudioConnectivity(void) { void startTunerStudioConnectivity() {
// Assert tune & output channel struct sizes // Assert tune & output channel struct sizes
static_assert(sizeof(persistent_config_s) == TOTAL_CONFIG_SIZE, "TS datapage size mismatch"); static_assert(sizeof(persistent_config_s) == TOTAL_CONFIG_SIZE, "TS datapage size mismatch");
// useful trick if you need to know how far off is the static_assert // useful trick if you need to know how far off is the static_assert

View File

@ -52,7 +52,8 @@ int getSecondsSinceChannelsRequest();
void updateTunerStudioState(); void updateTunerStudioState();
void startTunerStudioConnectivity(void); void startTunerStudioConnectivity();
bool wasPresetJustApplied();
typedef struct { typedef struct {
uint16_t offset; uint16_t offset;

View File

@ -27,12 +27,6 @@ bool validateOffsetCount(size_t offset, size_t count, TsChannelBase* tsChannel)
return false; 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;
static Timer channelsRequestTimer; static Timer channelsRequestTimer;
int getSecondsSinceChannelsRequest() { int getSecondsSinceChannelsRequest() {

View File

@ -727,6 +727,7 @@ void updateTunerStudioState() {
tsOutputChannels->vssEdgeCounter = vehicleSpeedSensor.eventCounter; tsOutputChannels->vssEdgeCounter = vehicleSpeedSensor.eventCounter;
tsOutputChannels->hasCriticalError = hasFirmwareError() || hasConfigError(); tsOutputChannels->hasCriticalError = hasFirmwareError() || hasConfigError();
tsOutputChannels->triggerPageRefreshFlag = wasPresetJustApplied();
tsOutputChannels->isWarnNow = engine->engineState.warnings.isWarningNow(); tsOutputChannels->isWarnNow = engine->engineState.warnings.isWarningNow();
#if EFI_HIP_9011_DEBUG #if EFI_HIP_9011_DEBUG

View File

@ -287,6 +287,7 @@ public:
RpmCalculator rpmCalculator; RpmCalculator rpmCalculator;
Timer configBurnTimer; Timer configBurnTimer;
Timer engineTypeChangeTimer;
/** /**
* This counter is incremented every time user adjusts ECU parameters online (either via rusEfi console or other * This counter is incremented every time user adjusts ECU parameters online (either via rusEfi console or other

View File

@ -518,13 +518,9 @@ static void handleCommandX14(uint16_t index) {
extern bool rebootForPresetPending; extern bool rebootForPresetPending;
void fatalErrorForPresetApply() { static void applyPreset(int index) {
rebootForPresetPending = true; engine->configBurnTimer.reset();
firmwareError(ObdCode::OBD_PCM_Processor_Fault, setEngineType(index);
"\n\nTo complete preset apply:\n"
" 1. Close TunerStudio\n"
" 2. Power cycle ECU\n"
" 3. Open TunerStudio and reconnect\n\n");
} }
PUBLIC_API_WEAK void boardTsAction(uint16_t index) { } PUBLIC_API_WEAK void boardTsAction(uint16_t index) { }
@ -584,8 +580,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
break; break;
case TS_SET_ENGINE_TYPE: case TS_SET_ENGINE_TYPE:
fatalErrorForPresetApply(); applyPreset(index);
setEngineType(index);
break; break;
case TS_BOARD_ACTION: case TS_BOARD_ACTION:
@ -593,8 +588,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
break; break;
case TS_SET_DEFAULT_ENGINE: case TS_SET_DEFAULT_ENGINE:
fatalErrorForPresetApply(); applyPreset((int)DEFAULT_ENGINE_TYPE);
setEngineType((int)DEFAULT_ENGINE_TYPE);
break; break;
case 0x79: case 0x79:

View File

@ -15,7 +15,6 @@ void onConfigurationChangeBenchTest();
bool isRunningBenchTest(); bool isRunningBenchTest();
const OutputPin *getOutputOnTheBenchTest(); const OutputPin *getOutputOnTheBenchTest();
void fatalErrorForPresetApply();
void fanBench(); void fanBench();
void fan2Bench(); void fan2Bench();

View File

@ -5391,3 +5391,7 @@ dialog = tcuControls, "Transmission Settings"
#else #else
addTool = afrTableGenerator, "AFR Table Generator", afrTableTbl addTool = afrTableGenerator, "AFR Table Generator", afrTableTbl
#endif #endif
[EventTriggers]
triggeredPageRefresh = 1, { triggerPageRefreshFlag }