auto-sync

This commit is contained in:
rusEfi 2014-09-13 21:02:41 -05:00
parent 5464109748
commit af6f838ea7
8 changed files with 27 additions and 20 deletions

View File

@ -88,7 +88,7 @@ static bool validateBuffer(Logging *logging, uint32_t extraLen, const char *text
void append(Logging *logging, const char *text) {
efiAssertVoid(text != NULL, "append NULL");
uint32_t extraLen = strlen(text);
uint32_t extraLen = efiStrlen(text);
int isError = validateBuffer(logging, extraLen, text);
if (isError) {
return;
@ -108,7 +108,7 @@ void appendFast(Logging *logging, const char *text) {
// c = *s++;
// *logging->linePointer++ = c;
// } while (c != '\0');
int extraLen = strlen(text);
int extraLen = efiStrlen(text);
strcpy(logging->linePointer, text);
logging->linePointer += extraLen;
}
@ -281,9 +281,9 @@ static void printWithLength(char *line) {
* When we work with actual hardware, it is faster to invoke 'chSequentialStreamWrite' for the
* whole buffer then to invoke 'chSequentialStreamPut' once per character.
*/
int len = strlen(line);
int len = efiStrlen(line);
strcpy(header, "line:");
char *p = header + strlen(header);
char *p = header + efiStrlen(header);
p = itoa10(p, len);
*p++ = ':';
*p++ = '\0';
@ -365,11 +365,11 @@ void scheduleIntValue(Logging *logging, const char *msg, int value) {
void scheduleLogging(Logging *logging) {
// this could be done without locking
int newLength = strlen(logging->buffer);
int newLength = efiStrlen(logging->buffer);
bool alreadyLocked = lockOutputBuffer();
// I hope this is fast enough to operate under sys lock
int curLength = strlen(pendingBuffer);
int curLength = efiStrlen(pendingBuffer);
if (curLength + newLength >= DL_OUTPUT_BUFFER) {
/**
* if no one is consuming the data we have to drop it
@ -407,7 +407,7 @@ void printPending(void) {
pendingBuffer[0] = 0; // reset pending buffer
unlockOutputBuffer();
if (strlen(outputBuffer) > 0) {
if (efiStrlen(outputBuffer) > 0) {
printWithLength(outputBuffer);
}
}

View File

@ -23,7 +23,7 @@ extern engine_configuration_s *engineConfiguration;
#define NUMBER_OF_DIFFERENT_LINES 4
char * appendStr(char *ptr, const char *suffix) {
for (uint32_t i = 0; i < strlen(suffix); i++) {
for (uint32_t i = 0; i < efiStrlen(suffix); i++) {
*ptr++ = suffix[i];
}
return ptr;

View File

@ -129,6 +129,6 @@ void configureMazdaProtegeLx(trigger_shape_s *s) {
// s->shaftPositionEventCount = 2 + 8;
s->shaftPositionEventCount = 8;
s->shaftPositionEventCount = s->getSize();
s->isSynchronizationNeeded = false;
}

View File

@ -11,7 +11,6 @@ void configureFordAspireTriggerShape(trigger_shape_s * s) {
s->isSynchronizationNeeded = false;
s->reset(FOUR_STROKE_CAM_SENSOR);
s->shaftPositionEventCount = 10;
float x = 121.90;
float y = 110.86;
@ -27,6 +26,8 @@ void configureFordAspireTriggerShape(trigger_shape_s * s) {
s->addEvent(x + 360 + y, T_SECONDARY, TV_HIGH);
s->addEvent(x + 540, T_SECONDARY, TV_LOW);
s->addEvent(720, T_PRIMARY, TV_LOW);
s->shaftPositionEventCount = s->getSize();
}
void initializeMitsubishi4g18(trigger_shape_s *s) {

View File

@ -49,9 +49,13 @@ float maxF(float i1, float i2) {
return i1 > i2 ? i1 : i2;
}
int efiStrlen(const char *param) {
return strlen(param);
}
int indexOf(const char *string, char ch) {
// todo: there should be a standard function for this
int len = strlen(string);
int len = efiStrlen(string);
for (int i = 0; i < len; i++) {
if (string[i] == ch) {
return i;

View File

@ -33,6 +33,7 @@ extern "C"
const char * boolToString(bool value);
int efiStrlen(const char *param);
int indexOf(const char *string, char ch);
float atoff(const char *string);
int atoi(const char *string);

View File

@ -82,9 +82,9 @@ int histogramGetIndex(int64_t value) {
* @brief Reset histogram_s to orignal state
*/
void initHistogram(histogram_s *h, const char *name) {
if(strlen(name) > sizeof(h->name) - 1) {
if (efiStrlen(name) > sizeof(h->name) - 1) {
firmwareError("Histogram name [%s] too long", name);
}
}
strcpy(h->name, name);
h->total_value = 0;
h->total_count = 0;
@ -99,7 +99,7 @@ void hsAdd(histogram_s *h, int64_t value) {
int count = 1;
h->total_value += value;
h->total_count += count;
efiAssertVoid(index < BOUND_LENGTH, "histogram issue" );
efiAssertVoid(index < BOUND_LENGTH, "histogram issue");
h->values[index] += count;
}
@ -112,18 +112,18 @@ int hsReport(histogram_s *h, int* report) {
int index = 0;
if (h->total_count <= 5) {
for (int j = 0; j < BOUND_LENGTH; j++) {
for (int j = 0; j < BOUND_LENGTH; j++) {
for (int k = 0; k < h->values[j]; k++) {
report[index++] = (bounds[j] + bounds[j + 1]) / 2;
}
}
}
return index;
}
int minIndex = 0;
while (h->values[minIndex] == 0) {
minIndex++;
}
}
report[index++] = h->values[minIndex];
int64_t acc = 0;
@ -133,10 +133,10 @@ int hsReport(histogram_s *h, int* report) {
// Always drop at least 1 'non-confident' sample...
if (k == 0) {
k = 1;
}
}
if (k == h->total_count) {
k = h->total_count - 1;
}
}
// 'k' is desired number of samples.
while (acc + h->values[minIndex] < k)
acc += h->values[minIndex++];
@ -148,7 +148,7 @@ int hsReport(histogram_s *h, int* report) {
float d = bounds[minIndex];
if (acc != k)
d += (bounds[minIndex + 1] - 1 - bounds[minIndex]) * (k - acc) / h->values[minIndex];
report[index++] = (int)d;
report[index++] = (int) d;
}
int maxIndex = BOUND_LENGTH - 1;

View File

@ -19,6 +19,7 @@
#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
#define EFI_SIGNAL_EXECUTOR_ONE_TIMER TRUE
#define EFI_SIGNAL_EXECUTOR_SLEEP FALSE
#define EFI_SHAFT_POSITION_INPUT TRUE
#define EFI_ENGINE_CONTROL TRUE