Обновление

This commit is contained in:
cfif 2026-04-07 12:24:00 +03:00
parent 38623c52d2
commit 5d561fd044
2 changed files with 33 additions and 13 deletions

View File

@ -35,6 +35,8 @@ typedef struct {
uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG]; uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG];
uint8_t countBufLoggerNames; uint8_t countBufLoggerNames;
osMutexId_t access;
struct { struct {
osThreadId_t id; osThreadId_t id;
uint32_t stack[384]; uint32_t stack[384];

View File

@ -57,8 +57,9 @@ static void LoggerToSerialPort_TimeToString(time_t timestamp, char *strbuf) {
asctime_r(&timestampTM, strbuf); asctime_r(&timestampTM, strbuf);
} }
static void LoggerToSerialPort_PrintLegend( static uint32_t LoggerToSerialPort_PrintLegend(
tLoggerToSerialPort *env, tLoggerToSerialPort *env,
char *outStr[],
char *authorStatic, char *authorStatic,
const uint8_t authorLen, const uint8_t authorLen,
eLoggerLevel loglevel eLoggerLevel loglevel
@ -113,9 +114,12 @@ static void LoggerToSerialPort_PrintLegend(
if (env->flags) if (env->flags)
vAsciiStringAdd(str, &strLen, ": ", 2); vAsciiStringAdd(str, &strLen, ": ", 2);
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) str, strLen, env->timeout); // SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) str, strLen, env->timeout);
*outStr = str;
env->open = true; env->open = true;
return strLen;
} }
static void LoggerToSerialPort_Logging( static void LoggerToSerialPort_Logging(
@ -136,19 +140,30 @@ static void LoggerToSerialPort_Logging(
// env->timeout = 0; // env->timeout = 0;
// } // }
if (!env->open) { char *outStr = NULL;
LoggerToSerialPort_PrintLegend(env, authorStatic, authorLen, loglevel); uint32_t lenStr;
}
// if (!env->open) {
lenStr = LoggerToSerialPort_PrintLegend(env, &outStr, authorStatic, authorLen, loglevel);
// }
if (osMutexAcquire(env->access, env->timeout) == osOK) {
//выводим сообщение //выводим сообщение
if (outStr != NULL) {
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) outStr, lenStr, env->timeout);
}
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) msg, msgLen, env->timeout); SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) msg, msgLen, env->timeout);
if (complete) { if (complete) {
//переводим строку //переводим строку
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) "\r\n", 2, env->timeout); SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) "\r\n", 2, env->timeout);
env->open = false; // env->open = false;
} else { } else {
env->open = true; // env->open = true;
}
osMutexRelease(env->access);
} }
// env->timeout = timeoutLocal; // env->timeout = timeoutLocal;
@ -175,6 +190,9 @@ void LoggerToSerialPort_Init(
env->rtc = rtc; env->rtc = rtc;
env->flags = flags; env->flags = flags;
env->timeoutTransmittedLog = timeoutTransmittedLog; env->timeoutTransmittedLog = timeoutTransmittedLog;
env->access = osMutexNew(NULL);
// env->showDate = showDate; // env->showDate = showDate;
// env->showTime = showTime; // env->showTime = showTime;
// env->showLoglevel = showLoglevel; // env->showLoglevel = showLoglevel;