Обновление
This commit is contained in:
parent
454c300c0e
commit
93648e8b88
|
|
@ -24,11 +24,7 @@ typedef struct {
|
|||
|
||||
uint8_t buf_LOG[256];
|
||||
|
||||
uint8_t bufPrintfLogger[MAX_COUNT_BUF_LOG][MAX_LEN_PRINTF_BUF_LOG];
|
||||
uint8_t bufPrintfNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG];
|
||||
uint8_t countBufPrintfNames;
|
||||
|
||||
uint8_t bufLogger[MAX_COUNT_BUF_LOG][MAX_LEN_LOGGER_BUF_LOG];
|
||||
uint8_t bufLogger[MAX_COUNT_BUF_LOG][MAX_LEN_LOGGER_BUF_LOG + MAX_LEN_PRINTF_BUF_LOG + 32];
|
||||
uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG];
|
||||
uint8_t countBufLoggerNames;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,33 +11,12 @@
|
|||
#include "memory.h"
|
||||
#include CMSIS_device_header
|
||||
|
||||
|
||||
static uint8_t *getMemPrintfBufLog(tLoggerToSerialPort *env, char *authorStatic, const uint8_t authorLen) {
|
||||
|
||||
for (uint8_t i = 0; i < env->countBufPrintfNames; ++i) {
|
||||
if (memcmp(env->bufPrintfNames[i], authorStatic, authorLen) == 0) {
|
||||
return env->bufPrintfLogger[i];
|
||||
}
|
||||
}
|
||||
|
||||
configASSERT(env->countBufPrintfNames < MAX_COUNT_BUF_LOG);
|
||||
|
||||
uint8_t len = authorLen;
|
||||
if (authorLen > MAX_LEN_BUF_NAME_LOG) {
|
||||
len = MAX_LEN_BUF_NAME_LOG;
|
||||
}
|
||||
|
||||
memcpy(env->bufPrintfNames[env->countBufPrintfNames], authorStatic, len);
|
||||
++env->countBufPrintfNames;
|
||||
|
||||
return env->bufPrintfLogger[env->countBufPrintfNames - 1];
|
||||
}
|
||||
|
||||
static uint8_t *getMemLoggerBufLog(tLoggerToSerialPort *env, char *authorStatic, const uint8_t authorLen) {
|
||||
static uint8_t *
|
||||
getMemLoggerBufLog(tLoggerToSerialPort *env, char *authorStatic, const uint8_t authorLen, uint16_t offset) {
|
||||
|
||||
for (uint8_t i = 0; i < env->countBufLoggerNames; ++i) {
|
||||
if (memcmp(env->bufLoggerNames[i], authorStatic, authorLen) == 0) {
|
||||
return env->bufLogger[i];
|
||||
return &env->bufLogger[i][offset];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +30,7 @@ static uint8_t *getMemLoggerBufLog(tLoggerToSerialPort *env, char *authorStatic,
|
|||
memcpy(env->bufLoggerNames[env->countBufLoggerNames], authorStatic, len);
|
||||
++env->countBufLoggerNames;
|
||||
|
||||
return env->bufLogger[env->countBufLoggerNames - 1];
|
||||
return &env->bufLogger[env->countBufLoggerNames - 1][offset];
|
||||
}
|
||||
|
||||
static void LoggerToSerialPort_TimeToString(time_t timestamp, char *strbuf) {
|
||||
|
|
@ -67,13 +46,15 @@ static void LoggerToSerialPort_PrintLegend(
|
|||
eLoggerLevel loglevel
|
||||
) {
|
||||
//char str[128];
|
||||
char *str = (char *) getMemLoggerBufLog(env, authorStatic, authorLen);
|
||||
char *str = (char *) getMemLoggerBufLog(env, authorStatic, authorLen, 0);
|
||||
size_t strLen = 0;
|
||||
|
||||
if (env->flags & (SERIAL_LOGGER_SHOW_DATE | SERIAL_LOGGER_SHOW_TIME)) {
|
||||
|
||||
time_t timestamp;
|
||||
char timeString[24];
|
||||
//char timeString[24];
|
||||
char *timeString = (char *) getMemLoggerBufLog(env, authorStatic, authorLen,
|
||||
MAX_LEN_LOGGER_BUF_LOG + MAX_LEN_PRINTF_BUF_LOG);
|
||||
|
||||
if (env->rtc) {
|
||||
RtcGet(env->rtc, ×tamp);
|
||||
|
|
@ -173,7 +154,7 @@ void LoggerToSerialPort_Init(
|
|||
env->logger.env = env;
|
||||
env->greenwichOffset = greenwichOffset;
|
||||
env->logger.logging = (LoggerGenericMethod) LoggerToSerialPort_Logging;
|
||||
env->logger.getMemPrintfBufLog = (getMemPrintfBufLogMethod) getMemPrintfBufLog;
|
||||
env->logger.getMemPrintfBufLog = (getMemPrintfBufLogMethod) getMemLoggerBufLog;
|
||||
env->rtc = rtc;
|
||||
env->flags = flags;
|
||||
env->timeoutTransmittedLog = timeoutTransmittedLog;
|
||||
|
|
|
|||
Loading…
Reference in New Issue