auto-sync

This commit is contained in:
rusEfi 2014-11-18 20:05:41 -06:00
parent 87695f5acd
commit 2c698a9912
8 changed files with 104 additions and 35 deletions

View File

@ -56,8 +56,7 @@ typedef char log_buf_t[DL_OUTPUT_BUFFER];
static log_buf_t pendingBuffers0 CCM_OPTIONAL static log_buf_t pendingBuffers0 CCM_OPTIONAL
; ;
static log_buf_t pendingBuffers1 static log_buf_t pendingBuffers1;
;
/** /**
* This is the buffer into which all the data providers write * This is the buffer into which all the data providers write
@ -121,8 +120,16 @@ void appendFast(Logging *logging, const char *text) {
// c = *s++; // c = *s++;
// *logging->linePointer++ = c; // *logging->linePointer++ = c;
// } while (c != '\0'); // } while (c != '\0');
int extraLen = efiStrlen(text); register char *s;
strcpy(logging->linePointer, text); for (s = (char *) text; *s; ++s)
;
int extraLen = (s - text);
s = logging->linePointer;
while ((*s++ = *text++) != 0)
;
// strcpy(logging->linePointer, text);
logging->linePointer += extraLen; logging->linePointer += extraLen;
} }
@ -195,8 +202,8 @@ char* getCaption(LoggingPoints loggingPoint) {
} }
/* /*
// todo: this method does not really belong to this file // todo: this method does not really belong to this file
static char* get2ndCaption(int loggingPoint) { static char* get2ndCaption(int loggingPoint) {
switch (loggingPoint) { switch (loggingPoint) {
case LP_RPM: case LP_RPM:
return "RPM"; return "RPM";
@ -215,8 +222,8 @@ static char* get2ndCaption(int loggingPoint) {
} }
firmwareError("No such loggingPoint"); firmwareError("No such loggingPoint");
return NULL; return NULL;
} }
*/ */
void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize) { void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize) {
print("Init logging %s\r\n", name); print("Init logging %s\r\n", name);

View File

@ -96,11 +96,16 @@ void appendPrintf(Logging *logging, const char *fmt, ...);
void vappendPrintf(Logging *logging, const char *fmt, va_list arg); void vappendPrintf(Logging *logging, const char *fmt, va_list arg);
void append(Logging *logging, const char *text); void append(Logging *logging, const char *text);
void appendFast(Logging *logging, const char *text); void appendFast(Logging *logging, const char *text);
/**
* This macro breaks the normal zero=termination constraint, please take care of this outside of this macro
*/
#define appendChar(logging, symbol) {(logging)->linePointer[0] = (symbol);(logging)->linePointer++;}
/** /**
* this method copies the line into the intermediate buffer for later output by * this method copies the line into the intermediate buffer for later output by
* the main thread * the main thread
*/ */
void scheduleLogging(Logging *logging); void scheduleLogging(Logging *logging);
void scheduleIntValue(Logging *logging, const char *msg, int value); void scheduleIntValue(Logging *logging, const char *msg, int value);

View File

@ -33,7 +33,7 @@
#include "eficonsole.h" #include "eficonsole.h"
#include "status_loop.h" #include "status_loop.h"
#define CHART_DELIMETER "!" #define CHART_DELIMETER '!'
#if EFI_HISTOGRAMS || defined(__DOXYGEN__) #if EFI_HISTOGRAMS || defined(__DOXYGEN__)
#include "rfiutil.h" #include "rfiutil.h"
@ -187,14 +187,15 @@ void WaveChart::addWaveChartEvent3(const char *name, const char * msg) {
* printf is a heavy method, append is used here as a performance optimization * printf is a heavy method, append is used here as a performance optimization
*/ */
appendFast(&logging, name); appendFast(&logging, name);
appendFast(&logging, CHART_DELIMETER); appendChar(&logging, CHART_DELIMETER);
appendFast(&logging, msg); appendFast(&logging, msg);
appendFast(&logging, CHART_DELIMETER); appendChar(&logging, CHART_DELIMETER);
// time100 -= startTime100; // time100 -= startTime100;
itoa10(timeBuffer, time100); itoa10(timeBuffer, time100);
appendFast(&logging, timeBuffer); appendFast(&logging, timeBuffer);
appendFast(&logging, CHART_DELIMETER); appendChar(&logging, CHART_DELIMETER);
logging.linePointer[0] = 0;
} }
if (!alreadyLocked) { if (!alreadyLocked) {
unlockOutputBuffer(); unlockOutputBuffer();

View File

@ -27,6 +27,11 @@ static LENameOrdinalPair leAnd(LE_OPERATOR_AND, "and");
static LENameOrdinalPair leOr(LE_OPERATOR_OR, "or"); static LENameOrdinalPair leOr(LE_OPERATOR_OR, "or");
static LENameOrdinalPair leNot(LE_OPERATOR_NOT, "not"); static LENameOrdinalPair leNot(LE_OPERATOR_NOT, "not");
static LENameOrdinalPair leAdd(LE_OPERATOR_ADDITION, "+");
static LENameOrdinalPair leSub(LE_OPERATOR_SUBSTRACTION, "-");
static LENameOrdinalPair leMul(LE_OPERATOR_MULTIPLICATION, "*");
static LENameOrdinalPair leDiv(LE_OPERATOR_DIVISION, "/");
static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">"); static LENameOrdinalPair leMore(LE_OPERATOR_MORE, ">");
static LENameOrdinalPair leMoreOrEqual(LE_OPERATOR_MORE_OR_EQUAL, ">="); static LENameOrdinalPair leMoreOrEqual(LE_OPERATOR_MORE_OR_EQUAL, ">=");
@ -149,6 +154,38 @@ void LECalculator::doJob(Engine *engine, LEElement *element) {
stack.push(v1 > v2); stack.push(v1 > v2);
} }
break; break;
case LE_OPERATOR_ADDITION: {
// elements on stack are in reverse order
float v2 = pop(LE_OPERATOR_MORE);
float v1 = pop(LE_OPERATOR_MORE);
stack.push(v1 + v2);
}
break;
case LE_OPERATOR_SUBSTRACTION: {
// elements on stack are in reverse order
float v2 = pop(LE_OPERATOR_MORE);
float v1 = pop(LE_OPERATOR_MORE);
stack.push(v1 - v2);
}
break;
case LE_OPERATOR_MULTIPLICATION: {
// elements on stack are in reverse order
float v2 = pop(LE_OPERATOR_MORE);
float v1 = pop(LE_OPERATOR_MORE);
stack.push(v1 * v2);
}
break;
case LE_OPERATOR_DIVISION: {
// elements on stack are in reverse order
float v2 = pop(LE_OPERATOR_MORE);
float v1 = pop(LE_OPERATOR_MORE);
stack.push(v1 / v2);
}
break;
case LE_OPERATOR_LESS_OR_EQUAL: { case LE_OPERATOR_LESS_OR_EQUAL: {
// elements on stack are in reverse order // elements on stack are in reverse order
float v2 = pop(LE_OPERATOR_LESS_OR_EQUAL); float v2 = pop(LE_OPERATOR_LESS_OR_EQUAL);
@ -292,6 +329,7 @@ LEElement *LEElementPool::parseExpression(const char * line) {
#if (EFI_PROD_CODE || EFI_SIMULATOR) #if (EFI_PROD_CODE || EFI_SIMULATOR)
static void eval(char *line, Engine *engine) { static void eval(char *line, Engine *engine) {
line = unquote(line);
scheduleMsg(&logger, "Parsing [%s]", line); scheduleMsg(&logger, "Parsing [%s]", line);
evalPool.reset(); evalPool.reset();
LEElement * e = evalPool.parseExpression(line); LEElement * e = evalPool.parseExpression(line);

View File

@ -23,6 +23,10 @@ typedef enum {
LE_OPERATOR_AND = 6, LE_OPERATOR_AND = 6,
LE_OPERATOR_OR = 7, LE_OPERATOR_OR = 7,
LE_OPERATOR_NOT = 8, LE_OPERATOR_NOT = 8,
LE_OPERATOR_ADDITION = 9,
LE_OPERATOR_SUBSTRACTION = 10,
LE_OPERATOR_MULTIPLICATION = 11,
LE_OPERATOR_DIVISION = 12,
LE_METHOD_RPM = 100, LE_METHOD_RPM = 100,
LE_METHOD_COOLANT = 101, LE_METHOD_COOLANT = 101,

View File

@ -416,4 +416,5 @@ void initEngineContoller(Engine *engine) {
} }
addConsoleActionSSP("set_user_out", (VoidCharPtrCharPtrVoidPtr) setUserOutput, engine); addConsoleActionSSP("set_user_out", (VoidCharPtrCharPtrVoidPtr) setUserOutput, engine);
initEval(engine);
} }

View File

@ -11,6 +11,7 @@
* @author Andrey Belomutskiy, (c) 2012-2014 * @author Andrey Belomutskiy, (c) 2012-2014
*/ */
#include "main.h"
#include "event_queue.h" #include "event_queue.h"
#include "efitime.h" #include "efitime.h"
@ -74,6 +75,8 @@ uint64_t EventQueue::getNextEventTime(uint64_t nowX) {
return nextTimeUs; return nextTimeUs;
} }
// static scheduling_s * longScheduling;
/** /**
* Invoke all pending actions prior to specified timestamp * Invoke all pending actions prior to specified timestamp
* @return true if at least one action was executed * @return true if at least one action was executed
@ -105,7 +108,14 @@ bool EventQueue::executeAll(uint64_t now) {
bool result = (executionList != NULL); bool result = (executionList != NULL);
LL_FOREACH_SAFE(executionList, current, tmp) LL_FOREACH_SAFE(executionList, current, tmp)
{ {
// uint32_t before = hal_lld_get_counter_value();
current->callback(current->param); current->callback(current->param);
// even with overflow it's safe to substract here
// uint32_t cost = hal_lld_get_counter_value() - before;
// if (cost > 2000) {
// longScheduling = current;
// cost++;
// }
} }
return result; return result;
} }

View File

@ -50,7 +50,10 @@ float maxF(float i1, float i2) {
} }
uint32_t efiStrlen(const char *param) { uint32_t efiStrlen(const char *param) {
return strlen(param); register const char *s;
for (s = param; *s; ++s)
;
return (s - param);
} }
bool startsWith(const char *line, const char *prefix) { bool startsWith(const char *line, const char *prefix) {