auto-sync

This commit is contained in:
rusEfi 2014-12-16 19:04:36 -06:00
parent 4294ca83f4
commit 3475bb6afb
3 changed files with 29 additions and 24 deletions

View File

@ -42,6 +42,7 @@ static cyclic_buffer errorDetection;
#if ! EFI_PROD_CODE
bool printGapRatio = false;
float actualSynchGap;
#endif /* ! EFI_PROD_CODE */
#if (EFI_PROD_CODE || EFI_SIMULATOR)
@ -154,25 +155,23 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now
bool_t isSynchronizationPoint;
if (TRIGGER_SHAPE(isSynchronizationNeeded)) {
#if ! EFI_PROD_CODE
// todo: replace printGapRatio with engineConfiguration->isPrintTriggerSynchDetails
// and merge these two sections
if (printGapRatio) {
float gap = 1.0 * currentDuration / toothed_previous_duration;
print("current gap %f\r\n", gap);
}
#else
if (engineConfiguration->isPrintTriggerSynchDetails) {
float gap = 1.0 * currentDuration / toothed_previous_duration;
scheduleMsg(&logger, "gap=%f @ %d", gap, current_index);
}
#endif /* ! EFI_PROD_CODE */
isSynchronizationPoint = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom)
&& currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo);
#if EFI_PROD_CODE
if (engineConfiguration->isPrintTriggerSynchDetails) {
#else
if (printGapRatio) {
#endif /* EFI_PROD_CODE */
float gap = 1.0 * currentDuration / toothed_previous_duration;
#if EFI_PROD_CODE
scheduleMsg(&logger, "gap=%f @ %d", gap, current_index);
#else
actualSynchGap = gap;
print("current gap %f\r\n", gap);
#endif /* EFI_PROD_CODE */
}
} else {
/**
* in case of noise the counter could be above the expected number of events
@ -196,7 +195,7 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now
#if EFI_PROD_CODE
scheduleMsg(&logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", current_index,
TRIGGER_SHAPE(expectedEventCount[0]), TRIGGER_SHAPE(expectedEventCount[1]),
TRIGGER_SHAPE(expectedEventCount[2]), eventCount[0], eventCount[1], eventCount[2]);
TRIGGER_SHAPE(expectedEventCount[2]), eventCount[0], eventCount[1], eventCount[2]);
#endif /* EFI_PROD_CODE */
}
}
@ -403,8 +402,8 @@ static uint32_t doFindTrigger(TriggerStimulatorHelper *helper, trigger_shape_s *
*
* This function finds the index of synchronization event within trigger_shape_s
*/
uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape,
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) {
uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s const*triggerConfig
DECLARE_ENGINE_PARAMETER_S) {
TriggerState state;
errorDetection.clear();

View File

@ -138,7 +138,7 @@ int main(void) {
testFLStack();
// resizeMap();
printf("Success 20131210\r\n");
printf("Success 20131216\r\n");
return EXIT_SUCCESS;
}

View File

@ -29,6 +29,7 @@
extern int timeNow;
extern bool printGapRatio;
extern float actualSynchGap;
extern "C" {
void sendOutConfirmation(char *value, int i);
@ -303,6 +304,13 @@ static void testTriggerDecoder2(const char *msg, engine_type_e type, int synchPo
assertEqualsM("channel2duty", channel2duty, t->dutyCycle[1]);
}
static void testTriggerDecoder3(const char *msg, engine_type_e type, int synchPointIndex, float channel1duty, float channel2duty, float expectedGap) {
printGapRatio = true;
testTriggerDecoder2(msg, type, synchPointIndex, channel1duty, channel2duty);
assertEqualsM("actual gap ratio", expectedGap, actualSynchGap);
printGapRatio = false;
}
void testGY6_139QMB(void) {
printf("*************************************************** testGY6_139QMB\r\n");
@ -520,12 +528,10 @@ void testTriggerDecoder(void) {
testTriggerDecoder2("testMitsu", MITSU_4G93, 3, 0.3750, 0.3889);
// testTriggerDecoder2("miata 1990", MIATA_1990, 0, 0.6280, 0.0);
testTriggerDecoder2("miata 1994", MIATA_1994_DEVIATOR, 11, 0.2917, 0.3716);
testTriggerDecoder3("miata 1994", MIATA_1994_DEVIATOR, 11, 0.2917, 0.3716, 1.5757);
testTriggerDecoder2("citroen", CITROEN_TU3JP, 0, 0.4833, 0.0);
printGapRatio = true;
testTriggerDecoder2("neon NGC", DODGE_NEON_2003, 5, 0.4861, 0.0);
printGapRatio = false;
testTriggerDecoder3("neon NGC", DODGE_NEON_2003, 5, 0.4861, 0.0, 2.9134);
testMazda323();