diff --git a/firmware/config/engines/honda_k_dbc.cpp b/firmware/config/engines/honda_k_dbc.cpp index fda9a06e47..94238c7e39 100644 --- a/firmware/config/engines/honda_k_dbc.cpp +++ b/firmware/config/engines/honda_k_dbc.cpp @@ -23,6 +23,8 @@ void setProteusHondaElement2003() { // engineConfiguration->trigger.customTotalToothCount = 12; // engineConfiguration->trigger.customSkippedToothCount = 0; + engineConfiguration->engineSyncCam = 1; + engineConfiguration->trigger.type = TT_HONDA_K_CRANK_12_1; engineConfiguration->globalTriggerAngleOffset = 675; @@ -30,7 +32,7 @@ void setProteusHondaElement2003() { // engineConfiguration->globalTriggerAngleOffset = 570; engineConfiguration->vvtMode[0] = VVT_HONDA_K_INTAKE; - engineConfiguration->vvtMode[1] = VVT_FIRST_HALF; + engineConfiguration->vvtMode[1] = VVT_HONDA_K_EXHAUST; engineConfiguration->vvtOffsets[0] = -41; engineConfiguration->map.sensor.type = MT_DENSO183; diff --git a/unit_tests/logicdata_csv_reader.cpp b/unit_tests/logicdata_csv_reader.cpp index 01df806a11..a0fae3bf2b 100644 --- a/unit_tests/logicdata_csv_reader.cpp +++ b/unit_tests/logicdata_csv_reader.cpp @@ -104,8 +104,15 @@ void CsvReader::processLine(EngineTestHelper *eth) { efitick_t nowNt = getTimeNowNt(); TriggerValue event = newVvtState[vvtIndex] ^ engineConfiguration->invertCamVVTSignal ? TriggerValue::RISE : TriggerValue::FALL; // todo: configurable selection of vvt mode - dual bank or dual cam single bank - int bankIndex = vvtIndex; - int camIndex = 0; + int bankIndex; + int camIndex; + if (twoBanksSingleCamMode) { + bankIndex = vvtIndex; + camIndex = 0; + } else { + bankIndex = vvtIndex / 2; + camIndex = vvtIndex % 2; + } hwHandleVvtCamSignal(event, nowNt, bankIndex *2 + camIndex); currentVvtState[vvtIndex] = newVvtState[vvtIndex]; diff --git a/unit_tests/logicdata_csv_reader.h b/unit_tests/logicdata_csv_reader.h index 8c35b6d695..a6dc5aa3c9 100644 --- a/unit_tests/logicdata_csv_reader.h +++ b/unit_tests/logicdata_csv_reader.h @@ -9,6 +9,8 @@ const int NORMAL_ORDER[2] = {0, 1}; const int REVERSE_ORDER[2] = {1, 0}; + + class CsvReader { public: CsvReader(size_t triggerCount, size_t vvtCount) : CsvReader(triggerCount, vvtCount, 0.0) {} @@ -20,6 +22,8 @@ public: } ~CsvReader(); + bool twoBanksSingleCamMode = true; + void open(const char *fileName, const int* triggerColumnIndeces = NORMAL_ORDER, const int *vvtColumnIndeces = NORMAL_ORDER); bool haveMore(); void processLine(EngineTestHelper *eth); diff --git a/unit_tests/tests/trigger/test_real_k20.cpp b/unit_tests/tests/trigger/test_real_k20.cpp index ad3c7d6a2a..e05b963e9f 100644 --- a/unit_tests/tests/trigger/test_real_k20.cpp +++ b/unit_tests/tests/trigger/test_real_k20.cpp @@ -2,20 +2,34 @@ #include "logicdata_csv_reader.h" +static int getExhaustIndex() { + return getTriggerCentral()->vvtState[/*bankIndex*/0][/*camIndex*/1].currentCycle.current_index; +} + TEST(realk20, cranking) { CsvReader reader(/* triggerCount */ 1, /* vvtCount */ 2); reader.open("tests/trigger/resources/civic-K20-cranking.csv", NORMAL_ORDER, REVERSE_ORDER); + reader.twoBanksSingleCamMode = false; EngineTestHelper eth (PROTEUS_HONDA_K); - while (reader.haveMore()) { + while (reader.haveMore() && reader.lineIndex() < 101) { reader.processLine(ð); + ASSERT_EQ(getExhaustIndex(), 0) << "Skipping until first exhaust event " << reader.lineIndex(); } + reader.haveMore(); + reader.processLine(ð); + ASSERT_EQ(getExhaustIndex(), 1) << "First exhaust event " << reader.lineIndex(); + + + while (reader.haveMore()) { + reader.processLine(ð); + ASSERT_TRUE(getExhaustIndex() != 0 ) << "At line " << reader.lineIndex(); + } + + ASSERT_EQ(173, getExhaustIndex()); // huh? not synching? + ASSERT_EQ(1182, round(Sensor::getOrZero(SensorType::Rpm))); - - } - -