auto-sync

This commit is contained in:
rusEfi 2015-02-19 08:04:18 -06:00
parent e37e3e2136
commit 9ba24a615d
9 changed files with 43 additions and 14 deletions

View File

@ -308,6 +308,13 @@ void handlePageReadCommand(ts_response_format_e mode, uint16_t pageId, uint16_t
#endif
}
void requestBurn(void) {
#if EFI_INTERNAL_FLASH
setNeedToWriteConfiguration();
#endif
incrementGlobalConfigurationVersion();
}
/**
* 'Burn' command is a command to commit the changes
*/
@ -327,10 +334,7 @@ void handleBurnCommand(ts_response_format_e mode, uint16_t page) {
// todo: how about some multi-threading?
memcpy(&persistentState.persistentConfiguration, &configWorkingCopy, sizeof(persistent_config_s));
#if EFI_INTERNAL_FLASH
setNeedToWriteConfiguration();
#endif
incrementGlobalConfigurationVersion();
requestBurn();
tunerStudioWriteCrcPacket(TS_RESPONSE_BURN_OK, NULL, 0);
scheduleMsg(tsLogger, "burned in (ms): %d", currentTimeMillis() - nowMs);
}

View File

@ -16,6 +16,7 @@
void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputChannels);
void printTsStats(void);
void requestBurn(void);
void startTunerStudioConnectivity(Logging *sharedLogger);
void syncTunerStudioCopy(void);

View File

@ -14,6 +14,10 @@
#include "flash.h"
#include "rusefi.h"
#if EFI_TUNER_STUDIO || defined(__DOXYGEN__)
#include "tunerstudio.h"
#endif
#if EFI_INTERNAL_FLASH
#include "engine_controller.h"
@ -56,12 +60,12 @@ void writeToFlashIfPending() {
// todo: technically we need a lock here, realistically we should be fine.
needToWriteConfiguration = false;
scheduleMsg(logger, "Writing pending configuration");
writeToFlash();
writeToFlashNow();
}
extern uint32_t maxLockTime;
void writeToFlash(void) {
void writeToFlashNow(void) {
scheduleMsg(logger, " !!!!!!!!!!!!!!!!!!!! BE SURE NOT WRITE WITH IGNITION ON !!!!!!!!!!!!!!!!!!!!");
persistentState.size = PERSISTENT_SIZE;
persistentState.version = FLASH_DATA_VERSION;
@ -119,14 +123,23 @@ void readFromFlash(void) {
static void rewriteConfig(Engine *engine) {
doResetConfiguration();
writeToFlash();
writeToFlashNow();
}
void initFlash(Logging *sharedLogger, Engine *engine) {
logger = sharedLogger;
addConsoleAction("readconfig", readFromFlash);
addConsoleAction("writeconfig", writeToFlash);
/**
* This would write NOW (you should not be doing this while connected to real engine)
*/
addConsoleAction("writeconfig", writeToFlashNow);
#if EFI_TUNER_STUDIO || defined(__DOXYGEN__)
/**
* This would schedule write to flash once the engine is stopped
*/
addConsoleAction("burnconfig", requestBurn);
#endif
addConsoleAction("resetconfig", doResetConfiguration);
addConsoleActionP("rewriteconfig", (VoidPtr)rewriteConfig, engine);
}

View File

@ -23,7 +23,7 @@ void initFlash(Logging *sharedLogger, Engine *engine);
* about 1-2 seconds, we cannot afford to do that while the engine is
* running so we postpone the write until the engine is stopped.
*/
void writeToFlash(void);
void writeToFlashNow(void);
void setNeedToWriteConfiguration(void);
/**
* @return true if an flash write is pending

View File

@ -283,7 +283,7 @@ void setEngineType(int value) {
engineConfiguration->engineType = (engine_type_e) value;
resetConfigurationExt(&logger, (engine_type_e) value, engine);
#if EFI_INTERNAL_FLASH
writeToFlash();
writeToFlashNow();
// scheduleReset();
#endif /* EFI_PROD_CODE */
incrementGlobalConfigurationVersion();

View File

@ -230,7 +230,7 @@ void initHardware(Logging *l, Engine *engine) {
if (SHOULD_INGORE_FLASH()) {
engineConfiguration->engineType = DEFAULT_ENGINE_TYPE;
resetConfigurationExt(sharedLogger, engineConfiguration->engineType, engine);
writeToFlash();
writeToFlashNow();
} else {
readFromFlash();
}

View File

@ -278,5 +278,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE == 0)
return 1; // this is here to make the compiler happy about the unused array
return 20150218;
return 20150219;
}

View File

@ -1,5 +1,5 @@
// This file was generated by Version2Header
// Wed Feb 18 22:08:55 EST 2015
// Thu Feb 19 07:53:56 EST 2015
#ifndef VCS_VERSION
#define VCS_VERSION "6947"
#define VCS_VERSION "6949"
#endif

View File

@ -505,6 +505,17 @@ page = 1
veAnalyzeMap = veTableTbl, afrTableTbl, AFRactual, egoCorrection , { 1 }
;lambdaTargetTables = afrTable1Tbl, afrTable2Tbl, afrTSCustom
; filter = Name, "DisplayName", outputChannel, operator, defaultVal, userAdjustable
filter = minRPMFilter, "Minimum RPM", rpm, < , 500, , true
#if CELSIUS
filter = minCltFilter, "Minimum CLT", coolant, < , 71, , true
#else
filter = minCltFilter, "Minimum CLT", coolant, < , 160, , true
#endif
[OutputChannels]
; see TS_FILE_VERSION in firmware code