auto-sync

This commit is contained in:
rusEfi 2014-12-06 14:04:01 -06:00
parent 284e0be839
commit 76d14c02d4
6 changed files with 81 additions and 28 deletions

View File

@ -272,6 +272,8 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat
* CLT D13/W9
*/
engineConfiguration->cltAdcChannel = EFI_ADC_12;
//setFsio(engineConfiguration, 0, GPIO)
}
#endif /* EFI_SUPPORT_DODGE_NEON */

View File

@ -27,6 +27,7 @@
#include "trigger_decoder.h"
#include "engine_math.h"
#include "speed_density.h"
#include "logic_expression.h"
#if EFI_TUNER_STUDIO
#include "tunerstudio.h"
@ -571,6 +572,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType, Engine *e
firmwareError("Unexpected engine type: %d", engineType);
}
applyNonPersistentConfiguration(logger, engine);
parseUserFsio(PASS_ENGINE_PARAMETER_F);
#if EFI_TUNER_STUDIO
syncTunerStudioCopy();

View File

@ -51,7 +51,7 @@ float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) {
case LE_METHOD_VBATT:
return getVBatt(engine->engineConfiguration);
default:
firmwareError("No value for %d", action);
firmwareError("FSIO unexpected %d", action);
return NAN;
}
}

View File

@ -52,6 +52,16 @@ static LECalculator evalCalc;
static LEElement evalPoolElements[LE_EVAL_POOL_SIZE];
static LEElementPool evalPool(evalPoolElements, LE_EVAL_POOL_SIZE);
#define SYS_ELEMENT_POOL_SIZE 128
#define UD_ELEMENT_POOL_SIZE 128
static LEElement sysElements[SYS_ELEMENT_POOL_SIZE];
LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE);
static LEElement userElements[UD_ELEMENT_POOL_SIZE];
LEElementPool userPool(userElements, UD_ELEMENT_POOL_SIZE);
LEElement * fsioLogics[LE_COMMAND_COUNT] CCM_OPTIONAL;
LENameOrdinalPair::LENameOrdinalPair(le_action_e action, const char *name) {
this->action = action;
this->name = name;
@ -237,7 +247,7 @@ void LECalculator::doJob(Engine *engine, LEElement *element) {
}
break;
case LE_UNDEFINED:
firmwareError("Undefined not expected here");
firmwareError("FSIO undefined action");
break;
default:
stack.push(getLEValue(engine, &stack, element->action));
@ -250,6 +260,10 @@ float LECalculator::getValue2(LEElement *element, Engine *engine) {
}
float LECalculator::getValue(Engine *engine) {
if (first == NULL) {
warning(OBD_PCM_Processor_Fault, "no FSIO code");
return NAN;
}
LEElement *element = first;
stack.reset();
@ -258,14 +272,16 @@ float LECalculator::getValue(Engine *engine) {
doJob(engine, element);
element = element->next;
}
efiAssert(stack.size() == 1, "One value expected on stack", NAN);
if (stack.size() != 1) {
warning(OBD_PCM_Processor_Fault, "unexpected FSIO stack size: %d", stack.size());
return NAN;
}
return stack.pop();
}
LEElementPool::LEElementPool(LEElement *pool, int size) {
this->pool = pool;
this->size = size;
this->capacity = capacity;
reset();
}
@ -273,8 +289,12 @@ void LEElementPool::reset() {
index = 0;
}
int LEElementPool::getSize() {
return index;
}
LEElement *LEElementPool::next() {
if (index == size - 1) {
if (index == capacity - 1) {
// todo: this should not be a fatal error, just an error
firmwareError("LE_ELEMENT_POOL_SIZE overflow");
return NULL;
@ -375,9 +395,27 @@ static void eval(char *line, Engine *engine) {
}
}
EXTERN_ENGINE;
void initEval(Engine *engine) {
initLogging(&logger, "le");
addConsoleActionSP("eval", (VoidCharPtrVoidPtr) eval, engine);
}
#endif
void parseUserFsio(DECLARE_ENGINE_PARAMETER_F) {
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
brain_pin_e brainPin = boardConfiguration->fsioPins[i];
if (brainPin != GPIO_UNASSIGNED) {
const char *formula = boardConfiguration->le_formulas[i];
LEElement *logic = userPool.parseExpression(formula);
if (logic == NULL) {
warning(OBD_PCM_Processor_Fault, "parsing [%s]", formula);
}
fsioLogics[i] = logic;
}
}
}

View File

@ -69,9 +69,10 @@ public:
LEElement *next();
void reset();
LEElement * parseExpression(const char * line);
int getSize();
private:
int index;
int size;
int capacity;
};
@ -112,5 +113,6 @@ const char *getNextToken(const char *line, char *buffer);
bool isNumeric(const char* line);
le_action_e parseAction(const char * line);
void initEval(Engine *engine);
void parseUserFsio(DECLARE_ENGINE_PARAMETER_F);
#endif /* LOGIC_EXPRESSION_H_ */

View File

@ -57,12 +57,6 @@
#include "pin_repository.h"
#include "pwm_generator.h"
#define LE_ELEMENT_POOL_SIZE 256
static LECalculator calc;
static LEElement mainPool[LE_ELEMENT_POOL_SIZE];
static LEElementPool lePool(mainPool, LE_ELEMENT_POOL_SIZE);
static LEElement * acRelayLogic;
static LEElement * fuelPumpLogic;
static LEElement * radiatorFanLogic;
@ -72,7 +66,10 @@ extern OutputPin outputs[IO_PIN_COUNT];
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
extern bool hasFirmwareErrorFlag;
static LEElement * fsioLogics[LE_COMMAND_COUNT] CCM_OPTIONAL;
extern LEElementPool sysPool;
extern LEElementPool userPool;
static SimplePwm fsioPwm[LE_COMMAND_COUNT] CCM_OPTIONAL;
persistent_config_container_s persistentState CCM_OPTIONAL;
@ -198,7 +195,10 @@ static void cylinderCleanupControl(Engine *engine) {
}
}
static void handleGpio(Engine *engine, int index) {
static LECalculator calc;
extern LEElement * fsioLogics[LE_COMMAND_COUNT];
static void handleFsio(Engine *engine, int index) {
if (boardConfiguration->fsioPins[index] == GPIO_UNASSIGNED)
return;
@ -251,7 +251,7 @@ static void onEvenyGeneralMilliseconds(Engine *engine) {
engine->updateSlowSensors();
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
handleGpio(engine, i);
handleFsio(engine, i);
}
#if EFI_FUEL_PUMP
@ -326,6 +326,22 @@ static void printAnalogInfo(void) {
static THD_WORKING_AREA(csThreadStack, UTILITY_THREAD_STACK_SIZE); // declare thread stack
static void showFsio(const char *msg, LEElement *element) {
scheduleMsg(&logger, "%s:", msg);
while (element != NULL) {
scheduleMsg(&logger, "action %d: fValue=%f iValue=%d", element->action, element->fValue, element->iValue);
element = element->next;
}
scheduleMsg(&logger, "<end>");
}
static void showFsioInfo(void) {
scheduleMsg(&logger, "sys used %d/user used %d", sysPool.getSize(), userPool.getSize());
showFsio("ac", acRelayLogic);
showFsio("fuel", fuelPumpLogic);
}
static void setFsioFrequency(int index, int frequency) {
index--;
if (index < 0 || index > LE_COMMAND_COUNT) {
@ -489,12 +505,12 @@ void initEngineContoller(Engine *engine) {
#endif
#if EFI_FUEL_PUMP
fuelPumpLogic = lePool.parseExpression(FUEL_PUMP_LOGIC);
fuelPumpLogic = sysPool.parseExpression(FUEL_PUMP_LOGIC);
#endif
acRelayLogic = lePool.parseExpression(AC_RELAY_LOGIC);
acRelayLogic = sysPool.parseExpression(AC_RELAY_LOGIC);
alternatorLogic = lePool.parseExpression(ALTERNATOR_LOGIC);
alternatorLogic = sysPool.parseExpression(ALTERNATOR_LOGIC);
addConsoleAction("analoginfo", printAnalogInfo);
@ -502,15 +518,6 @@ void initEngineContoller(Engine *engine) {
brain_pin_e brainPin = boardConfiguration->fsioPins[i];
if (brainPin != GPIO_UNASSIGNED) {
const char *formula = boardConfiguration->le_formulas[i];
LEElement *logic = lePool.parseExpression(formula);
if (logic == NULL) {
warning(OBD_PCM_Processor_Fault, "parsing [%s]", formula);
}
fsioLogics[i] = logic;
//mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
io_pin_e pin = (io_pin_e) ((int) GPIO_0 + i);
@ -532,5 +539,7 @@ void initEngineContoller(Engine *engine) {
addConsoleActionSS("set_int", (VoidCharPtrCharPtr) setInt);
addConsoleActionI("get_float", getFloat);
addConsoleActionI("get_int", getInt);
addConsoleAction("fsioinfo", showFsioInfo);
initEval(engine);
}