This commit is contained in:
Andrey 2024-03-06 20:37:17 -05:00
parent 534d619470
commit 9b1cabef1e
1 changed files with 11 additions and 6 deletions

View File

@ -8,11 +8,12 @@
#include "pch.h"
#include "logicdata_csv_reader.h"
static void test(int engineSyncCam, float camOffsetAdd) {
static void test(int engineSyncCam, float camOffsetAdd, int warningsCount) {
CsvReader reader(1, /* vvtCount */ 2);
reader.open("tests/trigger/resources/nissan_vq40_cranking-1.csv");
EngineTestHelper eth (engine_type_e::HELLEN_121_NISSAN_6_CYL);
setWholeTimingTable(0);
engineConfiguration->isFasterEngineSpinUpEnabled = false;
engineConfiguration->alwaysInstantRpm = true;
@ -49,17 +50,21 @@ static void test(int engineSyncCam, float camOffsetAdd) {
ASSERT_EQ(102, round(Sensor::getOrZero(SensorType::Rpm)))<< reader.lineIndex();
// TODO: why warnings?
ASSERT_EQ(2, eth.recentWarnings()->getCount());
ASSERT_EQ(ObdCode::CUSTOM_OUT_OF_ORDER_COIL, eth.recentWarnings()->get(0).Code); // this is from a coil being protected by overdwell protection
ASSERT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(1).Code);
ASSERT_EQ(warningsCount, eth.recentWarnings()->getCount());
if (warningsCount == 2) {
ASSERT_EQ(ObdCode::CUSTOM_OUT_OF_ORDER_COIL, eth.recentWarnings()->get(0).Code); // this is from a coil being protected by overdwell protection
ASSERT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(1).Code);
} else {
ASSERT_EQ(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, eth.recentWarnings()->get(0).Code);
}
}
// On Nissan VQ, all cams have the same pattern, so all should be equally good for engine sync. Check them all!
TEST(realCrankingVQ40, normalCrankingSyncCam1) {
test(1, 0);
test(1, 0, 1);
}
TEST(realCrankingVQ40, normalCrankingSyncCam2) {
test(2, -360);
test(2, -360, 2);
}