Merge branch 'master' into bootloader

This commit is contained in:
andreika-git 2017-06-05 20:35:33 +03:00 committed by GitHub
commit c75b6d0932
36 changed files with 679 additions and 260 deletions

View File

@ -45,17 +45,16 @@
*/
#define EFI_WAVE_ANALYZER TRUE
//#define SERIAL_SPEED (8 * 115200)
//#define SERIAL_SPEED (2 * 115200)
//todo: make this configurable via Tuner Studio
//todo: see uartConsoleSerialSpeed
#define SERIAL_SPEED 115200
/**
* TunerStudio support.
*/
#define EFI_TUNER_STUDIO TRUE
/**
* Bluetooth UART setup support.
*/
#define EFI_BLUETOOTH_SETUP FALSE
/**
* TunerStudio debug output
*/

View File

@ -0,0 +1,276 @@
#include "main.h"
#include "engine_state.h"
#include "tunerstudio.h"
#include "tunerstudio_io.h"
#include "bluetooth.h"
#include "engine_configuration.h"
#if EFI_BLUETOOTH_SETUP || defined(__DOXYGEN__)
static bool btProcessIsStarted = false;
static bool btProcessIsRunning = false;
static const char *commands[5];
static int numCommands = 0;
static int setBaudIdx = -1;
static char cmdHello[5];
static char cmdBaud[25];
static char cmdName[30];
static char cmdPin[16];
static const int baudRates[] = { 0, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1 };
static const int baudRateIndexList[] = { 4 /*9600*/, 6 /*38400*/, 8 /*115200*/, 7, 5, 3, 2, 1, -1 };
static const int btModuleTimeout = MS2ST(1000);
static ts_channel_s *tsChannel;
static THD_WORKING_AREA(btThreadStack, UTILITY_THREAD_STACK_SIZE);
static thread_t *btThread = NULL;
static thread_reference_t btThreadRef = NULL; // used by thread suspend/resume as a flag
static LoggingWithStorage btLogger("bluetooth");
EXTERN_ENGINE
;
// Main communication code
// We assume that the user has disconnected the software before starting the code.
static void runCommands() {
uint8_t buffer[2];
if (!btProcessIsStarted)
return;
// Store current serial port speed - we're going to change it
int savedSerialSpeed = boardConfiguration->tunerStudioSerialSpeed;
int prevBaudIdx = -1, baudIdx = -1, baudListIdx = 0;
int cmdIdx = 0;
// run all commands
while (true) {
if (baudIdx < 0) {
// try all available baud rates, in order of preference
baudIdx = baudRateIndexList[baudListIdx++];
// we've tried all baud rates?
if (baudIdx < 0)
break;
}
bool restoreAndExit = (cmdIdx >= numCommands || baudIdx < 0);
// if the baud rate is changed, reinit the UART
if (baudIdx != prevBaudIdx || restoreAndExit) {
// deinit UART
if (!stopTsPort(tsChannel)) {
scheduleMsg(&btLogger, "Failed! Cannot restart serial port connection!");
return;
}
chThdSleepMilliseconds(10); // safety
// change the port speed
boardConfiguration->tunerStudioSerialSpeed = restoreAndExit ? savedSerialSpeed : baudRates[baudIdx];
// init UART
startTsPort(tsChannel);
chThdSleepMilliseconds(10); // safety
prevBaudIdx = baudIdx;
}
// exit if all commands were sent
if (restoreAndExit)
break;
// send current command
sr5WriteData(tsChannel, (uint8_t *)commands[cmdIdx], strlen(commands[cmdIdx]));
// waiting for an answer
bool wasAnswer = false;
if (sr5ReadDataTimeout(tsChannel, buffer, 2, btModuleTimeout) == 2) {
wasAnswer = (buffer[0] == 'O' && buffer[1] == 'K');
}
// wait 1 second and skip all remaining response bytes from the bluetooth module
while (true) {
if (sr5ReadDataTimeout(tsChannel, buffer, 1, btModuleTimeout) < 1)
break;
}
if (wasAnswer) {
// if we changed the baud rate
if (commands[cmdIdx] == cmdBaud) {
// this is what we've set
baudIdx = setBaudIdx;
// if we fail somehow, try all other baud rates
baudListIdx = 0;
}
// move to the next command
cmdIdx++;
} else {
// try other baud rate
baudIdx = -1;
}
}
// the connection is already restored to the current baud rate, so print the result
if (cmdIdx == numCommands)
scheduleMsg(&btLogger, "SUCCESS! All commands (%d of %d) passed to the Bluetooth module!", cmdIdx, numCommands);
else
scheduleMsg(&btLogger, "FAIL! Only %d commands (of %d total) were passed to the Bluetooth module!", cmdIdx, numCommands);
}
static THD_FUNCTION(btThreadEntryPoint, arg) {
(void) arg;
chRegSetThreadName("bluetooth thread");
scheduleMsg(&btLogger, "*** Bluetooth module setup procedure ***");
scheduleMsg(&btLogger, "!Warning! Please make sure you're not currently using the BT module for communication (not paired)!");
scheduleMsg(&btLogger, "TO START THE PROCEDURE: PLEASE DISCONNECT YOUR PC COM-PORT FROM THE BOARD NOW!");
scheduleMsg(&btLogger, "After that please don't turn off the board power and wait for ~15 seconds to complete. Then reconnect to the board!");
// now wait
chSysLock();
msg_t msg = chThdSuspendTimeoutS(&btThreadRef, BLUETOOTH_COMMAND_TIMEOUT);
chSysUnlock();
if (msg == MSG_TIMEOUT) {
scheduleMsg(&btLogger, "The Bluetooth module init procedure is cancelled (timeout)!");
return;
} else {
// call this when the thread is resumed (after the disconnect)
btProcessIsRunning = true;
runCommands();
btProcessIsRunning = false;
}
// release the command
btProcessIsStarted = false;
chThdExit(MSG_OK);
}
void bluetoothStart(ts_channel_s *tsChan, bluetooth_module_e moduleType, const char *baudRate, const char *name, const char *pinCode) {
static const char *usage = "Usage: bluetooth_hc06 <baud> <name> <pincode>";
tsChannel = tsChan;
// if a binary protocol uses USB, we cannot init the bluetooth module!
if (!boardConfiguration->useSerialPort) {
scheduleMsg(&btLogger, "Failed! Serial Port connection is disabled!");
return;
}
if (btProcessIsStarted) {
scheduleMsg(&btLogger, "The Bluetooth module init procedure is already started and waiting! To cancel it, run \"bluetooth_cancel\" command!");
return;
}
numCommands = 0;
// now check the arguments and add other commands:
// 1) baud rate
int baud = (baudRate != NULL) ? atoi(baudRate) : 0;
int i;
// find a known baud rate in our list
setBaudIdx = -1;
for (i = 1; baudRates[i] > 0; i++) {
if (baudRates[i] == baud) {
setBaudIdx = i;
break;
}
}
// check the baud rate index
if (setBaudIdx < 1) {
if (baud == 0)
scheduleMsg(&btLogger, "The <baud> parameter is set to zero! The baud rate won't be set!");
else {
// unknown baud rate
scheduleMsg(&btLogger, "Wrong <baud> parameter '%s'! %s", baudRate, usage);
return;
}
} else {
// ok, add command!
}
// 2) check name
if (name == NULL || strlen(name) < 1 || strlen(name) > 20) {
scheduleMsg(&btLogger, "Wrong <name> parameter! Up to 20 characters expected! %s", usage);
return;
}
// 3) check pin code
int numDigits = 0;
// check the pincode
if (pinCode != NULL && strlen(pinCode) == 4) {
for (i = 0; i < 4; i++) {
if (pinCode[i] >= '0' && pinCode[i] <= '9') // digit
numDigits++;
}
}
if (numDigits != 4) {
scheduleMsg(&btLogger, "Wrong <pincode> parameter! 4 digits expected! %s", usage);
return;
}
// ok, add commands!
switch (moduleType) {
case BLUETOOTH_HC_05:
chsnprintf(cmdHello, sizeof(cmdHello), "AT\r\n");
chsnprintf(cmdBaud, sizeof(cmdBaud), "AT+UART=%d,0,0\r\n", baud); // baud rate, 0=(1 stop bit), 0=(no parity bits)
chsnprintf(cmdName, sizeof(cmdName), "AT+NAME=%s\r\n", name);
chsnprintf(cmdPin, sizeof(cmdPin), "AT+PSWD=%s\r\n", pinCode);
// todo: add more commands?
// AT+RMAAD
// AT+ROLE=0
break;
case BLUETOOTH_HC_06:
chsnprintf(cmdHello, sizeof(cmdHello), "AT");
chsnprintf(cmdBaud, sizeof(cmdBaud), "AT+BAUD%c", '0' + setBaudIdx);
chsnprintf(cmdName, sizeof(cmdName), "AT+NAME%s", name);
chsnprintf(cmdPin, sizeof(cmdPin), "AT+PIN%s", pinCode);
break;
default:
// todo: add support for other BT module types
scheduleMsg(&btLogger, "This Bluetooth module is currently not supported!");
return;
}
commands[numCommands++] = cmdHello; // this command is added to test a connection
commands[numCommands++] = cmdBaud;
commands[numCommands++] = cmdName;
commands[numCommands++] = cmdPin;
// create a thread to execute these commands later
btThread = chThdCreateStatic(btThreadStack, sizeof(btThreadStack), NORMALPRIO, (tfunc_t)btThreadEntryPoint, NULL);
btProcessIsStarted = true;
}
void bluetoothSoftwareDisconnectNotify() {
if (btProcessIsStarted) {
// start communication with the module
chThdResume(&btThreadRef, MSG_OK);
// wait the thread to finish
chThdWait(btThread);
}
}
void bluetoothCancel() {
if (!btProcessIsStarted) {
scheduleMsg(&btLogger, "The Bluetooth module init procedure was not started! Nothing to cancel!");
return;
}
if (btProcessIsRunning)
return;
// terminate thread
chThdTerminate(btThread);
btProcessIsStarted = false;
scheduleMsg(&btLogger, "The Bluetooth module init procedure is cancelled!");
}
#endif /* EFI_BLUETOOTH_SETUP */

View File

@ -0,0 +1,46 @@
/**
* @file tunerstudio.h
*
* @date Aug 26, 2013
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#ifndef BLUETOOTH_H_
#define BLUETOOTH_H_
#include "main.h"
#include "tunerstudio_io.h"
// The Bluetooth setup procedure will wait 10 seconds for the user to disconnect the UART cable.
// This is required because the BT setup procedure reads a response from the module during the communication.
// Thus any bytes sent from the Console Software may interfere with the procedure.
#define BLUETOOTH_COMMAND_TIMEOUT MS2ST(10000)
// Supported Bluetooth module types
typedef enum {
BLUETOOTH_HC_05,
BLUETOOTH_HC_06,
} bluetooth_module_e;
/**
* Start Bluetooth module initialization using UART connection:
* - wait for PC communication disconnect;
* - reconfigure the UART;
* - send AT-commands to the module;
* - restore connection to PC.
*/
void bluetoothStart(ts_channel_s *tsChannel, bluetooth_module_e moduleType, const char *baudRate, const char *name, const char *pinCode);
/**
* Cancel Bluetooth procedure
*/
void bluetoothCancel(void);
/**
* Called by runBinaryProtocolLoop() if a connection disconnect is detected.
* Bluetooth init code needs to make sure that there's no interference of the BT module and USB-UART (connected to PC)
*/
void bluetoothSoftwareDisconnectNotify();
#endif /* BLUETOOTH_H_ */

View File

@ -0,0 +1,38 @@
Bluetooth module setup procedure. User Manual.
To activate your Bluetooth module, you'll need:
1) Connect your PC to the rusEFI board using UART cable.
2) Run "rusEFI Console" software.
3) Turn on the board power and wait for the console connection.
4) Type the following command:
"bluetooth_hc06 <baud> <name> <pincode>"
Where:
- <baud> is the baud rate of the Bluetooth connection. Allowed values are: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.
Please set this to the baud rate currently used by your UART console.
- <name> is the name of your Bluetooth connection. It will be visible in the device list on your PC.
- <pincode> is 4-digit PIN-code needed to authorize the Bluetooth connection to your PC.
Example: "bluetooth_hc06 38400 rusefi 1234"
5) After entering the command the following text will appear:
*** Bluetooth module setup procedure ***
!Warning! Please make sure you're not currently using the BT module for communication (not paired)!
TO START THE PROCEDURE: PLEASE DISCONNECT YOUR PC COM-PORT FROM THE BOARD NOW!
After that please don't turn off the board power and wait for ~15 seconds to complete. Then reconnect to the board!
6) If you ignore this message and do nothing, the Bluetooth secup procedure will be cancelled in 10 seconds.
You can also use "bluetooth_cancel" command to cancel it.
7) If you disconnect the UART cable or close the software, then the procedure will begin.
8) It takes up to 15 seconds to complete. The Bluetooth LED may blink several times during the procedure - it's normal.
9) After that, you may restore the UART connection to your PC or start using Bluetooth module.
*** Developers Section ***
How it works, in two words:
- adds 2 new commands: "bluetooth_hc06(baud, name, pincode)" and "bluetooth_cancel";
- adds stopTsPort() to tunerstudio_io - needed to change the baud rate on fly;
- added bluetoothSoftwareDisconnectNotify() handler to runBinaryProtocolLoop() - to detect UART disconnects;
- added a thread with btThreadEntryPoint():
- It will wait up to 10 seconds for the user to disconnect the UART cable.
This is required because the BT setup procedure reads a response from the module during the communication - using the same UART.
Thus any bytes sent from the Console Software may interfere with the procedure.
- added bluetoothStart() which processes user input and creates a command list;
- added runCommands() where all the Bluetooth magic happens!

View File

@ -73,6 +73,7 @@
#include "console_io.h"
#include "crc.h"
#include "fl_protocol.h"
#include "bluetooth.h"
#include <string.h>
#include "engine_configuration.h"
@ -167,6 +168,17 @@ static void setTsSpeed(int value) {
printTsStats();
}
#if EFI_BLUETOOTH_SETUP || defined(__DOXYGEN__)
// Bluetooth HC-05 module initialization start (it waits for disconnect and then communicates to the module)
static void bluetoothHC05(const char *baudRate, const char *name, const char *pinCode) {
bluetoothStart(&tsChannel, BLUETOOTH_HC_05, baudRate, name, pinCode);
}
// Bluetooth HC-06 module initialization start (it waits for disconnect and then communicates to the module)
static void bluetoothHC06(const char *baudRate, const char *name, const char *pinCode) {
bluetoothStart(&tsChannel, BLUETOOTH_HC_06, baudRate, name, pinCode);
}
#endif /* EFI_BLUETOOTH_SETUP */
void tunerStudioDebug(const char *msg) {
#if EFI_TUNER_STUDIO_VERBOSE || defined(__DOXYGEN__)
scheduleMsg(&tsLogger, "%s", msg);
@ -452,6 +464,10 @@ void runBinaryProtocolLoop(ts_channel_s *tsChannel, bool isConsoleRedirect) {
if (received != 1) {
// tunerStudioError("ERROR: no command");
#if EFI_BLUETOOTH_SETUP || defined(__DOXYGEN__)
// assume there's connection loss and notify the bluetooth init code
bluetoothSoftwareDisconnectNotify();
#endif /* EFI_BLUETOOTH_SETUP */
continue;
}
onDataArrived();
@ -828,6 +844,14 @@ void startTunerStudioConnectivity(void) {
addConsoleAction("tsinfo", printTsStats);
addConsoleAction("reset_ts", resetTs);
addConsoleActionI("set_ts_speed", setTsSpeed);
#if EFI_BLUETOOTH_SETUP || defined(__DOXYGEN__)
// Usage: "bluetooth_hc06 <baud> <name> <pincode>"
// Example: "bluetooth_hc06 38400 rusefi 1234"
addConsoleActionSSS("bluetooth_hc05", bluetoothHC05);
addConsoleActionSSS("bluetooth_hc06", bluetoothHC06);
addConsoleAction("bluetooth_cancel", bluetoothCancel);
#endif /* EFI_BLUETOOTH_SETUP */
chThdCreateStatic(tsThreadStack, sizeof(tsThreadStack), NORMALPRIO, (tfunc_t)tsThreadEntryPoint, NULL);
}

View File

@ -1,3 +1,4 @@
TUNERSTUDIO_SRC_CPP = $(PROJECT_DIR)/console/binary/tunerstudio_io.cpp \
$(PROJECT_DIR)/console/binary/tunerstudio.cpp
$(PROJECT_DIR)/console/binary/tunerstudio.cpp \
$(PROJECT_DIR)/console/binary/bluetooth.cpp

View File

@ -82,6 +82,7 @@ typedef struct {
unsigned int isTriggerError : 1; // bit 5
unsigned int hasFatalError : 1; // bit 6
unsigned int isWarnNow : 1; // bit 7
unsigned int isCltBroken : 1; // bit 8
int tsConfigVersion; // 84
egt_values_s egtValues; // 88
float unusedOffset104; // 104

View File

@ -124,6 +124,36 @@ void startTsPort(ts_channel_s *tsChannel) {
#endif /* EFI_PROD_CODE */
}
bool stopTsPort(ts_channel_s *tsChannel) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#if EFI_USB_SERIAL || defined(__DOXYGEN__)
if (isCommandLineConsoleOverTTL()) {
#if 0
usb_serial_stop();
#endif
// don't stop USB!
return false;
} else
#endif
{
if (boardConfiguration->useSerialPort) {
// todo: disable Rx/Tx pads?
#if TS_UART_DMA_MODE
uartStop(TS_DMA_UART_DEVICE);
#else
sdStop(TS_SERIAL_UART_DEVICE);
#endif /* TS_UART_DMA_MODE */
}
}
tsChannel->channel = (BaseChannel *) NULL;
return true;
#else /* EFI_PROD_CODE */
// don't stop simulator!
return false;
#endif /* EFI_PROD_CODE */
}
void sr5WriteData(ts_channel_s *tsChannel, const uint8_t * buffer, int size) {
efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 64, "tunerStudioWriteData");
#if EFI_SIMULATOR || defined(__DOXYGEN__)

View File

@ -90,6 +90,7 @@ typedef struct {
void startTsPort(ts_channel_s *tsChannel);
bool stopTsPort(ts_channel_s *tsChannel);
// that's 1 second
#define BINARY_IO_TIMEOUT MS2ST(1000)

View File

@ -138,7 +138,7 @@ bool isCommandLineConsoleOverTTL(void) {
}
#if (defined(EFI_CONSOLE_UART_DEVICE) && ! EFI_SIMULATOR ) || defined(__DOXYGEN__)
static SerialConfig serialConfig = { SERIAL_SPEED, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 };
static SerialConfig serialConfig = { 0, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 };
#endif
bool consoleInBinaryMode = false;
@ -256,9 +256,10 @@ void startConsole(Logging *sharedLogger, CommandHandler console_line_callback_p)
if (isCommandLineConsoleOverTTL()) {
/*
* Activates the serial using the driver default configuration (that's 38400)
* Activates the serial
* it is important to set 'NONE' as flow control! in terminal application on the PC
*/
serialConfig.speed = engineConfiguration->uartConsoleSerialSpeed;
sdStart(EFI_CONSOLE_UART_DEVICE, &serialConfig);
// cannot use pin repository here because pin repository prints to console

View File

@ -56,9 +56,6 @@ static void sayHello(void) {
#ifdef CH_FREQUENCY
scheduleMsg(&logger, "CH_FREQUENCY=%d", CH_FREQUENCY);
#endif
#ifdef SERIAL_SPEED
scheduleMsg(&logger, "SERIAL_SPEED=%d", SERIAL_SPEED);
#endif
#ifdef CORTEX_MAX_KERNEL_PRIORITY
scheduleMsg(&logger, "CORTEX_MAX_KERNEL_PRIORITY=%d", CORTEX_MAX_KERNEL_PRIORITY);

View File

@ -432,6 +432,7 @@ static void printInfo(systime_t nowSeconds) {
static systime_t timeOfPreviousReport = (systime_t) -1;
extern fatal_msg_t errorMessageBuffer;
extern bool consoleInBinaryMode;
/**
* @brief Sends all pending data to dev console
@ -442,7 +443,9 @@ void updateDevConsoleState(void) {
}
// looks like this is not needed anymore
// checkIfShouldHalt();
printPending();
if (!consoleInBinaryMode) {
printPending();
}
/**
* this should go before the firmware error so that console can detect connection
@ -731,6 +734,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->firmwareVersion = getRusEfiVersion();
tsOutputChannels->isWarnNow = isWarningNow(now, true);
tsOutputChannels->isCltBroken = engine->isCltBroken;
if (engineConfiguration->debugMode == DBG_TPS_ACCEL) {
tsOutputChannels->debugIntField1 = engine->tpsAccelEnrichment.cb.getSize();

View File

@ -693,6 +693,9 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->cranking.baseFuel = 5;
engineConfiguration->idleRpmPid.pFactor = 0.05;
engineConfiguration->idleRpmPid.iFactor = 0.002;
engineConfiguration->idleRpmPid.minValue = 5;
engineConfiguration->idleRpmPid.maxValue = 95;
boardConfiguration->idlePidDeactivationTpsThreshold = 2;

View File

@ -28,6 +28,7 @@ extern fsio8_Map3D_u8t fsioTable4;
static fsio8_Map3D_u8t * fsio8t_tables[] = {NULL, NULL, &fsioTable2, &fsioTable3, &fsioTable4};
EXTERN_ENGINE;
LENameOrdinalPair * LE_FIRST = NULL;
@ -75,12 +76,6 @@ void LEElement::clear() {
iValue = 0;
}
//void LEElement::init(le_action_e action, int iValue) {
// this->action = action;
// this->iValue = iValue;
//}
void LEElement::init(le_action_e action) {
this->action = action;
}
@ -142,7 +137,7 @@ void LECalculator::push(le_action_e action, float value) {
/**
* @return true in case of error, false otherwise
*/
bool LECalculator::processElement(Engine *engine, LEElement *element) {
bool LECalculator::processElement(LEElement *element DECLARE_ENGINE_PARAMETER_SUFFIX) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
efiAssert(getRemainingStack(chThdGetSelfX()) > 64, "FSIO logic", false);
#endif
@ -258,7 +253,7 @@ bool LECalculator::processElement(Engine *engine, LEElement *element) {
float humanIndex = pop(LE_METHOD_FSIO_SETTING);
int index = (int) humanIndex - 1;
if (index >= 0 && index < LE_COMMAND_COUNT) {
push(element->action, engine->engineConfiguration->bc.fsio_setting[index]);
push(element->action, boardConfiguration->fsio_setting[index]);
} else {
push(element->action, NAN);
}
@ -285,7 +280,7 @@ bool LECalculator::processElement(Engine *engine, LEElement *element) {
}
break;
case LE_METHOD_FSIO_ANALOG_INPUT:
push(element->action, getVoltage("fsio", engine->engineConfiguration->fsioAdc[0]));
push(element->action, getVoltage("fsio", engineConfiguration->fsioAdc[0]));
break;
case LE_METHOD_KNOCK:
push(element->action, engine->knockCount);
@ -294,21 +289,21 @@ bool LECalculator::processElement(Engine *engine, LEElement *element) {
warning(CUSTOM_UNKNOWN_FSIO, "FSIO undefined action");
return true;
default:
push(element->action, getLEValue(engine, &stack, element->action));
push(element->action, getEngineValue(element->action PASS_ENGINE_PARAMETER_SUFFIX));
}
return false;
}
float LECalculator::getValue2(float selfValue, LEElement *fistElementInList, Engine *engine) {
float LECalculator::getValue2(float selfValue, LEElement *fistElementInList DECLARE_ENGINE_PARAMETER_SUFFIX) {
reset(fistElementInList);
return getValue(selfValue, engine);
return getValue(selfValue PASS_ENGINE_PARAMETER_SUFFIX);
}
bool LECalculator::isEmpty() {
return first == NULL;
}
float LECalculator::getValue(float selfValue, Engine *engine) {
float LECalculator::getValue(float selfValue DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (isEmpty()) {
warning(CUSTOM_NO_FSIO, "no FSIO code");
return NAN;
@ -324,7 +319,7 @@ float LECalculator::getValue(float selfValue, Engine *engine) {
if (element->action == LE_METHOD_SELF) {
push(element->action, selfValue);
} else {
bool isError = processElement(engine, element);
bool isError = processElement(element PASS_ENGINE_PARAMETER_SUFFIX);
if (isError) {
// error already reported
return NAN;
@ -432,7 +427,7 @@ LEElement *LEElementPool::parseExpression(const char * line) {
/**
* Cannot recognize token
*/
warning((obd_code_e) 0, "unrecognized [%s]", parsingBuffer);
warning(CUSTOM_ERR_6536, "unrecognized [%s]", parsingBuffer);
return NULL;
}
n->init(action);

View File

@ -52,6 +52,7 @@ typedef enum {
LE_METHOD_FSIO_ANALOG_INPUT = 116,
LE_METHOD_INTAKE_VVT = 117,
LE_METHOD_EXHAUST_VVT = 118,
LE_METHOD_IS_COOLANT_BROKEN = 119,
Force_4b_le_action = ENUM_32_BITS,
@ -95,8 +96,8 @@ typedef FLStack<float, MAX_STACK_DEPTH> calc_stack_t;
class LECalculator {
public:
LECalculator();
float getValue(float selfValue, Engine *engine);
float getValue2(float selfValue, LEElement *fistElementInList, Engine *engine);
float getValue(float selfValue DECLARE_ENGINE_PARAMETER_SUFFIX);
float getValue2(float selfValue, LEElement *fistElementInList DECLARE_ENGINE_PARAMETER_SUFFIX);
void add(LEElement *element);
bool isEmpty();
void reset();
@ -106,7 +107,7 @@ public:
int currentCalculationLogPosition;
private:
void push(le_action_e action, float value);
bool processElement(Engine *engine, LEElement *element);
bool processElement(LEElement *element DECLARE_ENGINE_PARAMETER_SUFFIX);
float pop(le_action_e action);
LEElement *first;
calc_stack_t stack;

View File

@ -33,6 +33,7 @@ static LENameOrdinalPair leMap(LE_METHOD_MAP, "map");
static LENameOrdinalPair leVBatt(LE_METHOD_VBATT, "vbatt");
static LENameOrdinalPair leFan(LE_METHOD_FAN, "fan");
static LENameOrdinalPair leCoolant(LE_METHOD_COOLANT, "coolant");
static LENameOrdinalPair leIsCoolantBroken(LE_METHOD_IS_COOLANT_BROKEN, "is_clt_broken");
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");
@ -73,8 +74,7 @@ EXTERN_ENGINE
#if EFI_PROD_CODE || EFI_SIMULATOR
static Logging *logger;
float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) {
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
efiAssert(engine!=NULL, "getLEValue", NAN);
switch (action) {
case LE_METHOD_FAN:
@ -83,6 +83,8 @@ float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) {
return getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_COOLANT:
return getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_IS_COOLANT_BROKEN:
return engine->isCltBroken;
case LE_METHOD_INTAKE_AIR:
return getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE);
case LE_METHOD_RPM:
@ -261,7 +263,7 @@ static void handleFsio(Engine *engine, int index) {
warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(boardConfiguration->fsioPins[index]));
fvalue = NAN;
} else {
fvalue = calc.getValue2(engine->fsioLastValue[index], fsioLogics[index], engine);
fvalue = calc.getValue2(engine->fsioLastValue[index], fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX);
}
engine->fsioLastValue[index] = fvalue;
@ -298,11 +300,11 @@ static const char * action2String(le_action_e action) {
return buffer;
}
static void setPinState(const char * msg, OutputPin *pin, LEElement *element, Engine *engine) {
static void setPinState(const char * msg, OutputPin *pin, LEElement *element) {
if (element == NULL) {
warning(CUSTOM_OBD_11, "invalid expression for %s", msg);
} else {
int value = (int)calc.getValue2(pin->getLogicValue(), element, engine);
int value = (int)calc.getValue2(pin->getLogicValue(), element PASS_ENGINE_PARAMETER_SUFFIX);
if (pin->isInitialized() && value != pin->getLogicValue()) {
if (isRunningBenchTest()) {
return; // let's not mess with bench testing
@ -339,7 +341,7 @@ void runFsio(void) {
#if EFI_FUEL_PUMP || defined(__DOXYGEN__)
if (boardConfiguration->fuelPumpPin != GPIO_UNASSIGNED) {
setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic, engine);
setPinState("pump", &enginePins.fuelPumpRelay, fuelPumpLogic);
}
#endif /* EFI_FUEL_PUMP */
@ -352,7 +354,7 @@ void runFsio(void) {
enginePins.o2heater.setValue(engine->rpmCalculator.isRunning());
if (boardConfiguration->acRelayPin != GPIO_UNASSIGNED) {
setPinState("A/C", &enginePins.acRelay, acRelayLogic, engine);
setPinState("A/C", &enginePins.acRelay, acRelayLogic);
}
// if (boardConfiguration->alternatorControlPin != GPIO_UNASSIGNED) {
@ -360,7 +362,7 @@ void runFsio(void) {
// }
if (boardConfiguration->fanPin != GPIO_UNASSIGNED) {
setPinState("fan", &enginePins.fanRelay, radiatorFanLogic, engine);
setPinState("fan", &enginePins.fanRelay, radiatorFanLogic);
}
}
@ -465,7 +467,7 @@ static void setFsioExpression(const char *indexStr, const char *quotedLine, Engi
#endif
}
static void rpnEval(char *line, Engine *engine) {
static void rpnEval(char *line) {
#if EFI_PROD_CODE || EFI_SIMULATOR
line = unquote(line);
scheduleMsg(logger, "Parsing [%s]", line);
@ -474,7 +476,7 @@ static void rpnEval(char *line, Engine *engine) {
if (e == NULL) {
scheduleMsg(logger, "parsing failed");
} else {
float result = evalCalc.getValue2(0, e, engine);
float result = evalCalc.getValue2(0, e PASS_ENGINE_PARAMETER_SUFFIX);
scheduleMsg(logger, "Evaluate result: %f", result);
}
#endif
@ -527,11 +529,11 @@ void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
#endif /* EFI_PROD_CODE */
#if EFI_PROD_CODE || EFI_SIMULATOR
addConsoleActionSSP("set_rpn_expression", (VoidCharPtrCharPtrVoidPtr) setFsioExpression, engine);
addConsoleActionSS("set_rpn_expression", (VoidCharPtrCharPtr) setFsioExpression);
addConsoleActionFF("set_fsio_setting", setFsioSetting);
addConsoleAction("fsioinfo", showFsioInfo);
addConsoleActionSP("rpn_eval", (VoidCharPtrVoidPtr) rpnEval, engine);
#endif
addConsoleActionS("rpn_eval", (VoidCharPtr) rpnEval);
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
fsioTable1.init(config->fsioTable1, config->fsioTable1LoadBins,
config->fsioTable1RpmBins);

View File

@ -18,7 +18,7 @@ typedef Map3D<FSIO_TABLE_8, FSIO_TABLE_8, float> fsio8_Map3D_f32t;
typedef Map3D<FSIO_TABLE_8, FSIO_TABLE_8, uint8_t> fsio8_Map3D_u8t;
float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action);
float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX);
void setFsio(int index, brain_pin_e pin, const char * exp DECLARE_ENGINE_PARAMETER_SUFFIX);
void setFsioExt(int index, brain_pin_e pin, const char * exp, int freq DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -171,9 +171,9 @@ void onUnlockHook(void) {
if (lockedDuration > maxLockedDuration) {
maxLockedDuration = lockedDuration;
}
// if (t > 2800) {
// if (lockedDuration > 2800) {
// // un-comment this if you want a nice stop for a breakpoint
// maxLockTime = t + 1;
// maxLockedDuration = lockedDuration + 1;
// }
}

View File

@ -63,7 +63,6 @@ void idleDebug(const char *msg, percent_t value) {
scheduleMsg(logger, "idle debug: %s%f", msg, value);
}
static void showIdleInfo(void) {
const char * idleModeStr = getIdle_mode_e(engineConfiguration->idleMode);
scheduleMsg(logger, "idleMode=%s position=%f isStepper=%s", idleModeStr,
@ -150,14 +149,8 @@ static void undoIdleBlipIfNeeded() {
}
}
static percent_t currentIdleValve = -1;
percent_t getIdlePosition(void) {
if (engineConfiguration->idleMode == IM_AUTO) {
return currentIdleValve;
} else {
return boardConfiguration->manIdlePosition;
}
return currentIdlePosition;
}
static float autoIdle(float cltCorrection) {

View File

@ -39,13 +39,15 @@ EXTERN_ENGINE
static Logging * logger;
static bool isRunningBench = false;
// todo: move into Engine object?
// todo: looks like these flags are not currently used? dead functionality? unfinished functionality?
static int is_injector_enabled[INJECTION_PIN_COUNT];
bool isRunningBenchTest(void) {
return isRunningBench;
}
void assertCylinderId(int cylinderId, const char *msg) {
static void assertCylinderId(int cylinderId, const char *msg) {
int isValid = cylinderId >= 1 && cylinderId <= engineConfiguration->specs.cylindersCount;
if (!isValid) {
// we are here only in case of a fatal issue - at this point it is fine to make some blocking i-o
@ -58,12 +60,12 @@ void assertCylinderId(int cylinderId, const char *msg) {
/**
* @param cylinderId - from 1 to NUMBER_OF_CYLINDERS
*/
int isInjectorEnabled(int cylinderId) {
static int isInjectorEnabled(int cylinderId) {
assertCylinderId(cylinderId, "isInjectorEnabled");
return is_injector_enabled[cylinderId - 1];
}
static void printStatus(void) {
static void printInjectorsStatus(void) {
for (int id = 1; id <= engineConfiguration->specs.cylindersCount; id++) {
scheduleMsg(logger, "injector_%d_%d", isInjectorEnabled(id));
}
@ -72,7 +74,7 @@ static void printStatus(void) {
static void setInjectorEnabled(int id, int value) {
efiAssertVoid(id >= 0 && id < engineConfiguration->specs.cylindersCount, "injector id");
is_injector_enabled[id] = value;
printStatus();
printInjectorsStatus();
}
static void runBench(brain_pin_e brainPin, OutputPin *output, float delayMs, float onTimeMs, float offTimeMs,
@ -222,63 +224,11 @@ static msg_t benchThread(int param) {
#endif
}
static void unregister(brain_pin_e currentPin, OutputPin *output) {
if (currentPin == GPIO_UNASSIGNED)
return;
scheduleMsg(logger, "unregistering %s", hwPortname(currentPin));
unmarkPin(currentPin);
output->unregister();
}
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin, OutputPin *output) {
if (oldPin != newPin) {
unregister(oldPin, output);
}
}
void stopIgnitionPins(void) {
for (int i = 0; i < IGNITION_PIN_COUNT; i++) {
NamedOutputPin *output = &enginePins.coils[i];
unregisterOutput(activeConfiguration.bc.ignitionPins[i],
engineConfiguration->bc.ignitionPins[i], output);
}
}
void stopInjectionPins(void) {
for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
NamedOutputPin *output = &enginePins.injectors[i];
unregisterOutput(activeConfiguration.bc.injectionPins[i],
engineConfiguration->bc.injectionPins[i], output);
}
}
void startIgnitionPins(void) {
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
NamedOutputPin *output = &enginePins.coils[i];
// todo: we need to check if mode has changed
if (boardConfiguration->ignitionPins[i] != activeConfiguration.bc.ignitionPins[i]) {
output->initPin(output->name, boardConfiguration->ignitionPins[i],
&boardConfiguration->ignitionPinMode);
}
}
// todo: we need to check if mode has changed
if (engineConfiguration->dizzySparkOutputPin != activeConfiguration.dizzySparkOutputPin) {
enginePins.dizzyOutput.initPin("dizzy tach", engineConfiguration->dizzySparkOutputPin,
&engineConfiguration->dizzySparkOutputPinMode);
}
}
void startInjectionPins(void) {
// todo: should we move this code closer to the injection logic?
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
NamedOutputPin *output = &enginePins.injectors[i];
// todo: we need to check if mode has changed
if (engineConfiguration->bc.injectionPins[i] != activeConfiguration.bc.injectionPins[i]) {
output->initPin(output->name, boardConfiguration->injectionPins[i],
&boardConfiguration->injectionPinMode);
}
void OutputPin::unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin) {
if (oldPin != GPIO_UNASSIGNED && oldPin != newPin) {
scheduleMsg(logger, "unregistering %s", hwPortname(oldPin));
unmarkPin(oldPin);
unregister();
}
}
@ -304,14 +254,14 @@ void initInjectorCentral(Logging *sharedLogger) {
logger = sharedLogger;
chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL);
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
is_injector_enabled[i] = true;
}
startInjectionPins();
startIgnitionPins();
enginePins.startInjectionPins();
enginePins.startIgnitionPins();
printStatus();
printInjectorsStatus();
addConsoleActionII("injector", setInjectorEnabled);
addConsoleAction("fuelpumpbench", fuelPumpBench);

View File

@ -19,15 +19,7 @@ void fuelPumpBench(void);
void milBench(void);
void initInjectorCentral(Logging *sharedLogger);
bool isRunningBenchTest(void);
int isInjectorEnabled(int cylinderId);
void assertCylinderId(int cylinderId, const char *msg);
void stopInjectionPins(void);
void startInjectionPins(void);
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin, OutputPin *output);
void stopIgnitionPins(void);
void startIgnitionPins(void);
void runIoTest(int subsystem, int index);
#endif /* INJECTOR_CENTRAL_H_ */

View File

@ -27,8 +27,11 @@ void Pid::init(pid_s *pid) {
}
bool Pid::isSame(pid_s *pid) {
return this->pid->dFactor == pid->dFactor && this->pid->iFactor == pid->iFactor &&
this->pid->offset == pid->offset && this->pid->pFactor == pid->pFactor;
return this->pid->pFactor == pid->pFactor
&& this->pid->iFactor == pid->iFactor
&& this->pid->dFactor == pid->dFactor
&& this->pid->offset == pid->offset
&& this->pid->period == pid->period;
}
float Pid::getValue(float target, float input) {
@ -53,8 +56,9 @@ float Pid::getValue(float target, float input, float dTime) {
if (iTerm > pid->maxValue)
iTerm = pid->maxValue;
if (iTerm < pid->minValue)
iTerm = pid->minValue;
// this is kind of a hack. a proper fix would be having separate additional settings 'maxIValue' and 'minIValye'
if (iTerm < -pid->maxValue)
iTerm = -pid->maxValue;
float result = pTerm + iTerm + dTerm + pid->offset;
if (result > pid->maxValue) {

View File

@ -50,8 +50,7 @@ EnginePins::EnginePins() {
* Sets the value of the pin. On this layer the value is assigned as is, without any conversion.
*/
#if EFI_PROD_CODE \
#if EFI_PROD_CODE
#define setPinValue(outputPin, electricalValue, logicValue) \
{ \
if ((outputPin)->currentLogicValue != (logicValue)) { \
@ -79,6 +78,41 @@ bool EnginePins::stopPins() {
return result;
}
void EnginePins::unregisterPins() {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
fuelPumpRelay.unregisterOutput(activeConfiguration.bc.fuelPumpPin, engineConfiguration->bc.fuelPumpPin);
fanRelay.unregisterOutput(activeConfiguration.bc.fanPin, engineConfiguration->bc.fanPin);
hipCs.unregisterOutput(activeConfiguration.bc.hip9011CsPin, engineConfiguration->bc.hip9011CsPin);
triggerDecoderErrorPin.unregisterOutput(activeConfiguration.bc.triggerErrorPin,
engineConfiguration->bc.triggerErrorPin);
sdCsPin.unregisterOutput(activeConfiguration.bc.sdCardCsPin, engineConfiguration->bc.sdCardCsPin);
etbOutput1.unregisterOutput(activeConfiguration.bc.etbDirectionPin1,
engineConfiguration->bc.etbDirectionPin1);
etbOutput2.unregisterOutput(activeConfiguration.bc.etbDirectionPin2,
engineConfiguration->bc.etbDirectionPin2);
checkEnginePin.unregisterOutput(activeConfiguration.bc.malfunctionIndicatorPin,
engineConfiguration->bc.malfunctionIndicatorPin);
dizzyOutput.unregisterOutput(activeConfiguration.dizzySparkOutputPin,
engineConfiguration->dizzySparkOutputPin);
tachOut.unregisterOutput(activeConfiguration.bc.tachOutputPin,
engineConfiguration->bc.tachOutputPin);
idleSolenoidPin.unregisterOutput(activeConfiguration.bc.idle.solenoidPin,
engineConfiguration->bc.idle.solenoidPin);
for (int i = 0;i < LE_COMMAND_COUNT;i++) {
fsioOutputs[i].unregisterOutput(activeConfiguration.bc.fsioPins[i],
engineConfiguration->bc.fsioPins[i]);
}
alternatorPin.unregisterOutput(activeConfiguration.bc.alternatorControlPin,
engineConfiguration->bc.alternatorControlPin);
mainRelay.unregisterOutput(activeConfiguration.bc.mainRelayPin,
engineConfiguration->bc.mainRelayPin);
#endif /* EFI_PROD_CODE */
}
void EnginePins::reset() {
for (int i = 0; i < INJECTION_PIN_COUNT;i++) {
injectors[i].reset();
@ -88,6 +122,60 @@ void EnginePins::reset() {
}
}
void EnginePins::stopIgnitionPins(void) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
for (int i = 0; i < IGNITION_PIN_COUNT; i++) {
NamedOutputPin *output = &enginePins.coils[i];
output->unregisterOutput(activeConfiguration.bc.ignitionPins[i],
engineConfiguration->bc.ignitionPins[i]);
}
#endif /* EFI_PROD_CODE */
}
void EnginePins::stopInjectionPins(void) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
NamedOutputPin *output = &enginePins.injectors[i];
output->unregisterOutput(activeConfiguration.bc.injectionPins[i],
engineConfiguration->bc.injectionPins[i]);
}
#endif /* EFI_PROD_CODE */
}
void EnginePins::startIgnitionPins(void) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
NamedOutputPin *output = &enginePins.coils[i];
// todo: we need to check if mode has changed
if (boardConfiguration->ignitionPins[i] != activeConfiguration.bc.ignitionPins[i]) {
output->initPin(output->name, boardConfiguration->ignitionPins[i],
&boardConfiguration->ignitionPinMode);
}
}
// todo: we need to check if mode has changed
if (engineConfiguration->dizzySparkOutputPin != activeConfiguration.dizzySparkOutputPin) {
enginePins.dizzyOutput.initPin("dizzy tach", engineConfiguration->dizzySparkOutputPin,
&engineConfiguration->dizzySparkOutputPinMode);
}
#endif /* EFI_PROD_CODE */
}
void EnginePins::startInjectionPins(void) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
// todo: should we move this code closer to the injection logic?
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
NamedOutputPin *output = &enginePins.injectors[i];
// todo: we need to check if mode has changed
if (engineConfiguration->bc.injectionPins[i] != activeConfiguration.bc.injectionPins[i]) {
output->initPin(output->name, boardConfiguration->injectionPins[i],
&boardConfiguration->injectionPinMode);
}
}
#endif /* EFI_PROD_CODE */
}
NamedOutputPin::NamedOutputPin() : OutputPin() {
name = NULL;
}

View File

@ -35,6 +35,8 @@ public:
bool isPinAssigned();
void initPin(const char *msg, brain_pin_e brainPin);
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e *outputMode);
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin);
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
ioportid_t port;
@ -88,6 +90,11 @@ public:
EnginePins();
void reset();
bool stopPins();
void unregisterPins();
void startInjectionPins();
void startIgnitionPins();
void stopInjectionPins();
void stopIgnitionPins();
OutputPin mainRelay;
OutputPin fanRelay;
OutputPin acRelay;

View File

@ -50,7 +50,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitime_t timeX, schfunc_t
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
printf("Already scheduled was %d\r\n", (int)scheduling->momentX);
printf("Already scheduled now %d\r\n", (int)timeX);
#endif /* EFI_UNIT_TEST || EFI_SIMULATOR */
#endif /* EFI_UNIT_TEST */
return false;
}

View File

@ -200,6 +200,7 @@ static void calcFastAdcIndexes(void) {
}
static void adcConfigListener(Engine *engine) {
// todo: something is not right here - looks like should be a callback for each configuration change?
calcFastAdcIndexes();
}
@ -231,8 +232,8 @@ void applyNewHardwareSettings(void) {
// all 'stop' methods need to go before we begin starting pins
stopInjectionPins();
stopIgnitionPins();
enginePins.stopInjectionPins();
enginePins.stopIgnitionPins();
stopCanPins();
bool etbRestartNeeded = isETBRestartNeeded();
if (etbRestartNeeded) {
@ -261,40 +262,11 @@ void applyNewHardwareSettings(void) {
unregisterPin(engineConfiguration->bc.clutchUpPin, activeConfiguration.bc.clutchUpPin);
enginePins.unregisterPins();
unregisterOutput(activeConfiguration.bc.fuelPumpPin, engineConfiguration->bc.fuelPumpPin,
&enginePins.fuelPumpRelay);
unregisterOutput(activeConfiguration.bc.fanPin, engineConfiguration->bc.fanPin, &enginePins.fanRelay);
unregisterOutput(activeConfiguration.bc.hip9011CsPin,
engineConfiguration->bc.hip9011CsPin, &enginePins.hipCs);
unregisterOutput(activeConfiguration.bc.triggerErrorPin,
engineConfiguration->bc.triggerErrorPin, &enginePins.triggerDecoderErrorPin);
unregisterOutput(activeConfiguration.bc.sdCardCsPin, engineConfiguration->bc.sdCardCsPin,
&enginePins.sdCsPin);
unregisterOutput(activeConfiguration.bc.etbDirectionPin1,
engineConfiguration->bc.etbDirectionPin1, &enginePins.etbOutput1);
unregisterOutput(activeConfiguration.bc.etbDirectionPin2,
engineConfiguration->bc.etbDirectionPin2, &enginePins.etbOutput2);
unregisterOutput(activeConfiguration.bc.malfunctionIndicatorPin,
engineConfiguration->bc.malfunctionIndicatorPin, &enginePins.checkEnginePin);
unregisterOutput(activeConfiguration.dizzySparkOutputPin,
engineConfiguration->dizzySparkOutputPin, &enginePins.dizzyOutput);
unregisterOutput(activeConfiguration.bc.tachOutputPin,
engineConfiguration->bc.tachOutputPin, &enginePins.tachOut);
unregisterOutput(activeConfiguration.bc.idle.solenoidPin,
engineConfiguration->bc.idle.solenoidPin, &enginePins.idleSolenoidPin);
for (int i = 0;i < LE_COMMAND_COUNT;i++)
unregisterOutput(activeConfiguration.bc.fsioPins[i],
engineConfiguration->bc.fsioPins[i], &enginePins.fsioOutputs[i]);
unregisterOutput(activeConfiguration.bc.alternatorControlPin,
engineConfiguration->bc.alternatorControlPin, &enginePins.alternatorPin);
unregisterOutput(activeConfiguration.bc.mainRelayPin,
engineConfiguration->bc.mainRelayPin, &enginePins.mainRelay);
startInjectionPins();
startIgnitionPins();
enginePins.startInjectionPins();
enginePins.startIgnitionPins();
startCanPins();
if (etbRestartNeeded) {
startETBPins();

View File

@ -107,8 +107,8 @@ struct pid_s
float dFactor;;"value", 1, 0, -1000, 1000, 5
int16_t offset;Linear addition to PID logic;"value", 1, 0, 0, 1000, 0
int16_t period;PID dTime;"ms", 1, 0, 0, 3000, 0
int16_t minValue;;"v", 1, 0, 0, 3000.0, 3
int16_t maxValue;;"v", 1, 0, 0, 3000.0, 3
int16_t minValue;;"", 1, 0, 0, 3000.0, 3
int16_t maxValue;;"", 1, 0, 0, 3000.0, 3
end_struct
struct cranking_parameters_s

View File

@ -260,5 +260,5 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20170602;
return 20170604;
}

View File

@ -1,5 +1,5 @@
// This file was generated by Version2Header
// Fri Jun 02 23:03:47 EDT 2017
// Sun Jun 04 19:14:56 EDT 2017
#ifndef VCS_VERSION
#define VCS_VERSION "14281"
#define VCS_VERSION "14317"
#endif

View File

@ -45,7 +45,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon May 29 22:21:18 EDT 2017
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jun 04 20:56:41 EDT 2017
pageSize = 16376
page = 1
@ -514,22 +514,22 @@ page = 1
alternatorControl_dFactor = scalar, F32, 1836, "value", 1, 0, -1000, 1000, 5
alternatorControl_offset = scalar, S16, 1840, "value", 1, 0, 0, 1000, 0
alternatorControl_period = scalar, S16, 1842, "ms", 1, 0, 0, 3000, 0
alternatorControl_minValue = scalar, S16, 1844, "v", 1, 0, 0, 3000.0, 3
alternatorControl_maxValue = scalar, S16, 1846, "v", 1, 0, 0, 3000.0, 3
alternatorControl_minValue = scalar, S16, 1844, "", 1, 0, 0, 3000.0, 3
alternatorControl_maxValue = scalar, S16, 1846, "", 1, 0, 0, 3000.0, 3
etb_pFactor = scalar, F32, 1848, "value", 1, 0, -1000, 1000, 5
etb_iFactor = scalar, F32, 1852, "value", 1, 0, -1000, 1000, 5
etb_dFactor = scalar, F32, 1856, "value", 1, 0, -1000, 1000, 5
etb_offset = scalar, S16, 1860, "value", 1, 0, 0, 1000, 0
etb_period = scalar, S16, 1862, "ms", 1, 0, 0, 3000, 0
etb_minValue = scalar, S16, 1864, "v", 1, 0, 0, 3000.0, 3
etb_maxValue = scalar, S16, 1866, "v", 1, 0, 0, 3000.0, 3
etb_minValue = scalar, S16, 1864, "", 1, 0, 0, 3000.0, 3
etb_maxValue = scalar, S16, 1866, "", 1, 0, 0, 3000.0, 3
warmupAfrPid_pFactor = scalar, F32, 1868, "value", 1, 0, -1000, 1000, 5
warmupAfrPid_iFactor = scalar, F32, 1872, "value", 1, 0, -1000, 1000, 5
warmupAfrPid_dFactor = scalar, F32, 1876, "value", 1, 0, -1000, 1000, 5
warmupAfrPid_offset = scalar, S16, 1880, "value", 1, 0, 0, 1000, 0
warmupAfrPid_period = scalar, S16, 1882, "ms", 1, 0, 0, 3000, 0
warmupAfrPid_minValue = scalar, S16, 1884, "v", 1, 0, 0, 3000.0, 3
warmupAfrPid_maxValue = scalar, S16, 1886, "v", 1, 0, 0, 3000.0, 3
warmupAfrPid_minValue = scalar, S16, 1884, "", 1, 0, 0, 3000.0, 3
warmupAfrPid_maxValue = scalar, S16, 1886, "", 1, 0, 0, 3000.0, 3
mapErrorDetectionTooLow = scalar, F32, 1888, "kPa", 1, 0, -100.0, 100.0, 2
mapErrorDetectionTooHigh = scalar, F32, 1892, "kPa", 1, 0, -100.0, 800.0, 2
step1RpmWindow = scalar, S32, 1896, "rpm", 1, 0, 0, 3000.0, 2
@ -538,8 +538,8 @@ page = 1
idleRpmPid_dFactor = scalar, F32, 1908, "value", 1, 0, -1000, 1000, 5
idleRpmPid_offset = scalar, S16, 1912, "value", 1, 0, 0, 1000, 0
idleRpmPid_period = scalar, S16, 1914, "ms", 1, 0, 0, 3000, 0
idleRpmPid_minValue = scalar, S16, 1916, "v", 1, 0, 0, 3000.0, 3
idleRpmPid_maxValue = scalar, S16, 1918, "v", 1, 0, 0, 3000.0, 3
idleRpmPid_minValue = scalar, S16, 1916, "", 1, 0, 0, 3000.0, 3
idleRpmPid_maxValue = scalar, S16, 1918, "", 1, 0, 0, 3000.0, 3
addedToWallCoef = scalar, F32, 1920, "%", 1, 0, 0.0, 300.0, 2
communicationPin = bits, U32, 1924, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
runningPin = bits, U32, 1928, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
@ -650,8 +650,8 @@ page = 1
fuelClosedLoopPid_dFactor = scalar, F32, 2748, "value", 1, 0, -1000, 1000, 5
fuelClosedLoopPid_offset = scalar, S16, 2752, "value", 1, 0, 0, 1000, 0
fuelClosedLoopPid_period = scalar, S16, 2754, "ms", 1, 0, 0, 3000, 0
fuelClosedLoopPid_minValue = scalar, S16, 2756, "v", 1, 0, 0, 3000.0, 3
fuelClosedLoopPid_maxValue = scalar, S16, 2758, "v", 1, 0, 0, 3000.0, 3
fuelClosedLoopPid_minValue = scalar, S16, 2756, "", 1, 0, 0, 3000.0, 3
fuelClosedLoopPid_maxValue = scalar, S16, 2758, "", 1, 0, 0, 3000.0, 3
fuelClosedLoopAfrHighThreshold = scalar, F32, 2760, "ratio", 1, 0, 0, 100, 1
stepperEnablePinMode = bits, U32, 2764, [0:5], "default", "INVALID", "INVALID", "INVALID", "opendrain", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "mode12", "mode13", "mode14", "mode15", "mode16", "mode17", "mode18", "mode19", "mode20", "mode21", "mode22", "mode23", "mode24", "mode25", "mode26", "mode27", "mode28", "mode29", "mode30", "mode31", "PULLUP", "mode33", "mode34", "mode35"
cj125ua = bits, U32, 2768, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
@ -683,29 +683,29 @@ page = 1
auxPid1_dFactor = scalar, F32, 2872, "value", 1, 0, -1000, 1000, 5
auxPid1_offset = scalar, S16, 2876, "value", 1, 0, 0, 1000, 0
auxPid1_period = scalar, S16, 2878, "ms", 1, 0, 0, 3000, 0
auxPid1_minValue = scalar, S16, 2880, "v", 1, 0, 0, 3000.0, 3
auxPid1_maxValue = scalar, S16, 2882, "v", 1, 0, 0, 3000.0, 3
auxPid1_minValue = scalar, S16, 2880, "", 1, 0, 0, 3000.0, 3
auxPid1_maxValue = scalar, S16, 2882, "", 1, 0, 0, 3000.0, 3
auxPid2_pFactor = scalar, F32, 2884, "value", 1, 0, -1000, 1000, 5
auxPid2_iFactor = scalar, F32, 2888, "value", 1, 0, -1000, 1000, 5
auxPid2_dFactor = scalar, F32, 2892, "value", 1, 0, -1000, 1000, 5
auxPid2_offset = scalar, S16, 2896, "value", 1, 0, 0, 1000, 0
auxPid2_period = scalar, S16, 2898, "ms", 1, 0, 0, 3000, 0
auxPid2_minValue = scalar, S16, 2900, "v", 1, 0, 0, 3000.0, 3
auxPid2_maxValue = scalar, S16, 2902, "v", 1, 0, 0, 3000.0, 3
auxPid2_minValue = scalar, S16, 2900, "", 1, 0, 0, 3000.0, 3
auxPid2_maxValue = scalar, S16, 2902, "", 1, 0, 0, 3000.0, 3
auxPid3_pFactor = scalar, F32, 2904, "value", 1, 0, -1000, 1000, 5
auxPid3_iFactor = scalar, F32, 2908, "value", 1, 0, -1000, 1000, 5
auxPid3_dFactor = scalar, F32, 2912, "value", 1, 0, -1000, 1000, 5
auxPid3_offset = scalar, S16, 2916, "value", 1, 0, 0, 1000, 0
auxPid3_period = scalar, S16, 2918, "ms", 1, 0, 0, 3000, 0
auxPid3_minValue = scalar, S16, 2920, "v", 1, 0, 0, 3000.0, 3
auxPid3_maxValue = scalar, S16, 2922, "v", 1, 0, 0, 3000.0, 3
auxPid3_minValue = scalar, S16, 2920, "", 1, 0, 0, 3000.0, 3
auxPid3_maxValue = scalar, S16, 2922, "", 1, 0, 0, 3000.0, 3
auxPid4_pFactor = scalar, F32, 2924, "value", 1, 0, -1000, 1000, 5
auxPid4_iFactor = scalar, F32, 2928, "value", 1, 0, -1000, 1000, 5
auxPid4_dFactor = scalar, F32, 2932, "value", 1, 0, -1000, 1000, 5
auxPid4_offset = scalar, S16, 2936, "value", 1, 0, 0, 1000, 0
auxPid4_period = scalar, S16, 2938, "ms", 1, 0, 0, 3000, 0
auxPid4_minValue = scalar, S16, 2940, "v", 1, 0, 0, 3000.0, 3
auxPid4_maxValue = scalar, S16, 2942, "v", 1, 0, 0, 3000.0, 3
auxPid4_minValue = scalar, S16, 2940, "", 1, 0, 0, 3000.0, 3
auxPid4_maxValue = scalar, S16, 2942, "", 1, 0, 0, 3000.0, 3
;skipping unusedEnd offset 2944
le_formulas1 = array, U08, 3048, [200],"char", 1, 0, 0.0, 3.0, 2
le_formulas2 = array, U08, 3248, [200],"char", 1, 0, 0.0, 3.0, 2
@ -952,7 +952,7 @@ fileVersion = { 20161225 }
wallFuelAmount = scalar, F32, 160, "ms", 1, 0
iatCorrection = scalar, F32, 164, "%", 1, 0
wallFuelCorrection = scalar, F32, 168, "ms", 1, 0
curIdlePosition = scalar, F32, 172, "percent", 1, 0
idleAirValvePosition = scalar, F32, 172, "percent", 1, 0
currentTargetAfr = scalar, F32, 176, "ratio", 1, 0
chargeAirMass = scalar, F32, 180, "g", 1, 0
cltCorrection = scalar, F32, 184, "%", 1, 0
@ -1242,7 +1242,7 @@ fileVersion = { 20161225 }
massAirFlowValueGa = massAirFlowValue,"Air Flow", "kg/hr", 0, 50, -999, -999, 999, 999, 1, 1
veValueGauge = veValue, "fuel: VE", "", 0, 120, 10, 10, 100, 100, 1, 1
baroCorrectionGauge = baroCorrection,"BaroCorr", "%", 0, 120, 10, 10, 100, 100, 1, 1
pedalPositionGauge = pedalPosition,"Pedal Position", "%", 0, 120, 10, 10, 100, 100, 1, 1
pedalPositionGauge = pedalPosition,"Throttle Pedal Position", "%", 0, 120, 10, 10, 100, 100, 1, 1
knockCountGauge = knockCount,"Knock count", "count", 0, 120, 10, 10, 100, 100, 1, 1
knockLevelGauge = knockLevel,"Knock level", "volts", 0, 7, 10, 10, 100, 100, 1, 2
@ -1267,7 +1267,7 @@ fileVersion = { 20161225 }
wallFuelAmountGauge = wallFuelAmount, "fuel: wall amount", "ms", 0, 100, 0, 0, 100, 100, 0, 0
wallFuelCorrectionGauge = wallFuelCorrection, "fuel: wall correction extra", "ms", 0, 100, 0, 0, 100, 100, 0, 0
curIdlePositionGauge = curIdlePosition, "idle position", "%", 0, 100, 0, 0, 100, 100, 0, 0
idleAirValvePositionGauge = idleAirValvePosition, "idle position", "%", 0, 100, 0, 0, 100, 100, 0, 0
debugFloatField1Gauge = debugFloatField1, "debug f1", "%", 0, 100, 0, 0, 100, 100, 4, 4
debugFloatField2Gauge = debugFloatField2, "debug f2", "%", 0, 100, 0, 0, 100, 100, 4, 4
@ -1356,7 +1356,7 @@ fileVersion = { 20161225 }
entry = massAirFlowValue,"airMass", float, "%.3f"
entry = pedalPosition, "pedal", float, "%.3f"
entry = triggerErrorsCounter, "trg err",int, "%d"
entry = curIdlePosition, "Idle Air Valve", float, "%.3f"
entry = idleAirValvePosition, "Idle Air Valve", float, "%.3f"
entry = fuelRunning, "fuel: running", float, "%.3f"
@ -1775,7 +1775,7 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
field = "AFR ADC input", afr_hwChannel
field = "fuelLevelSensor", fuelLevelSensor
field = "Baro ADC input", baroSensor_hwChannel
field = "pedal Position Channel", pedalPositionChannel
field = "Throttle pedal Position Channel", pedalPositionChannel
field = "Primary input channel", triggerInputPins1
field = "Secondary channel", triggerInputPins2
field = "Cam Sync/VVT input", camInput
@ -1985,6 +1985,7 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
field = "idle I", idleRpmPid_iFactor, { idleMode == 0}
field = "idle D", idleRpmPid_dFactor, { idleMode == 0}
field = "idle offset", idleRpmPid_offset, { idleMode == 0}
field = "period", idleRpmPid_period
field = "pid min", idleRpmPid_minValue, { idleMode == 0}
field = "pid max", idleRpmPid_maxValue, { idleMode == 0}
field = "pid TPS deactivation", idlePidDeactivationTpsThreshold, { idleMode == 0}
@ -2392,17 +2393,18 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
field = "verbose", isVerboseETB
field = "Throttle Pedal Up", throttlePedalUpVoltage
field = "Throttle Pedal Wide Open", throttlePedalWOTVoltage
field = "PWM Frequency", etbFreq
field = "Dir #1", etbDirectionPin1
field = "Dir #2", etbDirectionPin2
field = "Control #1", etbControlPin1
field = "Control #2", etbControlPin2
field = "pFactor", etb_pFactor
field = "iFactor", etb_iFactor
field = "dFactor", etb_dFactor
field = "offset", etb_offset
field = "pid min", etb_minValue
field = "pid max", etb_maxValue
field = "PWM Frequency", etbFreq, {pedalPositionChannel != 16}
field = "Dir #1", etbDirectionPin1, {pedalPositionChannel != 16}
field = "Dir #2", etbDirectionPin2, {pedalPositionChannel != 16}
field = "Control #1", etbControlPin1, {pedalPositionChannel != 16}
field = "Control #2", etbControlPin2, {pedalPositionChannel != 16}
field = "pFactor", etb_pFactor, {pedalPositionChannel != 16}
field = "iFactor", etb_iFactor, {pedalPositionChannel != 16}
field = "dFactor", etb_dFactor, {pedalPositionChannel != 16}
field = "offset", etb_offset, {pedalPositionChannel != 16}
field = "control period", etb_period, {pedalPositionChannel != 16}
field = "pid min", etb_minValue, {pedalPositionChannel != 16}
field = "pid max", etb_maxValue, {pedalPositionChannel != 16}
dialog = testSpark, "Spark"
commandButton = "Spark #1", cmd_test_spk1

View File

@ -188,7 +188,7 @@ fileVersion = { 20161225 }
wallFuelAmount = scalar, F32, 160, "ms", 1, 0
iatCorrection = scalar, F32, 164, "%", 1, 0
wallFuelCorrection = scalar, F32, 168, "ms", 1, 0
curIdlePosition = scalar, F32, 172, "percent", 1, 0
idleAirValvePosition = scalar, F32, 172, "percent", 1, 0
currentTargetAfr = scalar, F32, 176, "ratio", 1, 0
chargeAirMass = scalar, F32, 180, "g", 1, 0
cltCorrection = scalar, F32, 184, "%", 1, 0
@ -478,7 +478,7 @@ fileVersion = { 20161225 }
massAirFlowValueGa = massAirFlowValue,"Air Flow", "kg/hr", 0, 50, -999, -999, 999, 999, 1, 1
veValueGauge = veValue, "fuel: VE", "", 0, 120, 10, 10, 100, 100, 1, 1
baroCorrectionGauge = baroCorrection,"BaroCorr", "%", 0, 120, 10, 10, 100, 100, 1, 1
pedalPositionGauge = pedalPosition,"Pedal Position", "%", 0, 120, 10, 10, 100, 100, 1, 1
pedalPositionGauge = pedalPosition,"Throttle Pedal Position", "%", 0, 120, 10, 10, 100, 100, 1, 1
knockCountGauge = knockCount,"Knock count", "count", 0, 120, 10, 10, 100, 100, 1, 1
knockLevelGauge = knockLevel,"Knock level", "volts", 0, 7, 10, 10, 100, 100, 1, 2
@ -503,7 +503,7 @@ fileVersion = { 20161225 }
wallFuelAmountGauge = wallFuelAmount, "fuel: wall amount", "ms", 0, 100, 0, 0, 100, 100, 0, 0
wallFuelCorrectionGauge = wallFuelCorrection, "fuel: wall correction extra", "ms", 0, 100, 0, 0, 100, 100, 0, 0
curIdlePositionGauge = curIdlePosition, "idle position", "%", 0, 100, 0, 0, 100, 100, 0, 0
idleAirValvePositionGauge = idleAirValvePosition, "idle position", "%", 0, 100, 0, 0, 100, 100, 0, 0
debugFloatField1Gauge = debugFloatField1, "debug f1", "%", 0, 100, 0, 0, 100, 100, 4, 4
debugFloatField2Gauge = debugFloatField2, "debug f2", "%", 0, 100, 0, 0, 100, 100, 4, 4
@ -592,7 +592,7 @@ fileVersion = { 20161225 }
entry = massAirFlowValue,"airMass", float, "%.3f"
entry = pedalPosition, "pedal", float, "%.3f"
entry = triggerErrorsCounter, "trg err",int, "%d"
entry = curIdlePosition, @@GAUGE_NAME_IAC@@, float, "%.3f"
entry = idleAirValvePosition, @@GAUGE_NAME_IAC@@, float, "%.3f"
entry = fuelRunning, @@GAUGE_NAME_FUEL_RUNNING@@, float, "%.3f"
@ -1011,7 +1011,7 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
field = "AFR ADC input", afr_hwChannel
field = "fuelLevelSensor", fuelLevelSensor
field = "Baro ADC input", baroSensor_hwChannel
field = "pedal Position Channel", pedalPositionChannel
field = "Throttle pedal Position Channel", pedalPositionChannel
field = "Primary input channel", triggerInputPins1
field = "Secondary channel", triggerInputPins2
field = "Cam Sync/VVT input", camInput
@ -1221,6 +1221,7 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
field = "idle I", idleRpmPid_iFactor, { idleMode == 0}
field = "idle D", idleRpmPid_dFactor, { idleMode == 0}
field = "idle offset", idleRpmPid_offset, { idleMode == 0}
field = "period", idleRpmPid_period
field = "pid min", idleRpmPid_minValue, { idleMode == 0}
field = "pid max", idleRpmPid_maxValue, { idleMode == 0}
field = "pid TPS deactivation", idlePidDeactivationTpsThreshold, { idleMode == 0}
@ -1628,17 +1629,18 @@ cmd_call_from_pit = "w\x00\x20\x34\x56"
field = "verbose", isVerboseETB
field = "Throttle Pedal Up", throttlePedalUpVoltage
field = "Throttle Pedal Wide Open", throttlePedalWOTVoltage
field = "PWM Frequency", etbFreq
field = "Dir #1", etbDirectionPin1
field = "Dir #2", etbDirectionPin2
field = "Control #1", etbControlPin1
field = "Control #2", etbControlPin2
field = "pFactor", etb_pFactor
field = "iFactor", etb_iFactor
field = "dFactor", etb_dFactor
field = "offset", etb_offset
field = "pid min", etb_minValue
field = "pid max", etb_maxValue
field = "PWM Frequency", etbFreq, {pedalPositionChannel != 16}
field = "Dir #1", etbDirectionPin1, {pedalPositionChannel != 16}
field = "Dir #2", etbDirectionPin2, {pedalPositionChannel != 16}
field = "Control #1", etbControlPin1, {pedalPositionChannel != 16}
field = "Control #2", etbControlPin2, {pedalPositionChannel != 16}
field = "pFactor", etb_pFactor, {pedalPositionChannel != 16}
field = "iFactor", etb_iFactor, {pedalPositionChannel != 16}
field = "dFactor", etb_dFactor, {pedalPositionChannel != 16}
field = "offset", etb_offset, {pedalPositionChannel != 16}
field = "control period", etb_period, {pedalPositionChannel != 16}
field = "pid min", etb_minValue, {pedalPositionChannel != 16}
field = "pid max", etb_maxValue, {pedalPositionChannel != 16}
dialog = testSpark, "Spark"
commandButton = "Spark #1", cmd_test_spk1

View File

@ -58,7 +58,7 @@ static ALWAYS_INLINE bool validateBuffer(Logging *logging, uint32_t extraLen) {
if (remainingSize(logging) < extraLen + 1) {
#if EFI_PROD_CODE
warning(CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s", logging->name);
#endif
#endif /* EFI_PROD_CODE */
return true;
}
return false;
@ -67,8 +67,8 @@ static ALWAYS_INLINE bool validateBuffer(Logging *logging, uint32_t extraLen) {
void append(Logging *logging, const char *text) {
efiAssertVoid(text != NULL, "append NULL");
uint32_t extraLen = efiStrlen(text);
bool isError = validateBuffer(logging, extraLen);
if (isError) {
bool isCapacityProblem = validateBuffer(logging, extraLen);
if (isCapacityProblem) {
return;
}
strcpy(logging->linePointer, text);
@ -82,24 +82,11 @@ void append(Logging *logging, const char *text) {
* @note This method if fast because it does not validate much, be sure what you are doing
*/
void appendFast(Logging *logging, const char *text) {
// todo: fix this implementation? this would be a one-pass implementation instead of a two-pass
// char c;
// char *s = (char *) text;
// do {
// c = *s++;
// *logging->linePointer++ = c;
// } while (c != '\0');
register char *s;
for (s = (char *) text; *s; ++s)
;
int extraLen = (s - text);
s = logging->linePointer;
while ((*s++ = *text++) != 0)
;
// strcpy(logging->linePointer, text);
logging->linePointer += extraLen;
logging->linePointer = s - 1;
}
// todo: look into chsnprintf once on Chibios 3
@ -225,11 +212,6 @@ void printWithLength(char *line) {
consoleOutputBuffer((const uint8_t *) line, p - line);
}
void printLine(Logging *logging) {
printWithLength(logging->buffer);
resetLogging(logging);
}
void appendMsgPrefix(Logging *logging) {
append(logging, "msg" DELIMETER);
}
@ -263,7 +245,8 @@ void printMsg(Logging *logger, const char *fmt, ...) {
va_end(ap);
append(logger, DELIMETER);
printLine(logger);
printWithLength(logger->buffer);
resetLogging(logger);
}
/**

View File

@ -56,7 +56,6 @@ void debugFloat(Logging *logging, const char *text, float value, int precision);
void appendFloat(Logging *logging, float value, int precision);
void resetLogging(Logging *logging);
void printLine(Logging *logging);
void appendMsgPrefix(Logging *logging);
void appendMsgPostfix(Logging *logging);

View File

@ -73,7 +73,7 @@ char * swapOutputBuffers(int *actualOutputBufferSize) {
int expectedOutputSize;
#endif /* EFI_ENABLE_ASSERTS */
{ // start of critical section
lockOutputBuffer();
bool alreadyLocked = lockOutputBuffer();
/**
* we cannot output under syslock, we simply rotate which buffer is which
*/
@ -88,7 +88,9 @@ char * swapOutputBuffers(int *actualOutputBufferSize) {
accumulatedSize = 0;
accumulationBuffer[0] = 0;
unlockOutputBuffer();
if (!alreadyLocked) {
unlockOutputBuffer();
}
} // end of critical section
*actualOutputBufferSize = efiStrlen(outputBuffer);
@ -104,16 +106,12 @@ char * swapOutputBuffers(int *actualOutputBufferSize) {
return outputBuffer;
}
extern bool consoleInBinaryMode;
/**
* This method actually sends all the pending data to the communication layer.
* This method is invoked by the main thread - that's the only thread which should be sending
* actual data to console in order to avoid concurrent access to serial hardware.
*/
void printPending(void) {
if (consoleInBinaryMode)
return;
int actualOutputBufferSize;
char *output = swapOutputBuffers(&actualOutputBufferSize);

View File

@ -14,6 +14,8 @@
#define EFI_PRINTF_FUEL_DETAILS TRUE
#define EFI_BLUETOOTH_SETUP FALSE
#define EFI_GPIO_HARDWARE FALSE
#define EFI_CLOCK_LOCKS FALSE

View File

@ -11,6 +11,7 @@
#include "test_logic_expression.h"
#include "fsio_impl.h"
#include "cli_registry.h"
#include "engine_test_helper.h"
#define TEST_POOL_SIZE 256
@ -19,7 +20,7 @@ static float mockFan;
static float mockRpm;
static float mockTimeSinceBoot;
float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) {
float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
switch(action) {
case LE_METHOD_FAN:
return mockFan;
@ -91,7 +92,11 @@ static void testExpression2(float selfValue, const char *line, float expected) {
print("Parsing [%s]", line);
assertTrueM("Not NULL expected", element != NULL);
LECalculator c;
assertEqualsM(line, expected, c.getValue2(selfValue, element, NULL));
EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper;
assertEqualsM(line, expected, c.getValue2(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX));
}
static void testExpression(const char *line, float expected) {
@ -103,13 +108,16 @@ void testLogicExpressions(void) {
testParsing();
EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper;
LECalculator c;
LEElement value1;
value1.init(LE_NUMERIC_VALUE, 123.0);
c.add(&value1);
assertEqualsM("123", 123.0, c.getValue(0, NULL));
assertEqualsM("123", 123.0, c.getValue(0 PASS_ENGINE_PARAMETER_SUFFIX));
LEElement value2;
value2.init(LE_NUMERIC_VALUE, 321.0);
@ -118,7 +126,7 @@ void testLogicExpressions(void) {
LEElement value3;
value3.init(LE_OPERATOR_AND);
c.add(&value3);
assertEqualsM("123 and 321", 1.0, c.getValue(0, NULL));
assertEqualsM("123 and 321", 1.0, c.getValue(0 PASS_ENGINE_PARAMETER_SUFFIX));
/**
* fuel_pump = (time_since_boot < 4 seconds) OR (rpm > 0)
@ -183,7 +191,7 @@ void testLogicExpressions(void) {
LEElement * element = pool.parseExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR");
assertTrueM("Not NULL expected", element != NULL);
LECalculator c;
assertEqualsM("that expression", 1, c.getValue2(0, element, NULL));
assertEqualsM("that expression", 1, c.getValue2(0, element PASS_ENGINE_PARAMETER_SUFFIX));
assertEquals(12, c.currentCalculationLogPosition);
assertEquals(102, c.calcLogAction[0]);