WTF is wrong with MRE_miata_na6 config? operationMode complexity #898

fatal error is the best I can come up with quickly
This commit is contained in:
rusefi 2019-08-08 22:57:22 -04:00
parent 539cd8b1c7
commit e0acec2a63
6 changed files with 33 additions and 6 deletions

View File

@ -62,6 +62,15 @@ void Engine::eInitializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_SU
engineConfiguration->ambiguousOperationMode,
engineConfiguration->useOnlyRisingEdgeForTrigger, &engineConfiguration->trigger));
if (TRIGGER_SHAPE(bothFrontsRequired) && engineConfiguration->useOnlyRisingEdgeForTrigger) {
#if EFI_PROD_CODE || EFI_SIMULATOR
firmwareError(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "Inconsistent trigger setup");
#else
warning(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "Inconsistent trigger setup");
#endif
}
if (!TRIGGER_SHAPE(shapeDefinitionError)) {
/**
* this instance is used only to initialize 'this' TriggerShape instance

View File

@ -2066,7 +2066,7 @@ typedef enum {
CUSTOM_CJ125_1 = 6701,
CUSTOM_CJ125_2 = 6702,
CUSTOM_ERR_6703 = 6703,
CUSTOM_ERR_6704 = 6704,
CUSTOM_ERR_BOTH_FRONTS_REQUIRED = 6704,
CUSTOM_TLE8888 = 6705,
CUSTOM_ERR_6706 = 6706,
CUSTOM_ERR_6707 = 6707,

View File

@ -25,6 +25,8 @@ void initializeMazdaMiataNaShape(TriggerShape *s) {
s->setTriggerSynchronizationGap2(1.4930 * 0.6f, 1.4930 * 1.3f);
s->useRiseEdge = false;
s->bothFrontsRequired = true;
s->tdcPosition = 294;
s->isSynchronizationNeeded = true;
@ -104,6 +106,8 @@ static void initializeMazdaMiataNb1ShapeWithOffset(TriggerShape *s, float offset
s->setTriggerSynchronizationGap(0.11f);
s->useRiseEdge = false;
s->bothFrontsRequired = true;
s->invertOnAdd = true;
s->tdcPosition = 276;
@ -158,6 +162,8 @@ void configureMazdaProtegeSOHC(TriggerShape *s) {
// float w = 720 / 4 * 0.215;
float a = 5;
s->bothFrontsRequired = true;
float z = 0.093;
a = 180;
s->addEvent720(a - z * 720, T_PRIMARY, TV_RISE);

View File

@ -62,6 +62,7 @@ TriggerShape::TriggerShape() :
void TriggerShape::initialize(operation_mode_e operationMode, bool needSecondTriggerInput) {
isSynchronizationNeeded = true; // that's default value
bothFrontsRequired = false;
this->needSecondTriggerInput = needSecondTriggerInput;
memset(expectedDutyCycle, 0, sizeof(expectedDutyCycle));
memset(eventAngles, 0, sizeof(eventAngles));

View File

@ -103,6 +103,16 @@ public:
*/
bool shapeDefinitionError;
/**
* https://github.com/rusefi/rusefi/issues/898
* User can choose for example Miata trigger which is not compatible with useOnlyRisingEdgeForTrigger option
* Such contradictory configuration causes a very hard to identify issue and for the sake of usability it's better to
* just crash with a very visible fatal error
*
* One day a nicer implementation could be simply ignoring 'useOnlyRisingEdgeForTrigger' in case of 'bothFrontsRequired'
*/
bool bothFrontsRequired;
/**
* this variable is incremented after each trigger shape redefinition
* See also

View File

@ -6,6 +6,7 @@
*/
#include "engine_test_helper.h"
extern WarningCodeState unitTestWarningCodeState;
static void boardConfigurationForIssue898(engine_configuration_s *engineConfiguration) {
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
@ -14,12 +15,12 @@ static void boardConfigurationForIssue898(engine_configuration_s *engineConfigur
}
TEST(issues, issue898) {
// works without extra board settings
EngineTestHelper eth(MRE_MIATA_NA6);
// fails like this with self-contradictory trigger definition
// EngineTestHelper eth(MRE_MIATA_NA6, &boardConfigurationForIssue898);
EngineTestHelper eth(MRE_MIATA_NA6, &boardConfigurationForIssue898);
EXPAND_EngineTestHelper;
ASSERT_EQ(TRUE, engine->triggerCentral.triggerShape.shapeDefinitionError) << "MRE_MIATA_NA6 shapeDefinitionError";
ASSERT_EQ(0, engine->triggerCentral.triggerShape.shapeDefinitionError) << "MRE_MIATA_NA6 shapeDefinitionError";
ASSERT_EQ( 2, unitTestWarningCodeState.recentWarnings.getCount()) << "warningCounter#testFuelSchedulerBug299smallAndMedium";
ASSERT_EQ(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, unitTestWarningCodeState.recentWarnings.get(0));
ASSERT_EQ(CUSTOM_ERR_TRIGGER_SYNC, unitTestWarningCodeState.recentWarnings.get(1));
}