auto-sync

This commit is contained in:
rusEfi 2016-07-14 23:02:55 -04:00
parent 3e469df698
commit 4324659896
12 changed files with 91 additions and 70 deletions

View File

@ -102,6 +102,9 @@ void setToyota_2jz_vics(DECLARE_ENGINE_PARAMETER_F) {
boardConfiguration->isSdCardEnabled = true;
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
engineConfiguration->trigger.type = TT_2JZ_3_34;
}

View File

@ -81,6 +81,7 @@ typedef struct {
unsigned int isAcSwitchEngaged : 1; // bit 4
unsigned int isTriggerError : 1; // bit 5
unsigned int hasFatalError : 1; // bit 6
unsigned int isWarnNow : 1; // bit 7
int tsConfigVersion;
egt_values_s egtValues;
float rpmAcceleration;

View File

@ -638,7 +638,10 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->baseFuel = engine->engineState.baseFuel;
tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection);
tsOutputChannels->timeSeconds = getTimeNowSeconds();
efitimesec_t now = getTimeNowSeconds();
tsOutputChannels->timeSeconds = now;
tsOutputChannels->isWarnNow = isWarningNow(now);
if (engineConfiguration->debugMode == DBG_TPS_ACCEL) {
tsOutputChannels->debugIntField1 = engine->tpsAccelEnrichment.cb.getSize();

View File

@ -139,6 +139,7 @@ EngineState::EngineState() {
tpsAccelEnrich = 0;
tChargeK = 0;
currentVE = 0;
timeOfPreviousWarning = -10;
}
void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_F) {

View File

@ -124,6 +124,7 @@ public:
int warningCounter;
int lastErrorCode;
efitimesec_t timeOfPreviousWarning;
float airMass;

View File

@ -18,6 +18,7 @@ int getVtSizeEstimate(void);
#include "obd_error_codes.h"
#include "efifeatures.h"
#include "stdbool.h"
#include "rusefi_types.h"
void assertVtList(void);
@ -27,6 +28,7 @@ void assertVtList(void);
*
*/
int warning(obd_code_e code, const char *fmt, ...);
bool isWarningNow(efitimesec_t now);
/**
* Something really bad had happened - firmware cannot function
*

View File

@ -8,9 +8,12 @@
#define CONTROLLERS_ALGO_RUSEFI_TYPES_H_
#include <stdint.h>
#include <sys/types.h>
#include "rusefi_enums.h"
#include "rusefi_generated.h"
// time in seconds
typedef time_t efitimesec_t;
/**
* integer time in milliseconds

View File

@ -176,7 +176,7 @@ efitimems_t currentTimeMillis(void) {
}
// todo: this overflows pretty fast!
int getTimeNowSeconds(void) {
efitimesec_t getTimeNowSeconds(void) {
return currentTimeMillis() / 1000;
}

View File

@ -16,7 +16,6 @@
#include "lcd_HD44780.h"
#endif /* EFI_HD44780_LCD */
static time_t timeOfPreviousWarning = -10;
static LoggingWithStorage logger("error handling");
EXTERN_ENGINE;
@ -55,6 +54,10 @@ static char warningBuffer[WARNING_BUFFER_SIZE];
static bool isWarningStreamInitialized = false;
static MemoryStream warningStream;
bool isWarningNow(efitimesec_t now) {
return absI(now - engine->engineState.timeOfPreviousWarning) < 10;
}
/**
* OBD_PCM_Processor_Fault is the general error code for now
*
@ -64,10 +67,10 @@ int warning(obd_code_e code, const char *fmt, ...) {
efiAssert(isWarningStreamInitialized, "warn stream", false);
UNUSED(code);
int now = getTimeNowSeconds();
if (absI(now - timeOfPreviousWarning) < 10 || !warningEnabled)
efitimesec_t now = getTimeNowSeconds();
if (isWarningNow(now) || !warningEnabled)
return true; // we just had another warning, let's not spam
timeOfPreviousWarning = now;
engine->engineState.timeOfPreviousWarning = now;
engine->engineState.warningCounter++;
engine->engineState.lastErrorCode = code;

View File

@ -55,7 +55,7 @@ efitimems_t currentTimeMillis(void);
/**
* @brief Current system time in seconds.
*/
int getTimeNowSeconds(void);
efitimesec_t getTimeNowSeconds(void);
#ifdef __cplusplus
}

View File

@ -46,69 +46,71 @@ void initialize2jzGE1_12(TriggerShape *s) {
}
void initialize2jzGE3_34(TriggerShape *s) {
s->initialize(FOUR_STROKE_CAM_SENSOR, true);
setToothedWheelConfiguration(s, 36, 2, FOUR_STROKE_CRANK_SENSOR);
float camD = 720 / 6; // 120
float crankAngle = 20; // skipping two teeth
for (int i = 0; i < 10; i++) {
s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
crankAngle += 10;
} // 2 + 10
float camAngle = 0;
camAngle += camD;
s->addEvent(camAngle, T_PRIMARY, TV_RISE, -1, 721); // 120
for (int i = 0; i < 12; i++) {
s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
crankAngle += 10;
} // 2 + 22
camAngle += camD;
s->addEvent(camAngle, T_PRIMARY, TV_FALL, -1, 721); // 240
for (int i = 0; i < 12; i++) {
s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
crankAngle += 10;
} // 2 + 34
camAngle += camD;
s->addEvent(camAngle, T_PRIMARY, TV_RISE, -1, 721); // 360
crankAngle += 20; // skipping two teeth one more time
for (int i = 0; i < 10; i++) {
s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
crankAngle += 10;
} // 2 + 10
camAngle += camD;
s->addEvent(camAngle, T_PRIMARY, TV_FALL, -1, 721); // 480
for (int i = 0; i < 12; i++) {
s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
crankAngle += 10;
} // 2 + 22
camAngle += camD;
s->addEvent(camAngle, T_PRIMARY, TV_RISE, -1, 721); // 600
for (int i = 0; i < 12; i++) {
s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
crankAngle += 10;
} // 2 + 32
camAngle += camD;
s->addEvent(camAngle, T_PRIMARY, TV_FALL, -1, 721); // 720
s->isSynchronizationNeeded = false;
// s->initialize(FOUR_STROKE_CAM_SENSOR, true);
//
// float camD = 720 / 6; // 120
//
// float crankAngle = 20; // skipping two teeth
//
// for (int i = 0; i < 10; i++) {
// s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
// s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
// crankAngle += 10;
// } // 2 + 10
//
// float camAngle = 0;
// camAngle += camD;
// s->addEvent(camAngle, T_PRIMARY, TV_RISE, -1, 721); // 120
//
// for (int i = 0; i < 12; i++) {
// s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
// s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
// crankAngle += 10;
// } // 2 + 22
//
//
// camAngle += camD;
// s->addEvent(camAngle, T_PRIMARY, TV_FALL, -1, 721); // 240
//
// for (int i = 0; i < 12; i++) {
// s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
// s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
// crankAngle += 10;
// } // 2 + 34
//
// camAngle += camD;
// s->addEvent(camAngle, T_PRIMARY, TV_RISE, -1, 721); // 360
//
// crankAngle += 20; // skipping two teeth one more time
// for (int i = 0; i < 10; i++) {
// s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
// s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
// crankAngle += 10;
// } // 2 + 10
//
// camAngle += camD;
// s->addEvent(camAngle, T_PRIMARY, TV_FALL, -1, 721); // 480
//
// for (int i = 0; i < 12; i++) {
// s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
// s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
// crankAngle += 10;
// } // 2 + 22
//
// camAngle += camD;
// s->addEvent(camAngle, T_PRIMARY, TV_RISE, -1, 721); // 600
//
//
// for (int i = 0; i < 12; i++) {
// s->addEvent(crankAngle + 5, T_SECONDARY, TV_RISE, -1, 721);
// s->addEvent(crankAngle + 9.9, T_SECONDARY, TV_FALL, -1, 721); // 120
// crankAngle += 10;
// } // 2 + 32
// camAngle += camD;
// s->addEvent(camAngle, T_PRIMARY, TV_FALL, -1, 721); // 720
//
// s->isSynchronizationNeeded = false;
}

View File

@ -804,6 +804,7 @@ fileVersion = { 20160702 }
ind_iat_error = bits, U32, 80, [3:3], "true", "false";
ind_isTriggerError = bits, U32, 80, [5:5], "true", "false";
ind_hasFatalError=bits, U32, 80, [6:6], "true", "false";
ind_isWarnNow =bits, U32, 80, [7:7], "true", "false";
firmwareTsVersion = scalar,U32, 84, "version", 1, 0
egt1 = scalar, S16, 88, "°C", 1, 0
egt2 = scalar, S16, 90, "°C", 1, 0
@ -1158,6 +1159,7 @@ fileVersion = { 20160702 }
; important status
indicator = { ind_hasFatalError }, "", "FATAL ERROR", green, black, red, black
indicator = { firmwareTsVersion == fileVersion }, "WRONG VERSION", "version", red, black, green, black
indicator = { ind_isWarnNow }, "", "warn", green, black, red, black
indicator = { ind_check_engine }, "ok", "Check engine", green, black, red, black
indicator = { isIgnitionEnabledIndicator}, "no ignition", "ignition", red, black, green, black
indicator = { ind_injection_enabled}, "no injection", "injection", red, black, green, black