auto-sync

This commit is contained in:
rusEfi 2016-08-30 22:02:21 -04:00
parent 2fc291fb93
commit 0e833c4e35
4 changed files with 18 additions and 7 deletions

View File

@ -89,8 +89,7 @@
EXTERN_ENGINE
;
// todo: eliminate this magic constant, read from some relevant offset
#define LIVE_TUNING 6200
extern persistent_config_container_s persistentState;
extern short currentPageId;
@ -242,10 +241,15 @@ void handlePageSelectCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
tsSendResponse(tsChannel, mode, NULL, 0);
}
void yellowMagic(int currentPageId, int offset, int count) {
if (offset > LIVE_TUNING) {
static void onlineTuneBytes(int currentPageId, int offset, int count) {
if (offset > sizeof(engine_configuration_s)) {
int maxSize = sizeof(engine_configuration_s) - offset;
if (count > maxSize) {
warning(CUSTOM_OBD_99, "TS overflow %d %d", offset, count);
return;
}
scheduleMsg(&tsLogger, "applying soft change from %d length %d", offset, count);
memcpy(((char*) engineConfiguration) + offset, ((char*) &configWorkingCopy.engineConfiguration) + offset,
memcpy(((char*) &persistentState.persistentConfiguration) + offset, ((char*) &configWorkingCopy) + offset,
count);
}
}
@ -283,7 +287,7 @@ void handleWriteChunkCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
uint8_t * addr = (uint8_t *) (getWorkingPageAddr(currentPageId) + offset);
memcpy(addr, content, count);
yellowMagic(currentPageId, offset, count);
onlineTuneBytes(currentPageId, offset, count);
tsSendResponse(tsChannel, mode, NULL, 0);
}
@ -339,7 +343,7 @@ void handleWriteValueCommand(ts_channel_s *tsChannel, ts_response_format_e mode,
getWorkingPageAddr(currentPageId)[offset] = value;
yellowMagic(currentPageId, offset, 1);
onlineTuneBytes(currentPageId, offset, 1);
// scheduleMsg(logger, "va=%d", configWorkingCopy.boardConfiguration.idleValvePin);
}

View File

@ -98,6 +98,9 @@ Engine::Engine(persistent_config_s *config) {
isEngineChartEnabled = false;
sensorChartMode = SC_OFF;
actualLastInjection = 0;
fuelScheduleForThisEngineCycle = NULL;
isAlternatorControlEnabled = false;
wallFuelCorrection = 0;
/**
* it's important for fixAngle() that engineCycle field never has zero
*/

View File

@ -28,6 +28,7 @@ InjectionEvent::InjectionEvent() {
isSimultanious = false;
isOverlapping = false;
injectorIndex = 0;
output = NULL;
}
event_trigger_position_s::event_trigger_position_s() {

View File

@ -40,6 +40,9 @@ extern engine_pins_s enginePins;
* @return number of milliseconds in one crank shaft revolution
*/
floatms_t getCrankshaftRevolutionTimeMs(int rpm) {
if (rpm == 0) {
return NAN;
}
return 360 * getOneDegreeTimeMs(rpm);
}