Revert "logging simplification: switch bare functions to member functions (#1788)"

This reverts commit d941bdc5
This commit is contained in:
rusefi 2020-09-12 04:36:24 -04:00
parent d38cb3fabe
commit 256a4a2637
14 changed files with 165 additions and 119 deletions

View File

@ -176,7 +176,7 @@ static systime_t timeOfPreviousPrintVersion = (systime_t) -1;
#if EFI_PROD_CODE #if EFI_PROD_CODE
static void printOutPin(const char *pinName, brain_pin_e hwPin) { static void printOutPin(const char *pinName, brain_pin_e hwPin) {
if (hwPin != GPIO_UNASSIGNED) { if (hwPin != GPIO_UNASSIGNED) {
logger.appendPrintf("%s%s%s@%s%s", PROTOCOL_OUTPIN, DELIMETER, pinName, hwPortname(hwPin), DELIMETER); appendPrintf(&logger, "%s%s%s@%s%s", PROTOCOL_OUTPIN, DELIMETER, pinName, hwPortname(hwPin), DELIMETER);
} }
} }
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */

View File

@ -119,7 +119,7 @@ static void printToStream(MemoryStream *stream, const char *fmt, va_list ap) {
} }
static void printWarning(const char *fmt, va_list ap) { static void printWarning(const char *fmt, va_list ap) {
logger.reset(); // todo: is 'reset' really needed here? resetLogging(&logger); // todo: is 'reset' really needed here?
appendMsgPrefix(&logger); appendMsgPrefix(&logger);
logger.append(WARNING_PREFIX); logger.append(WARNING_PREFIX);
@ -137,7 +137,7 @@ static void printWarning(const char *fmt, va_list ap) {
} }
logger.append(warningBuffer); logger.append(warningBuffer);
logger.append(DELIMETER); append(&logger, DELIMETER);
scheduleLogging(&logger); scheduleLogging(&logger);
} }

View File

@ -58,7 +58,7 @@ int waveChartUsedSize;
//#define DEBUG_WAVE 1 //#define DEBUG_WAVE 1
#if DEBUG_WAVE #if DEBUG_WAVE
static LoggingWithStorage debugLogging("debug"); static Logging debugLogging;
#endif /* DEBUG_WAVE */ #endif /* DEBUG_WAVE */
static LoggingWithStorage logger("wave info"); static LoggingWithStorage logger("wave info");
@ -76,10 +76,11 @@ static void resetNow(void) {
} }
#endif #endif
WaveChart::WaveChart() : logging("wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER)) { WaveChart::WaveChart() {
} }
void WaveChart::init() { void WaveChart::init() {
logging.initLoggingExt("wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER));
isInitialized = true; isInitialized = true;
reset(); reset();
} }
@ -88,11 +89,11 @@ void WaveChart::reset() {
#if DEBUG_WAVE #if DEBUG_WAVE
scheduleSimpleMsg(&debugLogging, "reset while at ", counter); scheduleSimpleMsg(&debugLogging, "reset while at ", counter);
#endif /* DEBUG_WAVE */ #endif /* DEBUG_WAVE */
logging.reset(); resetLogging(&logging);
counter = 0; counter = 0;
startTimeNt = 0; startTimeNt = 0;
collectingData = false; collectingData = false;
logging.appendPrintf( "%s%s", PROTOCOL_ENGINE_SNIFFER, DELIMETER); appendPrintf(&logging, "%s%s", PROTOCOL_ENGINE_SNIFFER, DELIMETER);
} }
void WaveChart::startDataCollection() { void WaveChart::startDataCollection() {
@ -143,8 +144,8 @@ void WaveChart::publishIfFull() {
} }
void WaveChart::publish() { void WaveChart::publish() {
logging.appendPrintf( DELIMETER); appendPrintf(&logging, DELIMETER);
waveChartUsedSize = logging.loggingSize(); waveChartUsedSize = loggingSize(&logging);
#if DEBUG_WAVE #if DEBUG_WAVE
Logging *l = &chart->logging; Logging *l = &chart->logging;
scheduleSimpleMsg(&debugLogging, "IT'S TIME", strlen(l->buffer)); scheduleSimpleMsg(&debugLogging, "IT'S TIME", strlen(l->buffer));
@ -210,20 +211,20 @@ void WaveChart::addEvent3(const char *name, const char * msg) {
uint32_t diffNt = nowNt - startTimeNt; uint32_t diffNt = nowNt - startTimeNt;
uint32_t time100 = NT2US(diffNt / ENGINE_SNIFFER_UNIT_US); uint32_t time100 = NT2US(diffNt / ENGINE_SNIFFER_UNIT_US);
if (logging.remainingSize() > 35) { if (remainingSize(&logging) > 35) {
/** /**
* 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
*/ */
logging.appendFast(name); appendFast(&logging, name);
logging.appendChar(CHART_DELIMETER); appendChar(&logging, CHART_DELIMETER);
logging.appendFast(msg); appendFast(&logging, msg);
logging.appendChar(CHART_DELIMETER); appendChar(&logging, CHART_DELIMETER);
// time100 -= startTime100; // time100 -= startTime100;
itoa10(timeBuffer, time100); itoa10(timeBuffer, time100);
logging.appendFast(timeBuffer); appendFast(&logging, timeBuffer);
logging.appendChar(CHART_DELIMETER); appendChar(&logging, CHART_DELIMETER);
logging.appendChar('\0'); logging.linePointer[0] = 0;
} }
if (!alreadyLocked) { if (!alreadyLocked) {
unlockOutputBuffer(); unlockOutputBuffer();
@ -239,6 +240,10 @@ void initWaveChart(WaveChart *chart) {
printStatus(); printStatus();
#if DEBUG_WAVE
initLoggingExt(&debugLogging, "wave chart debug", &debugLogging.DEFAULT_BUFFER, sizeof(debugLogging.DEFAULT_BUFFER));
#endif
#if EFI_HISTOGRAMS #if EFI_HISTOGRAMS
initHistogram(&engineSnifferHisto, "wave chart"); initHistogram(&engineSnifferHisto, "wave chart");
#endif /* EFI_HISTOGRAMS */ #endif /* EFI_HISTOGRAMS */

View File

@ -171,38 +171,38 @@ static void reportWave(Logging *logging, int index) {
float dwellMs = getSignalOnTime(index); float dwellMs = getSignalOnTime(index);
float periodMs = getSignalPeriodMs(index); float periodMs = getSignalPeriodMs(index);
logging->appendPrintf("duty%d%s", index, DELIMETER); appendPrintf(logging, "duty%d%s", index, DELIMETER);
logging->appendFloat(100.0f * dwellMs / periodMs, 2); appendFloat(logging, 100.0f * dwellMs / periodMs, 2);
logging->appendPrintf("%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
/** /**
* that's the ON time of the LAST signal * that's the ON time of the LAST signal
*/ */
logging->appendPrintf("dwell%d%s", index, DELIMETER); appendPrintf(logging, "dwell%d%s", index, DELIMETER);
logging->appendFloat(dwellMs, 2); appendFloat(logging, dwellMs, 2);
logging->appendPrintf("%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
/** /**
* that's the total ON time during the previous engine cycle * that's the total ON time during the previous engine cycle
*/ */
logging->appendPrintf("total_dwell%d%s", index, DELIMETER); appendPrintf(logging, "total_dwell%d%s", index, DELIMETER);
logging->appendFloat(readers[index].prevTotalOnTimeUs / 1000.0f, 2); appendFloat(logging, readers[index].prevTotalOnTimeUs / 1000.0f, 2);
logging->appendPrintf("%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
logging->appendPrintf("period%d%s", index, DELIMETER); appendPrintf(logging, "period%d%s", index, DELIMETER);
logging->appendFloat(periodMs, 2); appendFloat(logging, periodMs, 2);
logging->appendPrintf("%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
uint32_t offsetUs = getWaveOffset(index); uint32_t offsetUs = getWaveOffset(index);
int rpm = GET_RPM(); int rpm = GET_RPM();
if (rpm != 0) { if (rpm != 0) {
float oneDegreeUs = getOneDegreeTimeUs(rpm); float oneDegreeUs = getOneDegreeTimeUs(rpm);
logging->appendPrintf("advance%d%s", index, DELIMETER); appendPrintf(logging, "advance%d%s", index, DELIMETER);
float angle = (offsetUs / oneDegreeUs) - tdcPosition(); float angle = (offsetUs / oneDegreeUs) - tdcPosition();
fixAngle(angle, "waveAn", CUSTOM_ERR_6564); fixAngle(angle, "waveAn", CUSTOM_ERR_6564);
logging->appendFloat(angle, 3); appendFloat(logging, angle, 3);
logging->appendPrintf("%s", DELIMETER); appendPrintf(logging, "%s", DELIMETER);
} }
} }
} }

View File

@ -49,7 +49,7 @@ void scAddData(float angle, float value) {
* data after we have added some data - meaning it's time to flush * data after we have added some data - meaning it's time to flush
*/ */
// message terminator // message terminator
scLogging.appendPrintf(DELIMETER); appendPrintf(&scLogging, DELIMETER);
// output pending data // output pending data
scheduleLogging(&scLogging); scheduleLogging(&scLogging);
pendingData = false; pendingData = false;
@ -58,13 +58,13 @@ void scAddData(float angle, float value) {
} }
if (!pendingData) { if (!pendingData) {
pendingData = true; pendingData = true;
scLogging.reset(); resetLogging(&scLogging);
// message header // message header
scLogging.appendPrintf( "%s%s", PROTOCOL_ANALOG_CHART, DELIMETER); appendPrintf(&scLogging, "%s%s", PROTOCOL_ANALOG_CHART, DELIMETER);
} }
if (scLogging.remainingSize() > 100) { if (remainingSize(&scLogging) > 100) {
scLogging.appendPrintf( "%.2f|%.2f|", angle, value); appendPrintf(&scLogging, "%.2f|%.2f|", angle, value);
} }
#endif /* EFI_TEXT_LOGGING */ #endif /* EFI_TEXT_LOGGING */
} }

View File

@ -385,10 +385,10 @@ static void printFullAdcReport(Logging *logger) {
int pin = getAdcChannelPin(hwIndex); int pin = getAdcChannelPin(hwIndex);
int adcValue = getAvgAdcValue(hwIndex, fastAdc.samples, ADC_BUF_DEPTH_FAST, fastAdc.size()); int adcValue = getAvgAdcValue(hwIndex, fastAdc.samples, ADC_BUF_DEPTH_FAST, fastAdc.size());
logger->appendPrintf(" F ch%d %s%d", index, portname(port), pin); appendPrintf(logger, " F ch%d %s%d", index, portname(port), pin);
logger->appendPrintf(" ADC%d 12bit=%d", hwIndex, adcValue); appendPrintf(logger, " ADC%d 12bit=%d", hwIndex, adcValue);
float volts = adcToVolts(adcValue); float volts = adcToVolts(adcValue);
logger->appendPrintf(" v=%.2f", volts); appendPrintf(logger, " v=%.2f", volts);
appendMsgPostfix(logger); appendMsgPostfix(logger);
scheduleLogging(logger); scheduleLogging(logger);
@ -405,10 +405,10 @@ static void printFullAdcReport(Logging *logger) {
int pin = getAdcChannelPin(hwIndex); int pin = getAdcChannelPin(hwIndex);
int adcValue = slowAdc.getAdcValueByIndex(index); int adcValue = slowAdc.getAdcValueByIndex(index);
logger->appendPrintf(" S ch%d %s%d", index, portname(port), pin); appendPrintf(logger, " S ch%d %s%d", index, portname(port), pin);
logger->appendPrintf(" ADC%d 12bit=%d", hwIndex, adcValue); appendPrintf(logger, " ADC%d 12bit=%d", hwIndex, adcValue);
float volts = adcToVolts(adcValue); float volts = adcToVolts(adcValue);
logger->appendPrintf(" v=%.2f", volts); appendPrintf(logger, " v=%.2f", volts);
appendMsgPostfix(logger); appendMsgPostfix(logger);
scheduleLogging(logger); scheduleLogging(logger);

View File

@ -145,7 +145,7 @@ void printDateTime(void) {
date_get_tm(&timp); date_get_tm(&timp);
appendMsgPrefix(&logger); appendMsgPrefix(&logger);
logger.appendPrintf( "Current RTC localtime is: %04u-%02u-%02u %02u:%02u:%02u w=%d", timp.tm_year + 1900, timp.tm_mon + 1, timp.tm_mday, timp.tm_hour, appendPrintf(&logger, "Current RTC localtime is: %04u-%02u-%02u %02u:%02u:%02u w=%d", timp.tm_year + 1900, timp.tm_mon + 1, timp.tm_mday, timp.tm_hour,
timp.tm_min, timp.tm_sec, rtcWorks); timp.tm_min, timp.tm_sec, rtcWorks);
appendMsgPostfix(&logger); appendMsgPostfix(&logger);
scheduleLogging(&logger); scheduleLogging(&logger);

View File

@ -73,22 +73,26 @@ static IntermediateLogging intermediateLogging;
/** /**
* @returns true if data does not fit into this buffer * @returns true if data does not fit into this buffer
*/ */
bool Logging::validateBuffer(const char *text, uint32_t extraLen) { static ALWAYS_INLINE bool validateBuffer(Logging *logging, const char *text, uint32_t extraLen) {
if (remainingSize() < extraLen + 1) { if (logging->buffer == NULL) {
#if EFI_PROD_CODE firmwareError(CUSTOM_ERR_LOGGING_NOT_READY, "Logging not initialized: %s", logging->name);
const char * msg = extraLen > 50 ? "(long)" : text;
warning(CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s %d [%s]", name, extraLen, msg);
#endif /* EFI_PROD_CODE */
return true; return true;
} }
if (remainingSize(logging) < extraLen + 1) {
#if EFI_PROD_CODE
const char * msg = extraLen > 50 ? "(long)" : text;
warning(CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s %d [%s]", logging->name, extraLen, msg);
#endif /* EFI_PROD_CODE */
return true;
}
return false; return false;
} }
void Logging::append(const char *text) { void Logging::append(const char *text) {
efiAssertVoid(CUSTOM_APPEND_NULL, text != NULL, "append NULL"); efiAssertVoid(CUSTOM_APPEND_NULL, text != NULL, "append NULL");
uint32_t extraLen = efiStrlen(text); uint32_t extraLen = efiStrlen(text);
bool isCapacityProblem = validateBuffer(text, extraLen); bool isCapacityProblem = validateBuffer(this, text, extraLen);
if (isCapacityProblem) { if (isCapacityProblem) {
return; return;
} }
@ -99,14 +103,20 @@ void Logging::append(const char *text) {
linePointer += extraLen; linePointer += extraLen;
} }
// todo: inline
void append(Logging *logging, const char *text) {
logging->append(text);
}
/** /**
* @note This method if fast because it does not validate much, be sure what you are doing * @note This method if fast because it does not validate much, be sure what you are doing
*/ */
void Logging::appendFast(const char *text) { void appendFast(Logging *logging, const char *text) {
char *s = linePointer; char *s;
s = logging->linePointer;
while ((*s++ = *text++) != 0) while ((*s++ = *text++) != 0)
; ;
linePointer = s - 1; logging->linePointer = s - 1;
} }
/** /**
@ -128,6 +138,15 @@ void Logging::vappendPrintf(const char *fmt, va_list arg) {
#endif // EFI_UNIT_TEST #endif // EFI_UNIT_TEST
} }
// todo: replace with logging->appendPrintf
void appendPrintf(Logging *logging, const char *fmt, ...) {
efiAssertVoid(CUSTOM_APPEND_STACK, getCurrentRemainingStack() > 128, "lowstck#4");
va_list ap;
va_start(ap, fmt);
logging->vappendPrintf(fmt, ap);
va_end(ap);
}
void Logging::appendPrintf(const char *fmt, ...) { void Logging::appendPrintf(const char *fmt, ...) {
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
va_list ap; va_list ap;
@ -143,7 +162,19 @@ void Logging::appendPrintf(const char *fmt, ...) {
#endif // EFI_UNIT_TEST #endif // EFI_UNIT_TEST
} }
void Logging::appendFloat(float value, int precision) { void Logging::initLoggingExt(const char *name, char *buffer, int bufferSize) {
this->name = name;
this->buffer = buffer;
this->bufferSize = bufferSize;
resetLogging(this);
this->isInitialized = true;
}
int isInitialized(Logging *logging) {
return logging->isInitialized;
}
void appendFloat(Logging *logging, float value, int precision) {
/** /**
* todo: #1 this implementation is less than perfect * todo: #1 this implementation is less than perfect
* todo: #2 The only way to avoid double promotion would probably be using *float instead of float * todo: #2 The only way to avoid double promotion would probably be using *float instead of float
@ -151,26 +182,26 @@ void Logging::appendFloat(float value, int precision) {
*/ */
switch (precision) { switch (precision) {
case 1: case 1:
appendPrintf("%.1f", value); appendPrintf(logging, "%.1f", value);
break; break;
case 2: case 2:
appendPrintf("%.2f", value); appendPrintf(logging, "%.2f", value);
break; break;
case 3: case 3:
appendPrintf("%.3f", value); appendPrintf(logging, "%.3f", value);
break; break;
case 4: case 4:
appendPrintf("%.4f", value); appendPrintf(logging, "%.4f", value);
break; break;
case 5: case 5:
appendPrintf("%.5f", value); appendPrintf(logging, "%.5f", value);
break; break;
case 6: case 6:
appendPrintf("%.6f", value); appendPrintf(logging, "%.6f", value);
break; break;
default: default:
appendPrintf("%.2f", value); appendPrintf(logging, "%.2f", value);
} }
} }
@ -179,7 +210,7 @@ static char header[16];
/** /**
* this method should invoked on the main thread only * this method should invoked on the main thread only
*/ */
static void printWithLength(char *line) { void printWithLength(char *line) {
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
int len; int len;
char *p; char *p;
@ -217,16 +248,21 @@ static void printWithLength(char *line) {
} }
void appendMsgPrefix(Logging *logging) { void appendMsgPrefix(Logging *logging) {
logging->append(PROTOCOL_MSG DELIMETER); append(logging, PROTOCOL_MSG DELIMETER);
} }
void appendMsgPostfix(Logging *logging) { void appendMsgPostfix(Logging *logging) {
logging->append(DELIMETER); append(logging, DELIMETER);
} }
void Logging::reset() { void resetLogging(Logging *logging) {
linePointer = buffer; char *buffer = logging->buffer;
*linePointer = 0; if (buffer == NULL) {
firmwareError(ERROR_NULL_BUFFER, "Null buffer: %s", logging->name);
return;
}
logging->linePointer = buffer;
logging->linePointer[0] = 0;
} }
/** /**
@ -243,17 +279,24 @@ void printMsg(Logging *logger, const char *fmt, ...) {
logger->vappendPrintf(fmt, ap); logger->vappendPrintf(fmt, ap);
va_end(ap); va_end(ap);
logger->append(DELIMETER); append(logger, DELIMETER);
printWithLength(logger->buffer); printWithLength(logger->buffer);
logger->reset(); resetLogging(logger);
} }
Logging::Logging(char const *name, char *buffer, int bufferSize) uint32_t remainingSize(Logging *logging) {
: name(name) return logging->bufferSize - loggingSize(logging);
, buffer(buffer) }
, bufferSize(bufferSize)
{ Logging::Logging() {
reset(); }
Logging::Logging(char const *name, char *buffer, int bufferSize) : Logging() {
#if ! EFI_UNIT_TEST
initLoggingExt(name, buffer, bufferSize);
#else
this->buffer = buffer;
#endif /* ! EFI_UNIT_TEST */
} }
LoggingWithStorage::LoggingWithStorage(const char *name) : Logging(name, DEFAULT_BUFFER, sizeof(DEFAULT_BUFFER)) { LoggingWithStorage::LoggingWithStorage(const char *name) : Logging(name, DEFAULT_BUFFER, sizeof(DEFAULT_BUFFER)) {

View File

@ -17,51 +17,28 @@
// size of buffers? // size of buffers?
class Logging { class Logging {
public: public:
Logging() = delete; Logging();
Logging(const char *name, char *buffer, int bufferSize); Logging(const char *name, char *buffer, int bufferSize);
void initLoggingExt(const char *name, char *buffer, int bufferSize);
void reset();
void vappendPrintf(const char *fmt, va_list arg); void vappendPrintf(const char *fmt, va_list arg);
void append(const char *text); void append(const char *text);
void appendFast(const char *text); void appendFast(const char *text);
void appendPrintf(const char *fmt, ...); void appendPrintf(const char *fmt, ...);
void appendFloat(float value, int precision); const char *name = nullptr;
char SMALL_BUFFER[40];
/**
* This macro breaks the normal zero=termination constraint, please take care of this outside of this function
*/
void appendChar(char c) {
*linePointer = c;
linePointer++;
}
size_t loggingSize() const {
return (uintptr_t)linePointer - (uintptr_t)buffer;
}
size_t remainingSize() const {
return bufferSize - loggingSize();
}
//private:
bool validateBuffer(const char *text, uint32_t extraLen);
const char* const name = nullptr;
/** /**
* Zero-terminated buffer of pending debug message * Zero-terminated buffer of pending debug message
* *
* Unless a larger external buffer is specified, this is just a pointer to DEFAULT_BUFFER * Unless a larger external buffer is specified, this is just a pointer to DEFAULT_BUFFER
*/ */
char* const buffer = nullptr; char *buffer = nullptr;
const int bufferSize = 0;
/** /**
* This pointer is always pointing at the position within the buffer into which next * This pointer is always pointing at the position within the buffer into which next
* write operation would append additional data * write operation would append additional data
*/ */
char *linePointer = nullptr; char *linePointer = nullptr;
int bufferSize = 0;
volatile bool isInitialized = false;
}; };
class LoggingWithStorage : public Logging { class LoggingWithStorage : public Logging {
@ -70,8 +47,14 @@ public:
char DEFAULT_BUFFER[200]; char DEFAULT_BUFFER[200];
}; };
int isInitialized(Logging *logging);
void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize); void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize);
void appendFloat(Logging *logging, float value, int precision);
void resetLogging(Logging *logging);
void appendMsgPrefix(Logging *logging); void appendMsgPrefix(Logging *logging);
void appendMsgPostfix(Logging *logging); void appendMsgPostfix(Logging *logging);
@ -84,7 +67,20 @@ extern "C"
#define lockOutputBuffer lockAnyContext #define lockOutputBuffer lockAnyContext
#define unlockOutputBuffer unlockAnyContext #define unlockOutputBuffer unlockAnyContext
uint32_t remainingSize(Logging *logging);
#define loggingSize(logging) ((int) (logging)->linePointer - (int) ((logging)->buffer))
void printMsg(Logging *logging, const char *fmt, ...); void printMsg(Logging *logging, const char *fmt, ...);
void appendPrintf(Logging *logging, const char *fmt, ...);
void append(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
@ -95,3 +91,5 @@ void scheduleLogging(Logging *logging);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
void printWithLength(char *line);

View File

@ -312,12 +312,12 @@ void printHistogram(Logging *logging, histogram_s *histogram) {
int report[5]; int report[5];
int len = hsReport(histogram, report); int len = hsReport(histogram, report);
logging->reset(); resetLogging(logging);
appendMsgPrefix(logging); appendMsgPrefix(logging);
logging.appendPrintf("histogram %s *", histogram->name); appendPrintf(logging, "histogram %s *", histogram->name);
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
logging.appendPrintf("%d ", report[i]); appendPrintf(logging, "%d ", report[i]);
logging.appendPrintf("*"); appendPrintf(logging, "*");
appendMsgPostfix(logging); appendMsgPostfix(logging);
scheduleLogging(logging); scheduleLogging(logging);
#else #else

View File

@ -82,7 +82,7 @@ void scheduleLogging(Logging *logging) {
if (!alreadyLocked) { if (!alreadyLocked) {
unlockOutputBuffer(); unlockOutputBuffer();
} }
logging->reset(); resetLogging(logging);
return; return;
} }
// memcpy is faster then strcpy because it is not looking for line terminator // memcpy is faster then strcpy because it is not looking for line terminator
@ -91,7 +91,7 @@ void scheduleLogging(Logging *logging) {
if (!alreadyLocked) { if (!alreadyLocked) {
unlockOutputBuffer(); unlockOutputBuffer();
} }
logging->reset(); resetLogging(logging);
#endif /* EFI_TEXT_LOGGING */ #endif /* EFI_TEXT_LOGGING */
} }
@ -167,7 +167,7 @@ void scheduleMsg(Logging *logging, const char *format, ...) {
return; return;
} }
int wasLocked = lockAnyContext(); int wasLocked = lockAnyContext();
logging->reset(); // todo: is 'reset' really needed here? resetLogging(logging); // todo: is 'reset' really needed here?
appendMsgPrefix(logging); appendMsgPrefix(logging);
va_list ap; va_list ap;

View File

@ -69,20 +69,20 @@ static void runChprintfTest() {
{ {
LoggingWithStorage testLogging("test"); LoggingWithStorage testLogging("test");
testLogging.appendFloat(1.23, 5); appendFloat(&testLogging, 1.23, 5);
testLogging.appendFloat(1.234, 2); appendFloat(&testLogging, 1.234, 2);
assertString(testLogging.buffer, "1.230001.23"); assertString(testLogging.buffer, "1.230001.23");
} }
{ {
LoggingWithStorage testLogging("test"); LoggingWithStorage testLogging("test");
testLogging.appendFloat(-1.23, 5); appendFloat(&testLogging, -1.23, 5);
assertString(testLogging.buffer, "-1.23000"); assertString(testLogging.buffer, "-1.23000");
} }
{ {
LoggingWithStorage testLogging("test"); LoggingWithStorage testLogging("test");
testLogging.appendPrintf( "a%.2fb%fc", -1.2, -3.4); appendPrintf(&testLogging, "a%.2fb%fc", -1.2, -3.4);
assertString(testLogging.buffer, "a-1.20b-3.400000095c"); assertString(testLogging.buffer, "a-1.20b-3.400000095c");
} }

View File

@ -104,7 +104,7 @@ TEST(fuel, testAccelEnrichmentFractionalTps) {
} }
} }
LoggingWithStorage logger("test"); Logging logger;
initAccelEnrichment(&logger PASS_ENGINE_PARAMETER_SUFFIX); initAccelEnrichment(&logger PASS_ENGINE_PARAMETER_SUFFIX);
engine->rpmCalculator.setRpmValue(600); engine->rpmCalculator.setRpmValue(600);

View File

@ -16,7 +16,7 @@ efitimems_t currentTimeMillis(void) {
return mockTimeMs; return mockTimeMs;
} }
LoggingWithStorage logging("test"); Logging logging;
static float zigZagOffset = 0; static float zigZagOffset = 0;