auto-sync

This commit is contained in:
rusEfi 2014-09-13 16:02:50 -05:00
parent df97e5b5ef
commit 22f3114f05
5 changed files with 28 additions and 14 deletions

View File

@ -63,30 +63,34 @@ static uint8_t intermediateLoggingBufferData[INTERMEDIATE_LOGGING_BUFFER_SIZE] C
//todo define max-printf-buffer
static bool intermediateLoggingBufferInited = FALSE;
static int validateBuffer(Logging *logging, uint32_t extraLen, const char *text) {
/**
* @returns true if data does not fit into this buffer
*/
static bool validateBuffer(Logging *logging, uint32_t extraLen, const char *text) {
if (logging->buffer == NULL) {
firmwareError("Logging not initialized: %s", logging->name);
return TRUE;
return true;
}
if (remainingSize(logging) < extraLen + 1) {
strcpy(logging->SMALL_BUFFER, "Logging buffer overflow: ");
strcat(logging->SMALL_BUFFER, logging->name);
strcat(logging->SMALL_BUFFER, "/");
strcat(logging->SMALL_BUFFER, text);
firmwareError(logging->SMALL_BUFFER);
warning(OBD_PCM_Processor_Fault, "buffer overflow %s", logging->name);
// strcpy(logging->SMALL_BUFFER, "Logging buffer overflow: ");
// strcat(logging->SMALL_BUFFER, logging->name);
// strcat(logging->SMALL_BUFFER, "/");
// strcat(logging->SMALL_BUFFER, text);
// firmwareError(logging->SMALL_BUFFER);
// unlockOutputBuffer();
// resetLogging(logging);
return TRUE;
return true;
}
return FALSE;
return false;
}
void append(Logging *logging, const char *text) {
efiAssertVoid(text != NULL, "append NULL");
uint32_t extraLen = strlen(text);
int errcode = validateBuffer(logging, extraLen, text);
if (errcode) {
int isError = validateBuffer(logging, extraLen, text);
if (isError) {
return;
}
strcpy(logging->linePointer, text);

View File

@ -163,7 +163,7 @@ typedef struct {
adc_channel_mode_e adcHwChannelEnabled[HW_MAX_ADC_INDEX];
brain_pin_e triggerInputPins[3];
int unused4;
brain_pin_e mainRelayPin;
int idleThreadPeriod;
int consoleLoopPeriod;
@ -197,7 +197,7 @@ typedef struct {
int unrealisticRpmThreashold;
int unused2;
pin_output_mode_e mainRelayPinMode;
} board_configuration_s;

View File

@ -108,6 +108,8 @@ typedef enum {
SPI_CS_4,
SPI_CS_SD_MODULE,
MAIN_RELAY,
/**
* This output pin is used to turn alternator on or off

View File

@ -84,6 +84,9 @@ void Executor::doExecute(uint64_t nowUs) {
* further invocations
*/
reentrantLock = TRUE;
/**
* It's worth noting that that the actions might be adding new actions into the queue
*/
queue.executeAll(nowUs);
if (!isLocked()) {
firmwareError("Someone has stolen my lock");

View File

@ -26,7 +26,6 @@ void EventQueue::insertTask(scheduling_s *scheduling, uint64_t timeUs, schfunc_t
if (callback == NULL)
firmwareError("NULL callback");
int alreadyPending = checkIfPending(scheduling);
if (alreadyPending || hasFirmwareError())
return;
@ -57,6 +56,12 @@ uint64_t EventQueue::getNextEventTime(uint64_t nowUs) {
firmwareError("Is this list looped #2?");
return EMPTY_QUEUE;
}
if (current->momentUs <= nowUs) {
//firmwareError("temperror: executeAll should have been called %d/%d", current->momentUs, nowUs);
// todo: looks like we end up here after 'writeconfig' (which freezes the firmware)
// todo: figure this out
continue;
}
efiAssert(current->momentUs > nowUs, "executeAll should have been called", EMPTY_QUEUE);
if (current->momentUs < result)
result = current->momentUs;