More portability and smaller RAM footprint possible (#722)

* EFI_NO_CONFIG_WORKING_COPY

* EFI_CONSOLE_NO_THREAD

* EFI_SHAFT_POSITION_INPUT

* #ifndef UTILITY_THREAD_STACK_SIZE

* fix printf() -> print()
This commit is contained in:
andreika-git 2019-03-30 23:41:46 +02:00 committed by rusefi
parent d973ebaa1c
commit f1ec34f032
6 changed files with 32 additions and 2 deletions

View File

@ -101,12 +101,15 @@ extern short currentPageId;
*/
LoggingWithStorage tsLogger("binary");
#if !defined(EFI_NO_CONFIG_WORKING_COPY) || defined(__DOXYGEN__)
/**
* this is a local copy of the configuration. Any changes to this copy
* have no effect until this copy is explicitly propagated to the main working copy
*/
persistent_config_s configWorkingCopy;
#endif /* EFI_NO_CONFIG_WORKING_COPY */
extern persistent_config_container_s persistentState;
static efitimems_t previousWriteReportMs = 0;
@ -192,7 +195,11 @@ void tunerStudioDebug(const char *msg) {
char *getWorkingPageAddr(int pageIndex) {
switch (pageIndex) {
case 0:
#if !defined(EFI_NO_CONFIG_WORKING_COPY) || defined(__DOXYGEN__)
return (char*) &configWorkingCopy.engineConfiguration;
#else
return (char*) &engineConfiguration;
#endif /* EFI_NO_CONFIG_WORKING_COPY */
// case 1:
// return (char*) &configWorkingCopy.ve2Table;
// case 2:
@ -264,8 +271,10 @@ static void onlineTuneBytes(int currentPageId, uint32_t offset, int count) {
return;
}
scheduleMsg(&tsLogger, "applying soft change from %d length %d", offset, count);
#if !defined(EFI_NO_CONFIG_WORKING_COPY) || defined(__DOXYGEN__)
memcpy(((char*) &persistentState.persistentConfiguration) + offset, ((char*) &configWorkingCopy) + offset,
count);
#endif /* EFI_NO_CONFIG_WORKING_COPY */
}
}
@ -430,7 +439,9 @@ void handleBurnCommand(ts_channel_s *tsChannel, ts_response_format_e mode, uint1
#endif
// todo: how about some multi-threading?
#if !defined(EFI_NO_CONFIG_WORKING_COPY) || defined(__DOXYGEN__)
memcpy(&persistentState.persistentConfiguration, &configWorkingCopy, sizeof(persistent_config_s));
#endif /* EFI_NO_CONFIG_WORKING_COPY */
requestBurn();
sendResponseCode(mode, tsChannel, TS_RESPONSE_BURN_OK);
@ -578,7 +589,9 @@ static THD_FUNCTION(tsThreadEntryPoint, arg) {
}
void syncTunerStudioCopy(void) {
#if !defined(EFI_NO_CONFIG_WORKING_COPY) || defined(__DOXYGEN__)
memcpy(&configWorkingCopy, &persistentState.persistentConfiguration, sizeof(persistent_config_s));
#endif /* EFI_NO_CONFIG_WORKING_COPY */
}
tunerstudio_counters_s tsState;

View File

@ -215,6 +215,8 @@ bool isCommandLineConsoleReady(void) {
}
#endif /* EFI_PROD_CODE || EFI_EGT */
#if !defined(EFI_CONSOLE_NO_THREAD) || defined(__DOXYGEN__)
ts_channel_s binaryConsole;
static THD_WORKING_AREA(consoleThreadStack, 3 * UTILITY_THREAD_STACK_SIZE);
@ -237,6 +239,8 @@ static THD_FUNCTION(consoleThreadThreadEntryPoint, arg) {
runConsoleLoop(&binaryConsole);
}
#endif /* EFI_CONSOLE_NO_THREAD */
// 10 seconds
#define CONSOLE_WRITE_TIMEOUT 10000
@ -290,7 +294,9 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p)
b_isCommandLineConsoleOverTTL = false;
#endif /* EFI_PROD_CODE */
#if !defined(EFI_CONSOLE_NO_THREAD) || defined(__DOXYGEN__)
chThdCreateStatic(consoleThreadStack, sizeof(consoleThreadStack), NORMALPRIO, (tfunc_t)consoleThreadThreadEntryPoint, NULL);
#endif /* EFI_CONSOLE_NO_THREAD */
addConsoleAction(SWITCH_TO_BINARY_COMMAND, switchToBinaryProtocol);
}

View File

@ -306,7 +306,11 @@ private:
undoIdleBlipIfNeeded();
float clt = engine->sensors.clt;
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
bool isRunning = engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE);
#else
bool isRunning = false;
#endif /* EFI_SHAFT_POSITION_INPUT */
// cltCorrection is used only for cranking or running in manual mode
float cltCorrection;
if (cisnan(clt))

View File

@ -58,7 +58,9 @@ typedef unsigned int time_t;
* See getRemainingStack()
* See getMaxUsedStack()
*/
#ifndef UTILITY_THREAD_STACK_SIZE
#define UTILITY_THREAD_STACK_SIZE 400
#endif /* UTILITY_THREAD_STACK_SIZE */
#define EFI_ERROR_CODE 0xffffffff

View File

@ -46,8 +46,13 @@ static msg_t stThread(StepperMotor *motor) {
// first wait until at least 1 slowADC sampling is complete
waitForSlowAdc();
#endif
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
bool isRunning = engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE);
#else
bool isRunning = false;
#endif /* EFI_SHAFT_POSITION_INPUT */
// now check if stepper motor re-initialization is requested - if the throttle pedal is pressed at startup
bool forceStepperParking = !engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE) && getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > STEPPER_PARKING_TPS;
bool forceStepperParking = !isRunning && getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > STEPPER_PARKING_TPS;
if (CONFIGB(stepperForceParkingEveryRestart))
forceStepperParking = true;
scheduleMsg(logger, "Stepper: savedStepperPos=%d forceStepperParking=%d (tps=%.2f)", motor->currentPosition, (forceStepperParking ? 1 : 0), getTPS(PASS_ENGINE_PARAMETER_SIGNATURE));

View File

@ -221,7 +221,7 @@ float atoff(const char *param) {
strcpy(todofixthismesswithcopy, param);
char *string = todofixthismesswithcopy;
if (indexOf(string, 'n') != -1 || indexOf(string, 'N') != -1) {
printf("NAN from [%s]\r\n", string);
print("NAN from [%s]\r\n", string);
return (float) NAN;
}