auto-sync

This commit is contained in:
rusEfi 2015-01-15 15:03:51 -06:00
parent 8e4890bff2
commit c5e639582c
22 changed files with 191 additions and 173 deletions

View File

@ -159,9 +159,9 @@ void print(const char *format, ...) {
#endif /* EFI_UART_ECHO_TEST_MODE */
}
void initializeConsole(void) {
void initializeConsole(Logging *sharedLogger) {
initIntermediateLoggingBuffer();
initConsoleLogic();
initConsoleLogic(sharedLogger);
startConsole(&handleConsoleLine);

View File

@ -10,13 +10,16 @@
#ifndef RFICONSOLE_H_
#define RFICONSOLE_H_
#include "datalogging.h"
void initializeConsole(Logging *sharedLogger);
void print(const char *fmt, ...);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
void initializeConsole(void);
void print(const char *fmt, ...);
#ifdef __cplusplus
}

View File

@ -41,8 +41,6 @@ extern WaveChart waveChart;
#include "efiGpio.h"
static LoggingWithStorage logger;
extern engine_pins_s enginePins;
static const char *sparkNames[ENGINE_CHANNEL_COUNT] = { "spa1", "spa2", "spa3", "spa4", "spa5", "spa6", "spa7", "spa8",
@ -52,7 +50,6 @@ static const char *injectorNames[ENGINE_CHANNEL_COUNT] = { "inj1", "inj2", "inj3
"inj10", "inj11", "inj12"};
void initSignalExecutor(void) {
initLogging(&logger, "s exec");
initSignalExecutorImpl();
for (int i = 0; i < ENGINE_CHANNEL_COUNT;i++) {

View File

@ -25,9 +25,12 @@ static LENameOrdinalPair leVBatt(LE_METHOD_VBATT, "vbatt");
static LENameOrdinalPair leFan(LE_METHOD_FAN, "fan");
static LENameOrdinalPair leCoolant(LE_METHOD_COOLANT, "coolant");
static LENameOrdinalPair leAcToggle(LE_METHOD_AC_TOGGLE, "ac_on_switch");
static LENameOrdinalPair leFanOnSetting(LE_METHOD_FAN_ON_SETTING, "fan_on_setting");
static LENameOrdinalPair leFanOffSetting(LE_METHOD_FAN_OFF_SETTING, "fan_off_setting");
static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT, "time_since_boot");
static LENameOrdinalPair leFanOnSetting(LE_METHOD_FAN_ON_SETTING,
"fan_on_setting");
static LENameOrdinalPair leFanOffSetting(LE_METHOD_FAN_OFF_SETTING,
"fan_off_setting");
static LENameOrdinalPair leTimeSinceBoot(LE_METHOD_TIME_SINCE_BOOT,
"time_since_boot");
static LENameOrdinalPair leFsioSsetting(LE_METHOD_FSIO_SETTING, "fsio_setting");
#define LE_EVAL_POOL_SIZE 32
@ -53,7 +56,8 @@ static LEElement * fuelPumpLogic;
static LEElement * radiatorFanLogic;
static LEElement * alternatorLogic;
EXTERN_ENGINE;
EXTERN_ENGINE
;
#if EFI_PROD_CODE || EFI_SIMULATOR
static Logging *logger;
@ -111,8 +115,8 @@ static void setFsioPin(const char *indexStr, const char *pinName) {
}
#endif
void setFsioExt(engine_configuration_s *engineConfiguration, int index, brain_pin_e pin, const char * exp, int freq) {
void setFsioExt(engine_configuration_s *engineConfiguration, int index,
brain_pin_e pin, const char * exp, int freq) {
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
boardConfiguration->fsioPins[index] = pin;
@ -120,7 +124,8 @@ void setFsioExt(engine_configuration_s *engineConfiguration, int index, brain_pi
boardConfiguration->fsioFrequency[index] = freq;
}
void setFsio(engine_configuration_s *engineConfiguration, int index, brain_pin_e pin, const char * exp) {
void setFsio(engine_configuration_s *engineConfiguration, int index,
brain_pin_e pin, const char * exp) {
setFsioExt(engineConfiguration, index, pin, exp, 0);
}
@ -150,44 +155,44 @@ extern LEElement * fsioLogics[LE_COMMAND_COUNT];
// that's crazy, but what's an alternative? we need const char *, a shared buffer would not work for pin repository
static const char *getGpioPinName(int index) {
switch (index) {
case 0:
return "GPIO_0";
case 1:
return "GPIO_1";
case 10:
return "GPIO_10";
case 11:
return "GPIO_11";
case 12:
return "GPIO_12";
case 13:
return "GPIO_13";
case 14:
return "GPIO_14";
case 15:
return "GPIO_15";
case 2:
return "GPIO_2";
case 3:
return "GPIO_3";
case 4:
return "GPIO_4";
case 5:
return "GPIO_5";
case 6:
return "GPIO_6";
case 7:
return "GPIO_7";
case 8:
return "GPIO_8";
case 9:
return "GPIO_9";
}
return NULL;
switch (index) {
case 0:
return "GPIO_0";
case 1:
return "GPIO_1";
case 10:
return "GPIO_10";
case 11:
return "GPIO_11";
case 12:
return "GPIO_12";
case 13:
return "GPIO_13";
case 14:
return "GPIO_14";
case 15:
return "GPIO_15";
case 2:
return "GPIO_2";
case 3:
return "GPIO_3";
case 4:
return "GPIO_4";
case 5:
return "GPIO_5";
case 6:
return "GPIO_6";
case 7:
return "GPIO_7";
case 8:
return "GPIO_8";
case 9:
return "GPIO_9";
}
return NULL;
}
static OutputPin fsioPins[LE_COMMAND_COUNT];
static OutputPin fsioOutputs[LE_COMMAND_COUNT];
static void handleFsio(Engine *engine, int index) {
if (boardConfiguration->fsioPins[index] == GPIO_UNASSIGNED)
@ -202,14 +207,15 @@ static void handleFsio(Engine *engine, int index) {
fsioPwm[index].setSimplePwmDutyCycle(fvalue);
} else {
int value = (int) fvalue;
if (value != fsioPins[index].getLogicValue()) {
if (value != fsioOutputs[index].getLogicValue()) {
// scheduleMsg(logger, "setting %s %s", getIo_pin_e(pin), boolToString(value));
fsioPins[index].setValue(value);
fsioOutputs[index].setValue(value);
}
}
}
static void setPinState(const char * msg, OutputPin *pin, LEElement *element, Engine *engine) {
static void setPinState(const char * msg, OutputPin *pin, LEElement *element,
Engine *engine) {
if (element == NULL) {
warning(OBD_PCM_Processor_Fault, "invalid expression for %s", msg);
} else {
@ -227,14 +233,16 @@ static void showFsio(const char *msg, LEElement *element) {
if (msg != NULL)
scheduleMsg(logger, "%s:", msg);
while (element != NULL) {
scheduleMsg(logger, "action %d: fValue=%f iValue=%d", element->action, element->fValue, element->iValue);
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());
scheduleMsg(logger, "sys used %d/user used %d", sysPool.getSize(),
userPool.getSize());
showFsio("a/c", acRelayLogic);
showFsio("fuel", fuelPumpLogic);
showFsio("fan", radiatorFanLogic);
@ -248,7 +256,8 @@ static void showFsioInfo(void) {
* is the fact that the target audience is more software developers
*/
scheduleMsg(logger, "FSIO #%d [%s] at %s@%dHz value=%f", i, exp,
hwPortname(boardConfiguration->fsioPins[i]), boardConfiguration->fsioFrequency[i],
hwPortname(boardConfiguration->fsioPins[i]),
boardConfiguration->fsioFrequency[i],
engineConfiguration2->fsioLastValue[i]);
// scheduleMsg(logger, "user-defined #%d value=%f", i, engine->engineConfiguration2->fsioLastValue[i]);
showFsio(NULL, fsioLogics[i]);
@ -282,10 +291,12 @@ static void setFsioFrequency(int index, int frequency) {
return;
}
boardConfiguration->fsioFrequency[index] = frequency;
scheduleMsg(logger, "Setting FSIO frequency %d on #%d", frequency, index + 1);
scheduleMsg(logger, "Setting FSIO frequency %d on #%d", frequency,
index + 1);
}
static void setUserOutput(const char *indexStr, const char *quotedLine, Engine *engine) {
static void setUserOutput(const char *indexStr, const char *quotedLine,
Engine *engine) {
int index = atoi(indexStr) - 1;
if (index < 0 || index >= LE_COMMAND_COUNT) {
scheduleMsg(logger, "invalid index %d", index);
@ -317,14 +328,14 @@ static void eval(char *line, Engine *engine) {
}
}
void runFsio(void) {
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
handleFsio(engine, i);
}
#if EFI_FUEL_PUMP
if (boardConfiguration->fuelPumpPin != GPIO_UNASSIGNED && engineConfiguration->isFuelPumpEnabled) {
if (boardConfiguration->fuelPumpPin != GPIO_UNASSIGNED
&& engineConfiguration->isFuelPumpEnabled) {
setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic, engine);
}
#endif
@ -337,13 +348,13 @@ void runFsio(void) {
enginePins.o2heater.setValue(engine->rpmCalculator.isRunning());
if (boardConfiguration->acRelayPin != GPIO_UNASSIGNED) {
setPinState("A/C", &enginePins.acRelay, acRelayLogic, engine);
}
if (boardConfiguration->alternatorControlPin != GPIO_UNASSIGNED) {
setPinState("alternator", &enginePins.alternatorField, alternatorLogic, engine);
setPinState("alternator", &enginePins.alternatorField, alternatorLogic,
engine);
}
if (boardConfiguration->fanPin != GPIO_UNASSIGNED) {
@ -371,22 +382,29 @@ void initFsioImpl(Logging *sharedLogger, Engine *engine) {
brain_pin_e brainPin = boardConfiguration->fsioPins[i];
if (brainPin != GPIO_UNASSIGNED) {
//mySetPadMode2("user-defined", boardConfiguration->gpioPins[i], PAL_STM32_MODE_OUTPUT);
int frequency = boardConfiguration->fsioFrequency[i];
if (frequency == 0) {
outputPinRegisterExt2(getGpioPinName(i), &fsioPins[i], boardConfiguration->fsioPins[i], &defa);
outputPinRegisterExt2(getGpioPinName(i), &fsioOutputs[i],
boardConfiguration->fsioPins[i], &defa);
} else {
startSimplePwmExt(&fsioPwm[i], "FSIO", brainPin, &fsioPins[i], frequency, 0.5f, applyPinState);
startSimplePwmExt(&fsioPwm[i], "FSIO", brainPin, &fsioOutputs[i],
frequency, 0.5f, applyPinState);
}
}
}
for (int i = 0; i < LE_COMMAND_COUNT; i++) {
brain_pin_e inputPin = engineConfiguration->fsioInpus[i];
if (inputPin != GPIO_UNASSIGNED) {
}
}
#endif /* EFI_PROD_CODE */
addConsoleActionSSP("set_fsio", (VoidCharPtrCharPtrVoidPtr) setUserOutput, engine);
addConsoleActionSSP("set_fsio", (VoidCharPtrCharPtrVoidPtr) setUserOutput,
engine);
addConsoleActionSS("set_fsio_pin", (VoidCharPtrCharPtr) setFsioPin);
addConsoleActionII("set_fsio_frequency", (VoidIntInt) setFsioFrequency);
addConsoleActionFF("set_fsio_setting", setFsioSetting);

View File

@ -12,7 +12,7 @@
#include "engine_configuration.h"
#include "engine.h"
#define FLASH_DATA_VERSION 6385
#define FLASH_DATA_VERSION 6395
void readFromFlash(void);
void initFlash(Logging *sharedLogger, Engine *engine);

View File

@ -1,5 +1,5 @@
/**
* @file signal_executor_sleep.c
* @file signal_executor_sleep.cpp
* @brief Asynchronous output signal code
*
* Here we have the simplest, thread-based implementation of signal executor.
@ -24,6 +24,7 @@
#include "main.h"
#include "scheduler.h"
#include "signal_executor.h"
#if EFI_SIGNAL_EXECUTOR_SLEEP || defined(__DOXYGEN__)

View File

@ -1,8 +1,8 @@
SYSTEMSRC = \
$(PROJECT_DIR)/controllers/system/signal_executor_sleep.c
SYSTEMSRC =
SYSTEMSRC_CPP = $(PROJECT_DIR)/controllers/system/pwm_generator_logic.cpp \
$(PROJECT_DIR)/controllers/system/signal_executor_sleep.cpp \
$(PROJECT_DIR)/controllers/system/event_queue.cpp \
$(PROJECT_DIR)/controllers/system/efiGpio.cpp \
$(PROJECT_DIR)/controllers/system/SingleTimerExecutor.cpp

View File

@ -38,7 +38,7 @@ static volatile uint64_t previousShaftEventTimeNt = (efitimems_t) -10 * US2NT(US
TriggerCentral triggerCentral;
static LoggingWithStorage logger;
static Logging *logger;
uint64_t getCrankEventCounter() {
return triggerCentral.triggerState.getTotalEventCounter();
@ -202,7 +202,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR
void printAllCallbacksHistogram(void) {
#if EFI_PROD_CODE
printHistogram(&logger, &triggerCallback);
printHistogram(logger, &triggerCallback);
#endif
}
@ -212,7 +212,7 @@ static void triggerShapeInfo(Engine *engine) {
#if EFI_PROD_CODE || EFI_SIMULATOR
TriggerShape *s = &engine->triggerShape;
for (int i = 0; i < s->getSize(); i++) {
scheduleMsg(&logger, "event %d %f", i, s->eventAngles[i]);
scheduleMsg(logger, "event %d %f", i, s->eventAngles[i]);
}
#endif
}
@ -229,60 +229,60 @@ void triggerInfo(Engine *engine) {
TriggerShape *ts = &engine->triggerShape;
scheduleMsg(&logger, "Template %s (%d) trigger %s (%d)",
scheduleMsg(logger, "Template %s (%d) trigger %s (%d)",
getConfigurationName(engineConfiguration->engineType),
engineConfiguration->engineType,
getTrigger_type_e(engineConfiguration->triggerConfig.triggerType),
engineConfiguration->triggerConfig.triggerType);
scheduleMsg(&logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0),
scheduleMsg(logger, "trigger event counters %d/%d/%d/%d", triggerCentral.getHwEventCounter(0),
triggerCentral.getHwEventCounter(1), triggerCentral.getHwEventCounter(2),
triggerCentral.getHwEventCounter(3));
scheduleMsg(&logger, "expected cycle events %d/%d/%d", ts->expectedEventCount[0],
scheduleMsg(logger, "expected cycle events %d/%d/%d", ts->expectedEventCount[0],
engine->triggerShape.expectedEventCount[1], ts->expectedEventCount[2]);
scheduleMsg(&logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->triggerConfig.triggerType,
scheduleMsg(logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->triggerConfig.triggerType,
boolToString(engineConfiguration->needSecondTriggerInput));
scheduleMsg(&logger, "expected duty #0=%f/#1=%f", ts->dutyCycle[0], ts->dutyCycle[1]);
scheduleMsg(logger, "expected duty #0=%f/#1=%f", ts->dutyCycle[0], ts->dutyCycle[1]);
scheduleMsg(&logger, "isError %s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
scheduleMsg(logger, "isError %s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
boolToString(isTriggerDecoderError()), triggerCentral.triggerState.totalTriggerErrorCounter,
triggerCentral.triggerState.orderingErrorCounter, triggerCentral.triggerState.getTotalRevolutionCounter(),
boolToString(engineConfiguration->directSelfStimulation));
if (ts->isSynchronizationNeeded) {
scheduleMsg(&logger, "gap from %f to %f", ts->syncRatioFrom, ts->syncRatioTo);
scheduleMsg(logger, "gap from %f to %f", ts->syncRatioFrom, ts->syncRatioTo);
}
#endif
#if EFI_PROD_CODE
scheduleMsg(&logger, "sn=%s ignitionMathTime=%d schTime=%d triggerMaxDuration=%d",
scheduleMsg(logger, "sn=%s ignitionMathTime=%d schTime=%d triggerMaxDuration=%d",
boolToString(ts->isSynchronizationNeeded), engine->ignitionMathTime, engine->ignitionSchTime,
triggerMaxDuration);
triggerMaxDuration = 0;
scheduleMsg(&logger, "maxLockTime=%d / maxTriggerReentraint=%d", maxLockTime, maxTriggerReentraint);
scheduleMsg(&logger, "maxEventQueueTime=%d", maxEventQueueTime);
scheduleMsg(logger, "maxLockTime=%d / maxTriggerReentraint=%d", maxLockTime, maxTriggerReentraint);
scheduleMsg(logger, "maxEventQueueTime=%d", maxEventQueueTime);
scheduleMsg(&logger, "primary trigger simulator: %s %s freq=%d",
scheduleMsg(logger, "primary trigger simulator: %s %s freq=%d",
hwPortname(boardConfiguration->triggerSimulatorPins[0]),
getPin_output_mode_e(boardConfiguration->triggerSimulatorPinModes[0]),
boardConfiguration->triggerSimulatorFrequency);
scheduleMsg(&logger, "secondary trigger simulator: %s %s phase=%d",
scheduleMsg(logger, "secondary trigger simulator: %s %s phase=%d",
hwPortname(boardConfiguration->triggerSimulatorPins[1]),
getPin_output_mode_e(boardConfiguration->triggerSimulatorPinModes[1]), triggerSignal.safe.phaseIndex);
scheduleMsg(&logger, "3rd trigger simulator: %s %s", hwPortname(boardConfiguration->triggerSimulatorPins[2]),
scheduleMsg(logger, "3rd trigger simulator: %s %s", hwPortname(boardConfiguration->triggerSimulatorPins[2]),
getPin_output_mode_e(boardConfiguration->triggerSimulatorPinModes[2]));
scheduleMsg(&logger, "trigger error extra LED: %s %s", hwPortname(boardConfiguration->triggerErrorPin),
scheduleMsg(logger, "trigger error extra LED: %s %s", hwPortname(boardConfiguration->triggerErrorPin),
getPin_output_mode_e(boardConfiguration->triggerErrorPinMode));
scheduleMsg(&logger, "primary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[0]));
scheduleMsg(&logger, "secondary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[1]));
scheduleMsg(&logger, "primary logic input: %s", hwPortname(boardConfiguration->logicAnalyzerPins[0]));
scheduleMsg(&logger, "secondary logic input: %s", hwPortname(boardConfiguration->logicAnalyzerPins[1]));
scheduleMsg(logger, "primary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[0]));
scheduleMsg(logger, "secondary trigger input: %s", hwPortname(boardConfiguration->triggerInputPins[1]));
scheduleMsg(logger, "primary logic input: %s", hwPortname(boardConfiguration->logicAnalyzerPins[0]));
scheduleMsg(logger, "secondary logic input: %s", hwPortname(boardConfiguration->logicAnalyzerPins[1]));
#endif /* EFI_PROD_CODE */
}
@ -291,7 +291,8 @@ float getTriggerDutyCycle(int index) {
return triggerCentral.triggerState.getTriggerDutyCycle(index);
}
void initTriggerCentral(Engine *engine) {
void initTriggerCentral(Logging *sharedLogger, Engine *engine) {
logger = sharedLogger;
strcpy((char*) shaft_signal_msg_index, "x_");
#if EFI_WAVE_CHART
@ -299,7 +300,6 @@ void initTriggerCentral(Engine *engine) {
#endif /* EFI_WAVE_CHART */
#if EFI_PROD_CODE || EFI_SIMULATOR
initLogging(&logger, "ShaftPosition");
addConsoleActionP("triggerinfo", (VoidPtr) triggerInfo, engine);
addConsoleActionP("triggershapeinfo", (VoidPtr) triggerShapeInfo, engine);
#endif

View File

@ -39,18 +39,10 @@ uint64_t getCrankEventCounter(void);
uint64_t getStartOfRevolutionIndex(void);
void hwHandleShaftSignal(trigger_event_e signal);
float getTriggerDutyCycle(int index);
void initTriggerCentral(Engine *engine);
void initTriggerCentral(Logging *sharedLogger, Engine *engine);
void printAllCallbacksHistogram(void);
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void addTriggerEventListener(ShaftPositionListener handler, const char *name, Engine *engine);
int isSignalDecoderError(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* TRIGGER_CENTRAL_H_ */

View File

@ -98,7 +98,7 @@ void initEngineEmulator(Logging *sharedLogger, Engine *engine) {
return;
#if EFI_POTENTIOMETER
initPotentiometers(&engine->engineConfiguration->bc);
initPotentiometers(sharedLogger, &engine->engineConfiguration->bc);
#endif /* EFI_POTENTIOMETER */
//initECUstimulator();

View File

@ -40,7 +40,7 @@
/* Low speed SPI configuration (281.250kHz, CPHA=0, CPOL=0, MSb first).*/
#define SPI_POT_CONFIG SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_DFF
static LoggingWithStorage logger;
static Logging * logger;
#if EFI_POTENTIOMETER || defined(__DOXYGEN__)
Mcp42010Driver config[DIGIPOT_COUNT];
@ -69,17 +69,7 @@ static void sendToPot(Mcp42010Driver *driver, int channel, int value) {
void setPotResistance(Mcp42010Driver *driver, int channel, int resistance) {
int value = getPotStep(resistance);
Logging *logging = &logger;
resetLogging(logging);
appendPrintf(logging, "msg");
appendPrintf(logging, DELIMETER);
appendPrintf(logging, "Sending to potentiometer%d", channel);
appendPrintf(&logger, ": ");
appendPrintf(&logger, "%d for R=%d", value, resistance);
appendMsgPostfix(logging);
scheduleLogging(logging);
scheduleMsg(logger, "Sending to potentiometer%d: %d for R=%d", channel, value, resistance);
sendToPot(driver, channel, value);
}
@ -93,11 +83,11 @@ static void setPotValue1(int value) {
#endif /* EFI_POTENTIOMETER */
void initPotentiometers(board_configuration_s *boardConfiguration) {
void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfiguration) {
logger = sharedLogger;
#if EFI_POTENTIOMETER
initLogging(&logger, "potentiometer");
if (boardConfiguration->digitalPotentiometerSpiDevice == SPI_NONE) {
scheduleMsg(&logger, "digiPot spi disabled");
scheduleMsg(logger, "digiPot spi disabled");
return;
}
turnOnSpi(boardConfiguration->digitalPotentiometerSpiDevice);

View File

@ -21,7 +21,7 @@ typedef struct {
} Mcp42010Driver;
//void initPotentiometer(Mcp42010Driver *driver, SPIDriver *spi, ioportid_t port, ioportmask_t pin);
void initPotentiometers(board_configuration_s *boardConfiguration);
void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfiguration);
void setPotResistance(Mcp42010Driver *driver, int channel, int resistance);
#endif

View File

@ -272,7 +272,7 @@ void initHardware(Logging *l, Engine *engine) {
// requestAdcValue(&adcState, 0);
// todo: figure out better startup logic
initTriggerCentral(engine);
initTriggerCentral(sharedLogger, engine);
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
initShaftPositionInputCapture();

View File

@ -189,6 +189,19 @@ void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t m
palSetPadMode(port, pin, mode);
}
void unmarkPin(brain_pin_e brainPin) {
ioportid_t port = getHwPort(brainPin);
ioportmask_t pin = getHwPin(brainPin);
int portIndex = getPortIndex(port);
int index = portIndex * 16 + pin;
if (PIN_USED[index] != NULL) {
PIN_USED[index] = NULL;
totalPinsUsed--;
}
}
/**
* This method would crash the program if pin is already in use
*/

View File

@ -17,8 +17,6 @@ extern "C"
#include "global.h"
#include "eficonsole.h"
#include "cli_registry.h"
#include "efilib.h"
#include "rusefi.h"
@ -27,7 +25,9 @@ extern "C"
#include "rusefi_enums.h"
#ifdef __cplusplus
#include "cli_registry.h"
#include "datalogging.h"
#include "eficonsole.h"
#endif
#include "chprintf.h"

View File

@ -151,7 +151,7 @@ void runRusEfi(void) {
/**
* Next we should initialize serial port console, it's important to know what's going on
*/
initializeConsole();
initializeConsole(&sharedLogger);
initLogging(&sharedLogger, "main");
engine->init();
@ -253,7 +253,7 @@ void firmwareError(const char *fmt, ...) {
}
}
static char UNUSED_RAM_SIZE[6500];
static char UNUSED_RAM_SIZE[7500];
static char UNUSED_CCM_SIZE[8000] CCM_OPTIONAL;

View File

@ -27,9 +27,10 @@
#if ! EFI_UNIT_TEST
#include "eficonsole.h"
static LoggingWithStorage logging;
#endif /* ! EFI_UNIT_TEST */
static Logging * logging;
static int consoleActionCount = 0;
static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS];
@ -155,10 +156,10 @@ void helpCommand(void) {
#endif /* EFI_PROD_CODE */
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
scheduleMsg(&logging, "%d actions available", consoleActionCount);
scheduleMsg(logging, "%d actions available", consoleActionCount);
for (int i = 0; i < consoleActionCount; i++) {
TokenCallback *current = &consoleActions[i];
scheduleMsg(&logging, " %s: %d parameters", current->token, getParameterCount(current->parameterType));
scheduleMsg(logging, " %s: %d parameters", current->token, getParameterCount(current->parameterType));
}
#endif
}
@ -306,7 +307,7 @@ void handleActionWithParameter(TokenCallback *current, char *parameter) {
int value1 = atoi(parameter);
if (absI(value1) == ERROR_CODE) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
scheduleMsg(&logging, "not an integer [%s]", parameter);
scheduleMsg(logging, "not an integer [%s]", parameter);
#endif
return;
}
@ -314,7 +315,7 @@ void handleActionWithParameter(TokenCallback *current, char *parameter) {
int value2 = atoi(parameter);
if (absI(value2) == ERROR_CODE) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
scheduleMsg(&logging, "not an integer [%s]", parameter);
scheduleMsg(logging, "not an integer [%s]", parameter);
#endif
return;
}
@ -384,10 +385,8 @@ int tokenLength(const char *msgp) {
return result;
}
void initConsoleLogic() {
#if EFI_PROD_CODE || EFI_SIMULATOR
initLogging(&logging, "rfi console");
#endif /* EFI_PROD_CODE */
void initConsoleLogic(Logging *sharedLogger) {
logging = sharedLogger;
resetConsoleActions();
addConsoleAction("help", helpCommand);
addConsoleActionI("echo", echo);
@ -466,7 +465,7 @@ static bool handleConsoleLineInternal(char *line, int lineLength) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
static void sendOutConfirmation(const char *command, int length) {
scheduleMsg(&logging, "%s%d", command, length);
scheduleMsg(logging, "%s%d", command, length);
}
#endif

View File

@ -9,6 +9,8 @@
#ifndef RFICONSOLE_LOGIC_H_
#define RFICONSOLE_LOGIC_H_
#include "datalogging.h"
#ifdef __cplusplus
extern "C"
{
@ -67,7 +69,7 @@ typedef void (*VoidCharPtrCharPtrCharPtrCharPtrCharPtr)(const char *, const char
char *validateSecureLine(char *line);
void resetConsoleActions(void);
void helpCommand(void);
void initConsoleLogic(void);
void initConsoleLogic(Logging *sharedLogger);
void handleConsoleLine(char *line);
int findEndOfToken(const char *line);
char *unquote(char *line);

View File

@ -8,7 +8,7 @@
#include "data_buffer.h"
#include "main.h"
#if EFI_PROD_CODE
#include "eficonsole.h"
//#include "eficonsole.h"
#endif /* EFI_PROD_CODE */
int dbIsFull(data_buffer_s *db) {
@ -38,33 +38,33 @@ int modp(int param) {
return param > EF_PERIOD ? param - EF_PERIOD : param;
}
void dbPrint(data_buffer_s *db, char *message, int withDiff) {
int s = db->size;
print("buffer [%s] size=%d\r\n", message, s);
int range = db->elements[s - 1] - db->elements[0];
print("range %d\r\n", range);
//void dbPrint(data_buffer_s *db, char *message, int withDiff) {
// int s = db->size;
// print("buffer [%s] size=%d\r\n", message, s);
// int range = db->elements[s - 1] - db->elements[0];
// print("range %d\r\n", range);
//
// for (int i = 0; i < s; i++) {
// print("%d: %d", i, db->elements[i]);
// if (withDiff && i > 0) {
// int diff = modp(db->elements[i]) - modp(db->elements[i - 1]);
// print(" t=%d", diff);
// }
// print("\r\n");
// }
//}
for (int i = 0; i < s; i++) {
print("%d: %d", i, db->elements[i]);
if (withDiff && i > 0) {
int diff = modp(db->elements[i]) - modp(db->elements[i - 1]);
print(" t=%d", diff);
}
print("\r\n");
}
}
void dbPrintTable(data_buffer_s *table[], char *caption[], int columns) {
for (int c = 0; c < columns; c++)
print("%7s", caption[c]);
print("\r\n");
for (int r = 0; r < DB_MAX_SIZE; r++) {
for (int c = 0; c < columns; c++) {
data_buffer_s *buf = table[c];
print("%7d", buf->elements[r]);
}
print("\r\n");
}
}
//void dbPrintTable(data_buffer_s *table[], char *caption[], int columns) {
// for (int c = 0; c < columns; c++)
// print("%7s", caption[c]);
// print("\r\n");
//
// for (int r = 0; r < DB_MAX_SIZE; r++) {
// for (int c = 0; c < columns; c++) {
// data_buffer_s *buf = table[c];
// print("%7d", buf->elements[r]);
// }
// print("\r\n");
// }
//}

View File

@ -2,3 +2,9 @@
#include "global.h"
#define hwPortname(x) "N/A"
#ifdef __cplusplus
#include "datalogging.h"
#include "eficonsole.h"
#include "cli_registry.h"
#endif

View File

@ -10,7 +10,6 @@
#include "error_handling.h"
#include "boards.h"
#include "eficonsole.h"
#include "efilib.h"
#include "efitime.h"
@ -31,7 +30,6 @@
#define CCM_OPTIONAL
#include "cli_registry.h"
#include "rusefi_enums.h"
#define EFI_CUSTOM_PANIC_METHOD 1
@ -57,7 +55,6 @@ extern TestStream testStream;
#endif /* GLOBAL_FT_H_ */
#ifdef __cplusplus
#include "datalogging.h"
extern "C"
{
#endif /* __cplusplus */

View File

@ -66,11 +66,11 @@ float getMap(void) {
}
void rusEfiFunctionalTest(void) {
initializeConsole();
initLogging(&sharedLogger, "simulator");
initializeConsole(&sharedLogger);
initFakeBoard();
initLogging(&sharedLogger, "simulator");
initStatusLoop(engine);
initDataStructures(PASS_ENGINE_PARAMETER_F);
@ -92,7 +92,7 @@ void rusEfiFunctionalTest(void) {
initMainEventListener(&sharedLogger, engine);
initTriggerCentral(engine);
initTriggerCentral(&sharedLogger, engine);
startStatusThreads(engine);
startTunerStudioConnectivity(&sharedLogger);