Trigger: warning code on normal engine start up #669

This commit is contained in:
Andrey 2021-06-23 05:22:08 -04:00
parent cbfc4cdd8d
commit 74c5a80cac
3 changed files with 37 additions and 16 deletions

View File

@ -6,12 +6,12 @@ TESTS_SRC_CPP = \
tests/trigger/test_cam_vvt_input.cpp \
tests/trigger/test_2jz_vvt.cpp \
tests/trigger/test_real_cranking_miata_NA.cpp \
tests/trigger/test_real_cranking_miata_na6.cpp \
tests/trigger/test_quad_cam.cpp \
tests/trigger/test_override_gaps.cpp \
tests/trigger/test_injection_scheduling.cpp \
tests/ignition_injection/injection_mode_transition.cpp \
tests/ignition_injection/test_startOfCrankingPrimingPulse.cpp \
tests/ignition_injection/test_miata_na6_real_cranking.cpp \
tests/ignition_injection/test_multispark.cpp \
tests/ignition_injection/test_ignition_scheduling.cpp \
tests/ignition_injection/test_fuelCut.cpp \

View File

@ -5,17 +5,31 @@
* @author Andrey Belomutskiy, (c) 2012-2021
*/
#define _POSIX_C_SOURCE 200809L
#define _GNU_SOURCE
#include "engine_test_helper.h"
#include <string>
TEST(cranking, realNA) {
static constexpr trigger_event_e riseEvents[] = { SHAFT_PRIMARY_RISING, SHAFT_SECONDARY_RISING, SHAFT_3RD_RISING };
static constexpr trigger_event_e fallEvents[] = { SHAFT_PRIMARY_FALLING, SHAFT_SECONDARY_FALLING, SHAFT_3RD_FALLING };
static char* trim(char*str) {
while (str != nullptr && str[0] == ' ') {
str++;
}
return str;
}
TEST(cranking, realCrankingFromFile) {
FILE *fp = fopen("tests/trigger/recourses/cranking_na_3.csv", "r");
ASSERT_TRUE(fp != nullptr);
WITH_ENGINE_TEST_HELPER(MIATA_NA6_MAP);
ssize_t read;
char buffer[255];
bool currentState[2];
int index = -1;
while (fgets(buffer, sizeof(buffer), fp)) {
index++;
@ -26,19 +40,26 @@ TEST(cranking, realNA) {
const char s[2] = ",";
char *line = buffer;
char *token;
char *timeStampstr = trim(strtok(line, s));
bool newState[2];
newState[0] = trim(strtok(NULL, s))[0] == '1';
newState[1] = trim(strtok(NULL, s))[0] == '1';
/* get the first token */
token = strtok(line, s);
double timeStamp = std::stod(timeStampstr);
/* walk through other tokens */
while (token != NULL) {
// printf(" %s\n", token);
eth.setTimeAndInvokeEventsUs(1'000'000 * timeStamp);
for (int index = 0;index <2;index ++) {
if (currentState[index] == newState[index]) {
continue;
}
trigger_event_e event = (newState[index] ? riseEvents : fallEvents)[index];
efitick_t nowNt = getTimeNowNt();
// engine->triggerCentral.handleShaftSignal(event, nowNt PASS_ENGINE_PARAMETER_SUFFIX);
token = strtok(NULL, s);
currentState[index] = newState[index];
}
}
ASSERT_TRUE(fp != nullptr);
}

View File

@ -1,5 +1,5 @@
/*
* test_miata_na6_real_cranking.cpp
* test_real_cranking_miata_na6.cpp
*
* @date May 11, 2019
* @author Andrey Belomutskiy, (c) 2012-2020
@ -32,14 +32,14 @@ static void fireTriggerEvent(EngineTestHelper*eth, double timestampS, int channe
engine->triggerCentral.handleShaftSignal(event, getTimeNowNt() PASS_ENGINE_PARAMETER_SUFFIX);
}
TEST(miataNA6, realCranking) {
TEST(cranking, hardcodedRealCranking) {
WITH_ENGINE_TEST_HELPER(MIATA_NA6_VAF);
unitTestWarningCodeState.clear();
#define EVENT(timestamp, channel, value) { fireTriggerEvent(&eth, timestamp, channel, value); }
/*
* generates using logicdata2c tool
*
* Generated using logicdata2c tool
*/
/* 3 */ EVENT(/* timestamp*/0.597303, /*index*/0, /*value*/false);