Remove fsio part 2 (#3876)

* dead config stuff

* fsio state

* remove tests

* getEngineValue

* put part back
This commit is contained in:
Matthew Kennedy 2022-02-01 21:49:44 -08:00 committed by GitHub
parent 42deca0fd0
commit 40d16291b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 6 additions and 357 deletions

View File

@ -2,7 +2,7 @@
export PROJECT_BOARD=proteus
export PROJECT_CPU=ARCH_STM32F4
export EXTRA_PARAMS="-DVR_HW_CHECK_MODE=TRUE -DHW_CHECK_MODE=TRUE -DHW_CHECK_SD=TRUE -DHW_CHECK_ALWAYS_STIMULATE=TRUE -DHW_CHECK_SPARK_FSIO=TRUE -DSHORT_BOARD_NAME=proteus_f4"
export EXTRA_PARAMS="-DVR_HW_CHECK_MODE=TRUE -DHW_CHECK_MODE=TRUE -DHW_CHECK_SD=TRUE -DHW_CHECK_ALWAYS_STIMULATE=TRUE -DSHORT_BOARD_NAME=proteus_f4"
export DEFAULT_ENGINE_TYPE=-DDEFAULT_ENGINE_TYPE=PROTEUS_QC_TEST_BOARD

View File

@ -2,7 +2,7 @@
export PROJECT_BOARD=proteus
export PROJECT_CPU=ARCH_STM32F7
export EXTRA_PARAMS="-DVR_HW_CHECK_MODE=TRUE -DHW_CHECK_MODE=TRUE -DHW_CHECK_SD=TRUE -DHW_CHECK_ALWAYS_STIMULATE=TRUE -DHW_CHECK_SPARK_FSIO=TRUE -DSHORT_BOARD_NAME=proteus_f7"
export EXTRA_PARAMS="-DVR_HW_CHECK_MODE=TRUE -DHW_CHECK_MODE=TRUE -DHW_CHECK_SD=TRUE -DHW_CHECK_ALWAYS_STIMULATE=TRUE -DSHORT_BOARD_NAME=proteus_f7"
export DEFAULT_ENGINE_TYPE=-DDEFAULT_ENGINE_TYPE=PROTEUS_QC_TEST_BOARD

View File

@ -80,11 +80,6 @@ void setEngineBMW_M73_microRusEfi() {
engineConfiguration->injectionMode = IM_BATCH;
// enable ETB
// set_rpn_expression 8 "0"
// TODO LUA setFsio(7, GPIOC_8, "0");
engineConfiguration->etb.pFactor = 2.00;
engineConfiguration->etb.iFactor = 0.35;

View File

@ -344,9 +344,6 @@ void setTle8888TestConfiguration() {
// IN2 PF14
// SF PF11
#if defined(STM32_HAS_GPIOF) && STM32_HAS_GPIOF
#if EFI_FSIO
// todo lua setFsio(14, GPIOF_13, "1");
#endif /* EFI_FSIO */
engineConfiguration->etbIo[0].directionPin1 = GPIOF_15;
engineConfiguration->etbIo[0].directionPin2 = GPIOF_14;
engineConfiguration->etbIo[0].disablePin = GPIOF_12;
@ -360,9 +357,7 @@ void setTle8888TestConfiguration() {
// IN1 PE2
// IN2 PE4
// SF PE3
#if EFI_FSIO
// todo lua setFsio(15, GPIOE_6, "1");
#endif
engineConfiguration->etbIo[0].directionPin1 = GPIOE_2;
engineConfiguration->etbIo[0].directionPin2 = GPIOE_4;
engineConfiguration->etbIo[0].disablePin = GPIOE_5;

View File

@ -239,11 +239,5 @@ void setFordEscortGt() {
engineConfiguration->tpsAccelEnrichmentThreshold = 40;
engineConfiguration->isSdCardEnabled = true;
// engineConfiguration->useFSIO16ForTimingAdjustment = true;
// we wanted to have a timinig table adjustment switch here
// engineConfiguration->fsioAdc[0] = EFI_ADC_12; // PC2
// end of Ford Escort GT config
}

View File

@ -278,12 +278,6 @@ void setMiataNA6_MAP_Frankenso() {
engineConfiguration->isSdCardEnabled = true;
// /**
// * oil pressure line
// * adc4/pa4/W47
// */
// engineConfiguration->fsioAdc[0] = EFI_ADC_NONE;
engineConfiguration->injectionPins[0] = GPIOD_3; // #1&3 pin 3U
engineConfiguration->injectionPins[1] = GPIOE_2; // #2&4 pin 3V
engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED;

View File

@ -444,8 +444,6 @@ void setMazdaMiata2003EngineConfiguration() {
engineConfiguration->scriptSetting[2] = 105; // #3 CLT threshold
engineConfiguration->scriptSetting[3] = 12.0; // #4 voltage threshold
// setFsio(1, GPIOE_6, COMBINED_WARNING_LIGHT);
// enable auto_idle
// enable verbose_idle
engineConfiguration->isVerboseIAC = false;
@ -617,12 +615,6 @@ void setMiataNB2_MRE_ETB() {
engineConfiguration->useETBforIdleControl = true;
#if EFI_FSIO
// enable ETB
// set_rpn_expression 8 "0"
// todo lua ETB setFsio(7, GPIOC_8, "0");
#endif /* EFI_FSIO */
//set idle_offset 0
engineConfiguration->idleRpmPid.offset = 0;
engineConfiguration->idleRpmPid.pFactor = 0.2;

View File

@ -123,10 +123,9 @@ void setToyota_2jz_vics() {
strcpy(engineConfiguration->engineCode, "2JZ");
strcpy(engineConfiguration->vehicleName, "VVT example");
// todo: these magic values would be hardcoded once we find out proper magic values
// engineConfiguration->fsio_setting[14] = 175 - 45;
// engineConfiguration->fsio_setting[15] = 175 + 45;
// engineConfiguration->scriptSetting[4] = 175 - 45;
// engineConfiguration->scriptSetting[5] = 175 + 45;
engineConfiguration->vvtPins[0] = GPIOE_3; // VVT solenoid control

View File

@ -49,7 +49,6 @@ void AlternatorController::onFastCallback() {
alternatorPid.postState(&engine->outputChannels.alternatorStatus);
#endif /* EFI_TUNER_STUDIO */
// todo: migrate this to FSIO
bool alternatorShouldBeEnabledAtCurrentRpm = Sensor::getOrZero(SensorType::Rpm) > engineConfiguration->cranking.rpm;
if (!engineConfiguration->isAlternatorControlEnabled || !alternatorShouldBeEnabledAtCurrentRpm) {

View File

@ -52,15 +52,6 @@ extern int waveChartUsedSize;
extern WaveChart waveChart;
#endif /* EFI_ENGINE_SNIFFER */
FsioState::FsioState() {
#if EFI_ENABLE_ENGINE_WARNING
isEngineWarning = FALSE;
#endif
#if EFI_ENABLE_CRITICAL_ENGINE_STOP
isCriticalEngineCondition = FALSE;
#endif
}
void Engine::resetEngineSnifferIfInTestMode() {
#if EFI_ENGINE_SNIFFER
if (isFunctionalTestMode) {

View File

@ -354,8 +354,6 @@ public:
bool isRunningPwmTest = false;
FsioState fsioState;
/**
* are we running any kind of functional test? this affect
* some areas

View File

@ -72,33 +72,6 @@ public:
warningBuffer_t recentWarnings;
};
class FsioState {
public:
FsioState();
#if EFI_UNIT_TEST
float mockFan = 0;
float mockCrankingRpm = 0;
float mockTimeSinceBoot = 0;
int mockAcToggle = 0;
#endif
#if EFI_ENABLE_ENGINE_WARNING
/**
* Shall we purposely miss on some cylinders in order to attract driver's attention to some problem
* like getting too hot
*/
float isEngineWarning;
#endif /* EFI_ENABLE_ENGINE_WARNING */
#if EFI_ENABLE_CRITICAL_ENGINE_STOP
/**
* Shall we stop engine due to some critical condition in order to save the engine
*/
float isCriticalEngineCondition;
#endif /* EFI_ENABLE_CRITICAL_ENGINE_STOP */
};
/**
* 6 crossing over 50% TPS means pressing and releasing three times
* TODO: looks like this code is not finished / not used?

View File

@ -218,11 +218,10 @@ FsioResult LECalculator::processElement(const LEElement *element) {
int sensorIdx = static_cast<int>(SensorType::Aux1) + index;
return Sensor::get(static_cast<SensorType>(sensorIdx));
}
default:
case LE_UNDEFINED:
warning(CUSTOM_UNKNOWN_FSIO, "FSIO undefined action");
return unexpected;
default:
return getEngineValue(element->action);
}
}

View File

@ -20,8 +20,6 @@
typedef Map3D<SCRIPT_TABLE_8, SCRIPT_TABLE_8, float, uint16_t, uint16_t> fsio8_Map3D_f32t;
typedef Map3D<SCRIPT_TABLE_8, SCRIPT_TABLE_8, uint8_t, uint16_t, uint16_t> fsio8_Map3D_u8t;
expected<float> getEngineValue(le_action_e action);
void initFsioImpl();
float getCurveValue(int index, float key);

View File

@ -9,248 +9,6 @@
#include "pch.h"
#include "fsio_impl.h"
#include "cli_registry.h"
#define TEST_POOL_SIZE 256
FsioResult getEngineValue(le_action_e action) {
switch(action) {
case LE_METHOD_FAN:
return engine->fsioState.mockFan;
case LE_METHOD_COOLANT:
return Sensor::getOrZero(SensorType::Clt);
case LE_METHOD_RPM:
return Sensor::getOrZero(SensorType::Rpm);
case LE_METHOD_CRANKING_RPM:
return engine->fsioState.mockCrankingRpm;
case LE_METHOD_VBATT:
return 12;
case LE_METHOD_AC_TOGGLE:
return getAcToggle();
case LE_METHOD_IS_COOLANT_BROKEN:
return 0;
default:
firmwareError(OBD_PCM_Processor_Fault, "FSIO: No mock value for %d", action);
return unexpected;
}
}
TEST(fsio, testTokenizer) {
char buffer[64];
ASSERT_TRUE(strEqualCaseInsensitive("hello", "HELlo"));
ASSERT_FALSE(strEqualCaseInsensitive("hello", "HElo2"));
const char *ptr;
ptr = getNextToken(" hello ", buffer, sizeof(buffer));
ASSERT_TRUE(strEqual("hello", buffer));
ptr = getNextToken("hello", buffer, sizeof(buffer));
ASSERT_TRUE(strEqual("hello", buffer));
ptr = getNextToken(" hello world ", buffer, sizeof(buffer));
ASSERT_TRUE(strEqual("hello", buffer));
ptr = getNextToken(ptr, buffer, sizeof(buffer));
ASSERT_TRUE(strEqual("world", buffer));
ASSERT_TRUE(isNumeric("123"));
ASSERT_FALSE(isNumeric("a123"));
}
TEST(fsio, testParsing) {
LEElement thepool[TEST_POOL_SIZE];
LEElementPool pool(thepool, TEST_POOL_SIZE);
LEElement *element = pool.parseExpression("1 3 AND not");
ASSERT_TRUE(element != NULL);
ASSERT_EQ(element[0].action, LE_NUMERIC_VALUE);
ASSERT_EQ(element[0].fValue, 1.0);
ASSERT_EQ(element[1].action, LE_NUMERIC_VALUE);
ASSERT_EQ(element[1].fValue, 3.0);
ASSERT_EQ(element[2].action, LE_OPERATOR_AND);
ASSERT_EQ(element[3].action, LE_OPERATOR_NOT);
// last should be a return instruction
ASSERT_EQ(element[4].action, LE_METHOD_RETURN);
ASSERT_EQ(pool.getSize(), 5);
}
TEST(fsio, parsingMultiple) {
LEElement poolArr[TEST_POOL_SIZE];
LEElementPool pool(poolArr, TEST_POOL_SIZE);
LEElement* p1 = pool.parseExpression("2");
ASSERT_EQ(p1[0].action, LE_NUMERIC_VALUE);
ASSERT_EQ(p1[0].fValue, 2);
ASSERT_EQ(p1[1].action, LE_METHOD_RETURN);
LEElement* p2 = pool.parseExpression("4");
ASSERT_EQ(p2[0].action, LE_NUMERIC_VALUE);
ASSERT_EQ(p2[0].fValue, 4);
ASSERT_EQ(p2[1].action, LE_METHOD_RETURN);
// Check that they got allocated sequentially without overlap
ASSERT_EQ(p2 - p1, 2);
}
static void testExpression2(float selfValue, const char *line, float expected, Engine *engine) {
LEElement thepool[TEST_POOL_SIZE];
LEElementPool pool(thepool, TEST_POOL_SIZE);
LEElement * element = pool.parseExpression(line);
printf("Parsing [%s]\n", line);
ASSERT_TRUE(element != NULL) << "Not NULL expected";
LECalculator c;
ASSERT_NEAR(expected, c.evaluate("test", selfValue, element), EPS4D) << line;
}
static void testExpression2(float selfValue, const char *line, float expected, const std::unordered_map<SensorType, float>& sensorVals = {}) {
EngineTestHelper eth(FORD_INLINE_6_1995, sensorVals);
testExpression2(selfValue, line, expected, engine);
}
static void testExpression(const char *line, float expectedValue, const std::unordered_map<SensorType, float>& sensorVals = {}) {
testExpression2(0, line, expectedValue, sensorVals);
}
TEST(fsio, testHysteresisSelf) {
EngineTestHelper eth(FORD_INLINE_6_1995);
LEElement thepool[TEST_POOL_SIZE];
LEElementPool pool(thepool, TEST_POOL_SIZE);
// value ON: 450
// value OFF: 400
// Human formula: (self and (rpm > 400)) | (rpm > 450)
LEElement * element = pool.parseExpression("self rpm 400 > and rpm 450 > |");
ASSERT_TRUE(element != NULL) << "Not NULL expected";
LECalculator c;
double selfValue = 0;
Sensor::setMockValue(SensorType::Rpm, 0);
selfValue = c.evaluate("test", selfValue, element);
ASSERT_EQ(0, selfValue);
Sensor::setMockValue(SensorType::Rpm, 430);
selfValue = c.evaluate("test", selfValue, element);
// OFF since not ON yet
ASSERT_EQ(0, selfValue);
Sensor::setMockValue(SensorType::Rpm, 460);
selfValue = c.evaluate("test", selfValue, element);
ASSERT_EQ(1, selfValue);
Sensor::setMockValue(SensorType::Rpm, 430);
selfValue = c.evaluate("test", selfValue, element);
// OFF since was ON yet
ASSERT_EQ(1, selfValue);
}
TEST(fsio, testLiterals) {
// Constants - single token
testExpression("123", 123.0f);
testExpression("true", 1);
testExpression("false", 0);
}
TEST(fsio, mathOperators) {
// Test basic operations
testExpression("123 456 +", 579);
testExpression("123 456 -", -333);
testExpression("123 456 *", 56088);
testExpression("123 456 /", 0.269737f);
}
TEST(fsio, comparisonOperators) {
// Comparison operators
testExpression("123 456 >", 0);
testExpression("123 456 >=", 0);
testExpression("123 456 <", 1);
testExpression("123 456 <=", 1);
testExpression("123 456 min", 123);
testExpression("123 456 max", 456);
}
TEST(fsio, booleanOperators) {
// Boolean operators
testExpression("true true and", 1);
testExpression("true false and", 0);
testExpression("true false or", 1);
testExpression("false false or", 0);
// (both ways to write and/or)
testExpression("true true &", 1);
testExpression("true false &", 0);
testExpression("true false |", 1);
testExpression("false false |", 0);
// not operator
testExpression("true not", 0);
testExpression("false not", 1);
}
TEST(fsio, extraOperators) {
// Self operator
testExpression2(123, "self 1 +", 124);
// ternary operator
testExpression("1 22 33 if", 22);
testExpression("0 22 33 if", 33);
}
TEST(fsio, invalidFunction) {
EXPECT_FATAL_ERROR(testExpression("bogus_function", 0));
EXPECT_FATAL_ERROR(testExpression("1 2 + bogus_expression *", 0));
}
TEST(fsio, testLogicExpressions) {
/**
* fan = (not fan && coolant > 90) OR (fan && coolant > 85)
* fan = fan NOT coolant 90 AND more fan coolant 85 more AND OR
*/
std::unordered_map<SensorType, float> sensorVals = {{SensorType::Clt, 100}};
testExpression("coolant 1 +", 101, sensorVals);
testExpression("fan", 0, sensorVals);
testExpression("fan not", 1, sensorVals);
testExpression("coolant 90 >", 1, sensorVals);
testExpression("fan not coolant 90 > and", 1, sensorVals);
testExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR", 1, sensorVals);
{
EngineTestHelper eth(FORD_INLINE_6_1995, sensorVals);
LEElement thepool[TEST_POOL_SIZE];
LEElementPool pool(thepool, TEST_POOL_SIZE);
LEElement * element = pool.parseExpression("fan NOT coolant 90 > AND fan coolant 85 > AND OR");
ASSERT_TRUE(element != NULL) << "Not NULL expected";
LECalculator c;
ASSERT_EQ( 1, c.evaluate("test", 0, element)) << "that expression";
ASSERT_EQ(12, c.currentCalculationLogPosition);
ASSERT_EQ(102, c.calcLogAction[0]);
ASSERT_EQ(0, c.calcLogValue[0]);
}
{
EngineTestHelper eth(FORD_INLINE_6_1995, sensorVals);
Sensor::setMockValue(SensorType::Rpm, 900);
engine->fsioState.mockCrankingRpm = 200;
testExpression2(0, "rpm", 900, engine);
testExpression2(0, "cranking_rpm", 200, engine);
testExpression2(0, STARTER_RELAY_LOGIC, 0, engine);
testExpression2(0, "rpm cranking_rpm > ", 1, engine);
}
}
extern int timeNowUs;
TEST(fsio, fuelPump) {
@ -292,39 +50,3 @@ TEST(fsio, fuelPump) {
// Pump should be on!
EXPECT_TRUE(efiReadPin(GPIOA_0));
}
TEST(fsio, fsioValueFloat) {
FsioValue floatVal(3.5f);
EXPECT_TRUE(floatVal.isFloat());
EXPECT_FALSE(floatVal.isBool());
EXPECT_FLOAT_EQ(floatVal.asFloat(), 3.5f);
}
TEST(fsio, fsioValueFloatZero) {
FsioValue floatVal(0.0f);
EXPECT_TRUE(floatVal.isFloat());
EXPECT_FALSE(floatVal.isBool());
EXPECT_FLOAT_EQ(floatVal.asFloat(), 0);
}
TEST(fsio, fsioValueBoolTrue) {
FsioValue boolVal(true);
EXPECT_TRUE(boolVal.isBool());
EXPECT_FALSE(boolVal.isFloat());
EXPECT_TRUE(boolVal.asBool());
}
TEST(fsio, fsioValueBoolFalse) {
FsioValue boolVal(false);
EXPECT_TRUE(boolVal.isBool());
EXPECT_FALSE(boolVal.isFloat());
EXPECT_FALSE(boolVal.asBool());
}