mirror of https://github.com/FOME-Tech/fome-fw.git
toyota 3 tooth cam decoder #237
This commit is contained in:
parent
a47bc88eae
commit
a6a25ba020
|
@ -299,14 +299,15 @@ void hwHandleVvtCamSignal(bool isRising, efitick_t nowNt, int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(engineConfiguration->vvtMode[camIndex]) {
|
switch(engineConfiguration->vvtMode[camIndex]) {
|
||||||
case VVT_2JZ:
|
case VVT_2JZ: {
|
||||||
// we do not know if we are in sync or out of sync, so we have to be looking for both possibilities
|
// Consider the tooth in the first 1/3 of the engine phase
|
||||||
if ((currentPosition < engineConfiguration->scriptSetting[4] || currentPosition > engineConfiguration->scriptSetting[5]) &&
|
bool inRange = angleFromPrimarySyncPoint > 0 && angleFromPrimarySyncPoint < (720 / 3);
|
||||||
(currentPosition < engineConfiguration->scriptSetting[4] + 360 || currentPosition > engineConfiguration->scriptSetting[5] + 360)) {
|
|
||||||
// outside of the expected range
|
if (!inRange) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
} break;
|
||||||
default:
|
default:
|
||||||
// else, do nothing
|
// else, do nothing
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,6 +20,7 @@ TESTS_SRC_CPP = \
|
||||||
tests/trigger/test_real_gm_24x.cpp \
|
tests/trigger/test_real_gm_24x.cpp \
|
||||||
tests/trigger/test_real_k24a2.cpp \
|
tests/trigger/test_real_k24a2.cpp \
|
||||||
tests/trigger/test_real_k20.cpp \
|
tests/trigger/test_real_k20.cpp \
|
||||||
|
tests/trigger/test_real_toyota_3_tooth_cam.cpp \
|
||||||
tests/trigger/test_map_cam.cpp \
|
tests/trigger/test_map_cam.cpp \
|
||||||
tests/trigger/test_rpm_multiplier.cpp \
|
tests/trigger/test_rpm_multiplier.cpp \
|
||||||
tests/trigger/test_quad_cam.cpp \
|
tests/trigger/test_quad_cam.cpp \
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,42 @@
|
||||||
|
#include "pch.h"
|
||||||
|
#include "logicdata_csv_reader.h"
|
||||||
|
|
||||||
|
TEST(realToyota3ToothCam, running) {
|
||||||
|
CsvReader reader(1, /* vvtCount */ 1);
|
||||||
|
|
||||||
|
reader.open("tests/trigger/resources/toyota_3_tooth_cam.csv");
|
||||||
|
EngineTestHelper eth(engine_type_e::TEST_ENGINE);
|
||||||
|
engineConfiguration->isFasterEngineSpinUpEnabled = true;
|
||||||
|
engineConfiguration->alwaysInstantRpm = true;
|
||||||
|
|
||||||
|
engineConfiguration->vvtMode[0] = VVT_2JZ;
|
||||||
|
engineConfiguration->vvtOffsets[0] = 152.583f;
|
||||||
|
|
||||||
|
engineConfiguration->trigger.customTotalToothCount = 36;
|
||||||
|
engineConfiguration->trigger.customSkippedToothCount = 2;
|
||||||
|
eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
|
||||||
|
|
||||||
|
bool hasSeenFirstVvt = false;
|
||||||
|
|
||||||
|
while (reader.haveMore()) {
|
||||||
|
reader.processLine(ð);
|
||||||
|
float vvt1 = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0);
|
||||||
|
|
||||||
|
if (vvt1 != 0) {
|
||||||
|
if (!hasSeenFirstVvt) {
|
||||||
|
EXPECT_NEAR(vvt1, 0, /*precision*/1);
|
||||||
|
hasSeenFirstVvt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cam position should never be reported outside of correct range
|
||||||
|
EXPECT_TRUE(vvt1 > -3 && vvt1 < 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_NEAR(engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0), 0, 1);
|
||||||
|
ASSERT_EQ(3078, round(Sensor::getOrZero(SensorType::Rpm)));
|
||||||
|
|
||||||
|
// TODO: why warnings?
|
||||||
|
ASSERT_EQ(1, eth.recentWarnings()->getCount());
|
||||||
|
ASSERT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(0).Code);
|
||||||
|
}
|
Loading…
Reference in New Issue