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 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

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);
extern bool rebootForPresetPending;
bool wasPresetJustApplied() {
return !engine->configBurnTimer.hasElapsedSec(1);
}
/**
* 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
if (!rebootForPresetPending) {
if (!wasPresetJustApplied()) {
uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
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);
if (page == 0) {
if (rebootForPresetPending) {
sendErrorCode(tsChannel, TS_RESPONSE_UNRECOGNIZED_COMMAND, "reboot");
return;
}
if (validateOffsetCount(offset, count, tsChannel)) {
tunerStudioError(tsChannel, "ERROR: RD out of range");
sendErrorCode(tsChannel, TS_RESPONSE_OUT_OF_RANGE);
@ -369,7 +366,7 @@ static void handleBurnCommand(TsChannelBase* tsChannel) {
validateConfigOnStartUpOrBurn();
// Skip the burn if a preset was just loaded - we don't want to overwrite it
if (!rebootForPresetPending) {
if (!wasPresetJustApplied()) {
requestBurn();
}
@ -906,7 +903,7 @@ static char tsErrorBuff[80];
#endif // EFI_PROD_CODE || EFI_SIMULATOR
void startTunerStudioConnectivity(void) {
void startTunerStudioConnectivity() {
// Assert tune & output channel struct sizes
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

View File

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

View File

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

View File

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

View File

@ -287,6 +287,7 @@ public:
RpmCalculator rpmCalculator;
Timer configBurnTimer;
Timer engineTypeChangeTimer;
/**
* 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;
void fatalErrorForPresetApply() {
rebootForPresetPending = true;
firmwareError(ObdCode::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");
static void applyPreset(int index) {
engine->configBurnTimer.reset();
setEngineType(index);
}
PUBLIC_API_WEAK void boardTsAction(uint16_t index) { }
@ -584,8 +580,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
break;
case TS_SET_ENGINE_TYPE:
fatalErrorForPresetApply();
setEngineType(index);
applyPreset(index);
break;
case TS_BOARD_ACTION:
@ -593,8 +588,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
break;
case TS_SET_DEFAULT_ENGINE:
fatalErrorForPresetApply();
setEngineType((int)DEFAULT_ENGINE_TYPE);
applyPreset((int)DEFAULT_ENGINE_TYPE);
break;
case 0x79:

View File

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

View File

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