From 24062a0b5722a71d5ecf4c03e8e9767df8fbaf75 Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 6 Apr 2026 12:59:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inc/LoggerToSerialPort.h | 9 ++++++++- Src/LoggerToSerialPort.c | 29 +++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Inc/LoggerToSerialPort.h b/Inc/LoggerToSerialPort.h index 95896fa..2273f0b 100644 --- a/Inc/LoggerToSerialPort.h +++ b/Inc/LoggerToSerialPort.h @@ -10,6 +10,13 @@ #include "RtcIO.h" #include +typedef struct { + uint8_t buf_big1[MAX_LEN_BUF_BIG1_LOG]; + uint8_t buf_big2[MAX_LEN_BUF_BIG2_LOG]; + uint8_t buf_small[MAX_LEN_BUF_SMALL_LOG]; + +} tLoggerDataBuf; + typedef struct { tSerialPortIO *serialPortIo_VIRT; tSerialPortIO *serialPortIo_PHYSIC; @@ -24,7 +31,7 @@ typedef struct { uint8_t buf_LOG[256]; - uint8_t bufLogger[MAX_COUNT_BUF_LOG][MAX_LEN_LOGGER_BUF_LOG + MAX_LEN_PRINTF_BUF_LOG + 32]; + tLoggerDataBuf bufLogger[MAX_COUNT_BUF_LOG]; uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG]; uint8_t countBufLoggerNames; diff --git a/Src/LoggerToSerialPort.c b/Src/LoggerToSerialPort.c index 2145d1f..e2de63d 100644 --- a/Src/LoggerToSerialPort.c +++ b/Src/LoggerToSerialPort.c @@ -12,11 +12,20 @@ #include CMSIS_device_header static uint8_t * -getMemLoggerBufLog(tLoggerToSerialPort *env, char *authorStatic, const uint8_t authorLen, uint16_t offset) { +getMemLoggerBufLog(tLoggerToSerialPort *env, char *authorStatic, const uint8_t authorLen, LOG_BUF_TYPE logBufType) { for (uint8_t i = 0; i < env->countBufLoggerNames; ++i) { if (memcmp(env->bufLoggerNames[i], authorStatic, authorLen) == 0) { - return &env->bufLogger[i][offset]; + + if (logBufType == LOG_BUF_SMALL) { + return env->bufLogger[i].buf_small; + } + + if (logBufType == LOG_BUF_BIG1) { + return env->bufLogger[i].buf_big1; + } + + return env->bufLogger[i].buf_big2; } } @@ -30,7 +39,16 @@ getMemLoggerBufLog(tLoggerToSerialPort *env, char *authorStatic, const uint8_t a memcpy(env->bufLoggerNames[env->countBufLoggerNames], authorStatic, len); ++env->countBufLoggerNames; - return &env->bufLogger[env->countBufLoggerNames - 1][offset]; + if (logBufType == LOG_BUF_SMALL) { + return env->bufLogger[env->countBufLoggerNames - 1].buf_small; + } + + if (logBufType == LOG_BUF_BIG1) { + return env->bufLogger[env->countBufLoggerNames - 1].buf_big1; + } + + return env->bufLogger[env->countBufLoggerNames - 1].buf_big2; + } static void LoggerToSerialPort_TimeToString(time_t timestamp, char *strbuf) { @@ -46,15 +64,14 @@ static void LoggerToSerialPort_PrintLegend( eLoggerLevel loglevel ) { //char str[128]; - char *str = (char *) getMemLoggerBufLog(env, authorStatic, authorLen, 0); + char *str = (char *) getMemLoggerBufLog(env, authorStatic, authorLen, LOG_BUF_BIG1); size_t strLen = 0; if (env->flags & (SERIAL_LOGGER_SHOW_DATE | SERIAL_LOGGER_SHOW_TIME)) { time_t timestamp; //char timeString[24]; - char *timeString = (char *) getMemLoggerBufLog(env, authorStatic, authorLen, - MAX_LEN_LOGGER_BUF_LOG + MAX_LEN_PRINTF_BUF_LOG); + char *timeString = (char *) getMemLoggerBufLog(env, authorStatic, authorLen, LOG_BUF_SMALL); if (env->rtc) { RtcGet(env->rtc, ×tamp);