Skip to content

Commit

Permalink
Usability: critical error in case of unneeded second channel #6419
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Apr 27, 2024
1 parent 4523987 commit 9b2a711
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void setBoardDefaultConfiguration() {
engineConfiguration->triggerSimulatorPins[1] = Gpio::D2;

engineConfiguration->triggerInputPins[0] = Gpio::C6;
engineConfiguration->triggerInputPins[1] = Gpio::A5;
// engineConfiguration->triggerInputPins[1] = Gpio::A5;

// set this to SPI_DEVICE_3 to enable stimulation
//engineConfiguration->digitalPotentiometerSpiDevice = SPI_DEVICE_3;
Expand Down
2 changes: 1 addition & 1 deletion firmware/config/engines/ford_1995_inline_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ void setFordInline6() {
engineConfiguration->mafAdcChannel = EFI_ADC_1;

engineConfiguration->triggerInputPins[0] = Gpio::A8;
engineConfiguration->triggerInputPins[1] = Gpio::A5;
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
}
3 changes: 3 additions & 0 deletions firmware/config/engines/ford_aspire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ void setFordAspireEngineConfiguration() {
engineConfiguration->tpsMax = 750;

engineConfiguration->rpmHardLimit = 7000;
#if HW_FRANKENSO
engineConfiguration->triggerInputPins[1] = Gpio::A5;
#endif

/**
* 18K Ohm @ -20C
Expand Down
11 changes: 11 additions & 0 deletions firmware/controllers/trigger/decoders/trigger_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,17 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperatio
warning(ObdCode::CUSTOM_ERR_NO_SHAPE, "initializeTriggerWaveform() not implemented: %d", triggerType.type);
}

if (!needSecondTriggerInput &&
#if EFI_UNIT_TEST
engineConfiguration != nullptr &&
#endif
engineConfiguration->triggerInputPins[1] != Gpio::Unassigned) {
// todo: technical debt: HW CI should not require special treatment
#ifndef HARDWARE_CI
criticalError("Single-channel trigger %s selected while two inputs were configured", getTrigger_type_e(triggerType.type));
#endif
}

/**
* Feb 2019 suggestion: it would be an improvement to remove 'expectedEventCount' logic from 'addEvent'
* and move it here, after all events were added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,11 @@ public void test2003DodgeNeon() {
EcuTestHelper.assertSomewhatClose("VBatt", 12, SensorCentral.getInstance().getValue(Sensor.VBATT));

chart = nextChart();
double x = 100;
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
assertWaveNull(msg, chart, EngineChart.SPARK_2);
assertWaveNotNull(msg, chart, EngineChart.SPARK_3);
assertWaveNull(msg, chart, EngineChart.SPARK_4);

x = 176.856;
// todo: why is width precision so low here? is that because of loaded Windows with 1ms precision?
double widthRatio = 0.25;
// WAT? this was just 0.009733333333333387?
Expand All @@ -216,14 +214,12 @@ public void test2003DodgeNeon() {
ecu.changeRpm(2700);
ecu.changeRpm(2000);
chart = nextChart();
x = 104.0;
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
assertWaveNull(msg, chart, EngineChart.SPARK_2);
assertWaveNotNull(msg, chart, EngineChart.SPARK_3);
assertWaveNull(msg, chart, EngineChart.SPARK_4);

chart = nextChart();
x = 74;
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_1);
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_2);
assertWaveNotNull(msg, chart, EngineChart.INJECTOR_3);
Expand All @@ -238,12 +234,10 @@ public void test2003DodgeNeon() {

ecu.sendCommand("set_whole_timing_map 520");
chart = nextChart();
x = 328;
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);

ecu.sendCommand("set_whole_timing_map 0");
chart = nextChart();
x = 128;
assertWaveNotNull(msg, chart, EngineChart.SPARK_1);
}

Expand Down
1 change: 1 addition & 0 deletions unit_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ GTEST_API_ int main(int argc, char **argv) {
* See TEST_FROM_TRIGGER_ID to limit test just for last trigger
*/
// setVerboseTrigger(true);
// --gtest_filter=*TEST_NAME*
//::testing::GTEST_FLAG(filter) = "*AllTriggersFixture*";
int result = RUN_ALL_TESTS();
// windows ERRORLEVEL in Jenkins batch file seems to want negative value to detect failure
Expand Down
1 change: 1 addition & 0 deletions unit_tests/tests/trigger/test_cam_vvt_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ TEST(trigger, testNoisyInput) {
TEST(trigger, testCamInput) {
// setting some weird engine
EngineTestHelper eth(engine_type_e::FORD_ESCORT_GT);
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;

// changing to 'ONE TOOTH' trigger on CRANK with CAM/VVT
setCrankOperationMode();
Expand Down
1 change: 1 addition & 0 deletions unit_tests/tests/trigger/test_quad_cam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
TEST(trigger, testQuadCamInput) {
// setting some weird engine
EngineTestHelper eth(engine_type_e::FORD_ESCORT_GT);
engineConfiguration->triggerInputPins[1] = Gpio::Unassigned;
engineConfiguration->isFasterEngineSpinUpEnabled = false;
engineConfiguration->alwaysInstantRpm = true;

Expand Down
3 changes: 1 addition & 2 deletions unit_tests/tests/trigger/test_trigger_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ extern bool debugSignalExecutor;

TEST(misc, testRpmCalculator) {
EngineTestHelper eth(engine_type_e::FORD_INLINE_6_1995);
efiAssertVoid(ObdCode::CUSTOM_ERR_6670, engineConfiguration!=NULL, "null config in engine");

setTable(config->injectionPhase, -180.0f);

Expand All @@ -190,8 +191,6 @@ TEST(misc, testRpmCalculator) {

ASSERT_EQ( 720, engine->engineState.engineCycle) << "engineCycle";

efiAssertVoid(ObdCode::CUSTOM_ERR_6670, engineConfiguration!=NULL, "null config in engine");

engineConfiguration->minimumIgnitionTiming = -15;
float timingAdvance = -13;
setWholeTimingTable(timingAdvance);
Expand Down
1 change: 1 addition & 0 deletions unit_tests/tests/trigger/test_trigger_decoder_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static auto makeTriggerShape(operation_mode_e mode, const TriggerConfiguration&
TEST(TriggerDecoder, FindsFirstSyncPoint) {
MockTriggerConfiguration cfg({trigger_type_e::TT_TOOTHED_WHEEL, 4, 1});
cfg.update();
engineConfiguration = nullptr;

auto shape = makeTriggerShape(FOUR_STROKE_CAM_SENSOR, cfg);

Expand Down

0 comments on commit 9b2a711

Please sign in to comment.