rusEfi settings editor is broken for one byte enums fix #709

This commit is contained in:
rusefi 2019-04-08 11:57:16 -04:00
parent 64c70c3e2d
commit f3d748917f
6 changed files with 39 additions and 11 deletions

View File

@ -254,6 +254,8 @@ void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
}
/**
* Copy specified amount of bytes from specified offset from communication layer working copy into real configuration
*
* Some changes like changing VE table or timing table are applied right away, meaning
* that the values are copied from communication copy into actual engine control copy right away.
* We call these parameters 'soft parameters'
@ -263,7 +265,7 @@ void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
* On the contrary, 'hard parameters' are waiting for the Burn button to be clicked and configuration version
* would be increased and much more complicated logic would be executed.
*/
static void onlineTuneBytes(int currentPageId, uint32_t offset, int count) {
static void onlineApplyWorkingCopyBytes(int currentPageId, uint32_t offset, int count) {
UNUSED(currentPageId);
if (offset > sizeof(engine_configuration_s)) {
int maxSize = sizeof(persistent_config_s) - offset;
@ -312,7 +314,7 @@ void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
uint8_t * addr = (uint8_t *) (getWorkingPageAddr(currentPageId) + offset);
memcpy(addr, content, count);
onlineTuneBytes(currentPageId, offset, count);
onlineApplyWorkingCopyBytes(currentPageId, offset, count);
sendOkResponse(tsChannel, mode);
}
@ -370,7 +372,7 @@ void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
getWorkingPageAddr(currentPageId)[offset] = value;
onlineTuneBytes(currentPageId, offset, 1);
onlineApplyWorkingCopyBytes(currentPageId, offset, 1);
// scheduleMsg(logger, "va=%d", configWorkingCopy.boardConfiguration.idleValvePin);
}
@ -589,6 +591,9 @@ static THD_FUNCTION(tsThreadEntryPoint, arg) {
runBinaryProtocolLoop(&tsChannel);
}
/**
* Copy real configuration into the communications layer working copy
*/
void syncTunerStudioCopy(void) {
#if !defined(EFI_NO_CONFIG_WORKING_COPY) || defined(__DOXYGEN__)
memcpy(&configWorkingCopy, &persistentState.persistentConfiguration, sizeof(persistent_config_s));

View File

@ -25,8 +25,8 @@ typedef void (*CommandHandler)(char *);
#include "datalogging.h"
#ifdef CONFIG_RESET_SWITCH_PORT
// todo: make this pin configurable
#define SHOULD_INGORE_FLASH() (CONFIG_RESET_SWITCH_PORT != NULL && palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0)
// todo: make this pin configurable? or maybe it should not be configurable?
#define SHOULD_INGORE_FLASH() (palReadPad(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN) == 0)
#else
#define SHOULD_INGORE_FLASH() (false)
#endif

View File

@ -1357,7 +1357,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN
#if EFI_TUNER_STUDIO
syncTunerStudioCopy();
#endif
#endif /* EFI_TUNER_STUDIO */
}
void validateConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {

View File

@ -441,6 +441,16 @@ static void getByte(int offset) {
scheduleMsg(&logger, "byte%s%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, value);
}
static void onConfigurationChanged() {
#if EFI_TUNER_STUDIO
// on start-up rusEfi would read from working copy of TS while
// we have a lot of console commands which write into real copy of configuration directly
// we have a bit of a mess here
syncTunerStudioCopy();
#endif /* EFI_TUNER_STUDIO */
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
}
static void setBit(const char *offsetStr, const char *bitStr, const char *valueStr) {
int offset = atoi(offsetStr);
if (absI(offset) == absI(ERROR_CODE)) {
@ -466,7 +476,7 @@ static void setBit(const char *offsetStr, const char *bitStr, const char *valueS
* this response is part of dev console API
*/
scheduleMsg(&logger, "bit%s%d/%d is %d", CONSOLE_DATA_PROTOCOL_TAG, offset, bit, value);
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
onConfigurationChanged();
}
static void setShort(const int offset, const int value) {
@ -475,7 +485,7 @@ static void setShort(const int offset, const int value) {
uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]);
*ptr = (uint16_t) value;
getShort(offset);
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
onConfigurationChanged();
}
static void setByte(const int offset, const int value) {
@ -484,7 +494,7 @@ static void setByte(const int offset, const int value) {
uint8_t *ptr = (uint8_t *) (&((char *) engineConfiguration)[offset]);
*ptr = (uint8_t) value;
getByte(offset);
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
onConfigurationChanged();
}
static void getBit(int offset, int bit) {
@ -515,7 +525,7 @@ static void setInt(const int offset, const int value) {
int *ptr = (int *) (&((char *) engineConfiguration)[offset]);
*ptr = value;
getInt(offset);
incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE);
onConfigurationChanged();
}
static void getFloat(int offset) {
@ -545,6 +555,7 @@ static void setFloat(const char *offsetStr, const char *valueStr) {
float *ptr = (float *) (&((char *) engineConfiguration)[offset]);
*ptr = value;
getFloat(offset);
onConfigurationChanged();
}
#if EFI_ENABLE_MOCK_ADC || EFI_SIMULATOR

View File

@ -171,6 +171,16 @@ static void rewriteConfig(void) {
writeToFlashNow();
}
static void writeConfigCommand() {
#if EFI_TUNER_STUDIO
// on start-up rusEfi would read from working copy of TS while
// we have a lot of console commands which write into real copy of configuration directly
// we have a bit of a mess here
syncTunerStudioCopy();
#endif /* EFI_TUNER_STUDIO */
writeToFlashNow();
}
void initFlash(Logging *sharedLogger) {
logger = sharedLogger;
@ -178,7 +188,7 @@ void initFlash(Logging *sharedLogger) {
/**
* This would write NOW (you should not be doing this while connected to real engine)
*/
addConsoleAction("writeconfig", writeToFlashNow);
addConsoleAction("writeconfig", writeConfigCommand);
#if EFI_TUNER_STUDIO || defined(__DOXYGEN__)
/**
* This would schedule write to flash once the engine is stopped

View File

@ -369,7 +369,9 @@ void initHardware(Logging *l) {
#if EFI_INTERNAL_FLASH
#ifdef CONFIG_RESET_SWITCH_PORT
palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN, PAL_MODE_INPUT_PULLUP);
#endif /* CONFIG_RESET_SWITCH_PORT */
initFlash(sharedLogger);
/**