idle_min through FSIO not working as intended #1553
This commit is contained in:
parent
e854410778
commit
a83cef6934
|
@ -32,11 +32,6 @@ EXTERN_ENGINE;
|
|||
*/
|
||||
#define NO_PWM 0
|
||||
|
||||
// see useFSIO15ForIdleRpmAdjustment
|
||||
#define MAGIC_OFFSET_FOR_IDLE_TARGET_RPM 14
|
||||
// see useFSIO16ForTimingAdjustment
|
||||
#define MAGIC_OFFSET_FOR_TIMING_FSIO 15
|
||||
|
||||
fsio8_Map3D_f32t fsioTable1("fsio#1");
|
||||
fsio8_Map3D_u8t fsioTable2("fsio#2");
|
||||
fsio8_Map3D_u8t fsioTable3("fsio#3");
|
||||
|
@ -151,6 +146,7 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
return getVBatt(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
case LE_METHOD_TPS:
|
||||
return Sensor::get(SensorType::DriverThrottleIntent).value_or(0);
|
||||
// cfg_xxx references are code generated
|
||||
#include "fsio_getters.def"
|
||||
default:
|
||||
warning(CUSTOM_FSIO_UNEXPECTED, "FSIO ERROR no data for action=%d", action);
|
||||
|
@ -260,9 +256,9 @@ void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
userPool.reset();
|
||||
for (int i = 0; i < FSIO_COMMAND_COUNT; i++) {
|
||||
const char *formula = config->fsioFormulas[i];
|
||||
int len = strlen(formula);
|
||||
LEElement *logic = userPool.parseExpression(formula);
|
||||
brain_pin_e brainPin = CONFIG(fsioOutputPins)[i];
|
||||
if (brainPin != GPIO_UNASSIGNED && logic == NULL) {
|
||||
if (len > 0 && logic == NULL) {
|
||||
warning(CUSTOM_FSIO_PARSING, "parsing [%s]", formula);
|
||||
}
|
||||
|
||||
|
@ -332,8 +328,8 @@ float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
/**
|
||||
* @param index from zero for (FSIO_COMMAND_COUNT - 1)
|
||||
*/
|
||||
static void handleFsio(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
if (CONFIG(fsioOutputPins)[index] == GPIO_UNASSIGNED) {
|
||||
static void runFsioCalculation(int index DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
if (strlen(config->fsioFormulas[index]) == 0) {
|
||||
engine->fsioState.fsioLastValue[index] = NAN;
|
||||
return;
|
||||
}
|
||||
|
@ -424,7 +420,8 @@ static void setFsioFrequency(int index, int frequency) {
|
|||
* @param out param! current and new value as long as element is not NULL
|
||||
* @return 'true' if value has changed
|
||||
*/
|
||||
static bool updateValueOrWarning(int fsioIndex, const char *msg, float *value DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
static bool updateValueOrWarning(int humanIndex, const char *msg, float *value DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
int fsioIndex = humanIndex - 1;
|
||||
LEElement * element = state.fsioLogics[fsioIndex];
|
||||
if (element == NULL) {
|
||||
warning(CUSTOM_FSIO_INVALID_EXPRESSION, "invalid expression for %s", msg);
|
||||
|
@ -438,7 +435,7 @@ static bool updateValueOrWarning(int fsioIndex, const char *msg, float *value DE
|
|||
}
|
||||
|
||||
static void useFsioForServo(int servoIndex DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
updateValueOrWarning(8 - 1 + servoIndex, "servo", &engine->fsioState.servoValues[servoIndex] PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
updateValueOrWarning(8 + servoIndex, "servo", &engine->fsioState.servoValues[servoIndex] PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -446,7 +443,7 @@ static void useFsioForServo(int servoIndex DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
*/
|
||||
void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
for (int index = 0; index < FSIO_COMMAND_COUNT; index++) {
|
||||
handleFsio(index PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
runFsioCalculation(index PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
#if EFI_FUEL_PUMP
|
||||
|
@ -517,7 +514,7 @@ void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
}
|
||||
|
||||
if (engineConfiguration->useFSIO6ForRevLimiter) {
|
||||
updateValueOrWarning(6 - 1, "rpm limit", &ENGINE(fsioState.fsioRpmHardLimit) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
updateValueOrWarning(6, "rpm limit", &ENGINE(fsioState.fsioRpmHardLimit) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
if (engineConfiguration->useFSIO8ForServo1) {
|
||||
|
|
|
@ -13,16 +13,22 @@
|
|||
#include "table_helper.h"
|
||||
#include "system_fsio.h"
|
||||
|
||||
// see useFSIO4ForSeriousEngineWarning
|
||||
#define MAGIC_OFFSET_FOR_ENGINE_WARNING 4
|
||||
// see useFSIO5ForCriticalIssueEngineStop
|
||||
#define MAGIC_OFFSET_FOR_CRITICAL_ENGINE 5
|
||||
// see useFSIO12ForIdleOffset
|
||||
#define MAGIC_OFFSET_FOR_IDLE_OFFSET 12
|
||||
// see useFSIO13ForIdleMinValue
|
||||
#define MAGIC_OFFSET_FOR_IDLE_MIN_VALUE 13
|
||||
// see useFSIO15ForIdleRpmAdjustment
|
||||
#define MAGIC_OFFSET_FOR_IDLE_TARGET_RPM 15
|
||||
// see useFSIO16ForTimingAdjustment
|
||||
#define MAGIC_OFFSET_FOR_TIMING_FSIO 16
|
||||
|
||||
typedef Map3D<FSIO_TABLE_8, FSIO_TABLE_8, float, float> fsio8_Map3D_f32t;
|
||||
typedef Map3D<FSIO_TABLE_8, FSIO_TABLE_8, uint8_t, float> fsio8_Map3D_u8t;
|
||||
|
||||
#define MAGIC_OFFSET_FOR_ENGINE_WARNING 4
|
||||
#define MAGIC_OFFSET_FOR_CRITICAL_ENGINE 5
|
||||
|
||||
float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
/**
|
||||
|
|
|
@ -100,7 +100,7 @@ TEST(fuelCut, criticalEngineTemperature) {
|
|||
setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð);
|
||||
|
||||
engineConfiguration->useFSIO5ForCriticalIssueEngineStop = true;
|
||||
setFsio(MAGIC_OFFSET_FOR_CRITICAL_ENGINE, GPIOD_7, TOO_HOT_LOGIC PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
setFsio(MAGIC_OFFSET_FOR_CRITICAL_ENGINE - 1, GPIOD_7, TOO_HOT_LOGIC PASS_CONFIG_PARAMETER_SUFFIX);
|
||||
applyFsioConfiguration(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
// we need some non-zero time as getTimeNow() which would become stopEngineRequestTimeNt
|
||||
|
@ -120,7 +120,6 @@ TEST(fuelCut, criticalEngineTemperature) {
|
|||
ASSERT_TRUE(engine->stopEngineRequestTimeNt > 0);
|
||||
}
|
||||
|
||||
|
||||
TEST(fuel, injectorFlowCorrection) {
|
||||
|
||||
|
||||
|
|
|
@ -25,28 +25,39 @@ extern int timeNowUs;
|
|||
TEST(idle, fsioPidParameters) {
|
||||
WITH_ENGINE_TEST_HELPER(MIATA_NA6_MAP);
|
||||
|
||||
// todo finish this unit test!
|
||||
engineConfiguration->idleRpmPid.offset = 40;
|
||||
engineConfiguration->idleRpmPid2.offset = 50;
|
||||
|
||||
engineConfiguration->idleRpmPid.minValue = 30;
|
||||
engineConfiguration->idleRpmPid2.minValue = 60;
|
||||
|
||||
engineConfiguration->useFSIO12ForIdleOffset = true;
|
||||
setFsioExpression(QUOTE(MAGIC_OFFSET_FOR_IDLE_OFFSET), "ac_on_switch cfg_idleRpmPid_offset cfg_idleRpmPid2_offset if" PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
engineConfiguration->useFSIO13ForIdleMinValue = true;
|
||||
setFsioExpression(QUOTE(MAGIC_OFFSET_FOR_IDLE_MIN_VALUE), "ac_on_switch cfg_idleRpmPid_minValue cfg_idleRpmPid2_minValue if" PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
eth.engine.periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
ASSERT_EQ(1, hasAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
// ASSERT_EQ(0, getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
setMockVoltage(engineConfiguration->acSwitchAdc, 0 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
ASSERT_EQ(1, getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
|
||||
// setMockVoltage(engineConfiguration->acSwitchAdc, 5 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
// ASSERT_EQ(1, getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
eth.engine.periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
ASSERT_EQ(40, ENGINE(fsioState.fsioIdleOffset));
|
||||
ASSERT_EQ(30, ENGINE(fsioState.fsioIdleMinValue));
|
||||
|
||||
setMockVoltage(engineConfiguration->acSwitchAdc, 5 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
ASSERT_EQ(0, getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE));
|
||||
|
||||
eth.engine.periodicSlowCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
ASSERT_EQ(50, ENGINE(fsioState.fsioIdleOffset));
|
||||
ASSERT_EQ(60, ENGINE(fsioState.fsioIdleMinValue));
|
||||
|
||||
|
||||
// todo finish this unit test!
|
||||
// timeNowUs = MS2US(700);
|
||||
|
||||
idleControllerInstance.PeriodicTask();
|
||||
|
||||
// ASSERT_EQ(0, engine->acSwitchLastChangeTime);
|
||||
// ASSERT_EQ(1, engine->acSwitchState);
|
||||
|
||||
}
|
||||
|
||||
// see also util.pid test
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "cli_registry.h"
|
||||
#include "engine_test_helper.h"
|
||||
#include "thermistors.h"
|
||||
#include "allsensors.h"
|
||||
|
||||
#define TEST_POOL_SIZE 256
|
||||
|
||||
|
@ -26,17 +27,13 @@ float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
return engine->fsioState.mockCrankingRpm;
|
||||
case LE_METHOD_TIME_SINCE_BOOT:
|
||||
return engine->fsioState.mockTimeSinceBoot;
|
||||
case FSIO_SETTING_FANONTEMPERATURE:
|
||||
case FSIO_SETTING_FANOFFTEMPERATURE:
|
||||
return 0;
|
||||
case LE_METHOD_VBATT:
|
||||
return 12;
|
||||
case LE_METHOD_IS_COOLANT_BROKEN:
|
||||
case FSIO_SETTING_IDLERPMPID_MINVALUE:
|
||||
case FSIO_SETTING_IDLERPMPID2_MINVALUE:
|
||||
return 0;
|
||||
case LE_METHOD_AC_TOGGLE:
|
||||
return engine->fsioState.mockAcToggle;
|
||||
return getAcToggle(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
case LE_METHOD_IS_COOLANT_BROKEN:
|
||||
return 0;
|
||||
#include "fsio_getters.def"
|
||||
default:
|
||||
firmwareError(OBD_PCM_Processor_Fault, "FSIO: No mock value for %d", action);
|
||||
return NAN;
|
||||
|
@ -92,7 +89,7 @@ static void testExpression2(float selfValue, const char *line, float expected, E
|
|||
LEElement thepool[TEST_POOL_SIZE];
|
||||
LEElementPool pool(thepool, TEST_POOL_SIZE);
|
||||
LEElement * element = pool.parseExpression(line);
|
||||
print("Parsing [%s]", line);
|
||||
print("Parsing [%s]\n", line);
|
||||
ASSERT_TRUE(element != NULL) << "Not NULL expected";
|
||||
LECalculator c;
|
||||
|
||||
|
@ -194,6 +191,7 @@ TEST(fsio, testLogicExpressions) {
|
|||
|
||||
testExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR", 1, sensorVals);
|
||||
|
||||
{
|
||||
WITH_ENGINE_TEST_HELPER_SENS(FORD_INLINE_6_1995, sensorVals);
|
||||
LEElement thepool[TEST_POOL_SIZE];
|
||||
LEElementPool pool(thepool, TEST_POOL_SIZE);
|
||||
|
@ -205,17 +203,26 @@ TEST(fsio, testLogicExpressions) {
|
|||
ASSERT_EQ(12, c.currentCalculationLogPosition);
|
||||
ASSERT_EQ(102, c.calcLogAction[0]);
|
||||
ASSERT_EQ(0, c.calcLogValue[0]);
|
||||
}
|
||||
|
||||
testExpression("cfg_fanOffTemperature", 0);
|
||||
testExpression("coolant cfg_fanOffTemperature >", 1);
|
||||
|
||||
testExpression("0 1 &", 0);
|
||||
testExpression("0 1 |", 1);
|
||||
|
||||
testExpression("0 1 >", 0);
|
||||
|
||||
testExpression(FAN_CONTROL_LOGIC, 1);
|
||||
{
|
||||
WITH_ENGINE_TEST_HELPER_SENS(FORD_INLINE_6_1995, sensorVals);
|
||||
engineConfiguration->fanOnTemperature = 0;
|
||||
engineConfiguration->fanOffTemperature = 0;
|
||||
|
||||
testExpression2(0, "cfg_fanOffTemperature", 0, engine);
|
||||
testExpression2(0, FAN_CONTROL_LOGIC, 1, engine);
|
||||
testExpression2(0, "coolant cfg_fanOffTemperature >", 1, engine);
|
||||
}
|
||||
|
||||
{
|
||||
WITH_ENGINE_TEST_HELPER_SENS(FORD_INLINE_6_1995, sensorVals);
|
||||
engine->fsioState.mockRpm = 900;
|
||||
engine->fsioState.mockCrankingRpm = 200;
|
||||
testExpression2(0, "rpm", 900, engine);
|
||||
|
@ -223,3 +230,4 @@ TEST(fsio, testLogicExpressions) {
|
|||
testExpression2(0, STARTER_RELAY_LOGIC, 0, engine);
|
||||
testExpression2(0, "rpm cranking_rpm > ", 1, engine);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue