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 //todo define max-printf-buffer
static bool intermediateLoggingBufferInited = FALSE; 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) { if (logging->buffer == NULL) {
firmwareError("Logging not initialized: %s", logging->name); firmwareError("Logging not initialized: %s", logging->name);
return TRUE; return true;
} }
if (remainingSize(logging) < extraLen + 1) { if (remainingSize(logging) < extraLen + 1) {
strcpy(logging->SMALL_BUFFER, "Logging buffer overflow: "); warning(OBD_PCM_Processor_Fault, "buffer overflow %s", logging->name);
strcat(logging->SMALL_BUFFER, logging->name); // strcpy(logging->SMALL_BUFFER, "Logging buffer overflow: ");
strcat(logging->SMALL_BUFFER, "/"); // strcat(logging->SMALL_BUFFER, logging->name);
strcat(logging->SMALL_BUFFER, text); // strcat(logging->SMALL_BUFFER, "/");
firmwareError(logging->SMALL_BUFFER); // strcat(logging->SMALL_BUFFER, text);
// firmwareError(logging->SMALL_BUFFER);
// unlockOutputBuffer(); // unlockOutputBuffer();
// resetLogging(logging); // resetLogging(logging);
return TRUE; return true;
} }
return FALSE; return false;
} }
void append(Logging *logging, const char *text) { void append(Logging *logging, const char *text) {
efiAssertVoid(text != NULL, "append NULL"); efiAssertVoid(text != NULL, "append NULL");
uint32_t extraLen = strlen(text); uint32_t extraLen = strlen(text);
int errcode = validateBuffer(logging, extraLen, text); int isError = validateBuffer(logging, extraLen, text);
if (errcode) { if (isError) {
return; return;
} }
strcpy(logging->linePointer, text); strcpy(logging->linePointer, text);

View File

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

View File

@ -108,6 +108,8 @@ typedef enum {
SPI_CS_4, SPI_CS_4,
SPI_CS_SD_MODULE, SPI_CS_SD_MODULE,
MAIN_RELAY,
/** /**
* This output pin is used to turn alternator on or off * 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 * further invocations
*/ */
reentrantLock = TRUE; reentrantLock = TRUE;
/**
* It's worth noting that that the actions might be adding new actions into the queue
*/
queue.executeAll(nowUs); queue.executeAll(nowUs);
if (!isLocked()) { if (!isLocked()) {
firmwareError("Someone has stolen my lock"); 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) if (callback == NULL)
firmwareError("NULL callback"); firmwareError("NULL callback");
int alreadyPending = checkIfPending(scheduling); int alreadyPending = checkIfPending(scheduling);
if (alreadyPending || hasFirmwareError()) if (alreadyPending || hasFirmwareError())
return; return;
@ -57,6 +56,12 @@ uint64_t EventQueue::getNextEventTime(uint64_t nowUs) {
firmwareError("Is this list looped #2?"); firmwareError("Is this list looped #2?");
return EMPTY_QUEUE; 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); efiAssert(current->momentUs > nowUs, "executeAll should have been called", EMPTY_QUEUE);
if (current->momentUs < result) if (current->momentUs < result)
result = current->momentUs; result = current->momentUs;