Обновление
This commit is contained in:
parent
38623c52d2
commit
5d561fd044
|
|
@ -35,6 +35,8 @@ typedef struct {
|
|||
uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG];
|
||||
uint8_t countBufLoggerNames;
|
||||
|
||||
osMutexId_t access;
|
||||
|
||||
struct {
|
||||
osThreadId_t id;
|
||||
uint32_t stack[384];
|
||||
|
|
|
|||
|
|
@ -57,8 +57,9 @@ static void LoggerToSerialPort_TimeToString(time_t timestamp, char *strbuf) {
|
|||
asctime_r(×tampTM, strbuf);
|
||||
}
|
||||
|
||||
static void LoggerToSerialPort_PrintLegend(
|
||||
static uint32_t LoggerToSerialPort_PrintLegend(
|
||||
tLoggerToSerialPort *env,
|
||||
char *outStr[],
|
||||
char *authorStatic,
|
||||
const uint8_t authorLen,
|
||||
eLoggerLevel loglevel
|
||||
|
|
@ -113,9 +114,12 @@ static void LoggerToSerialPort_PrintLegend(
|
|||
if (env->flags)
|
||||
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;
|
||||
|
||||
return strLen;
|
||||
}
|
||||
|
||||
static void LoggerToSerialPort_Logging(
|
||||
|
|
@ -136,19 +140,30 @@ static void LoggerToSerialPort_Logging(
|
|||
// env->timeout = 0;
|
||||
// }
|
||||
|
||||
if (!env->open) {
|
||||
LoggerToSerialPort_PrintLegend(env, authorStatic, authorLen, loglevel);
|
||||
}
|
||||
char *outStr = NULL;
|
||||
uint32_t lenStr;
|
||||
|
||||
//выводим сообщение
|
||||
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) msg, msgLen, env->timeout);
|
||||
// if (!env->open) {
|
||||
lenStr = LoggerToSerialPort_PrintLegend(env, &outStr, authorStatic, authorLen, loglevel);
|
||||
// }
|
||||
|
||||
if (complete) {
|
||||
//переводим строку
|
||||
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) "\r\n", 2, env->timeout);
|
||||
env->open = false;
|
||||
} else {
|
||||
env->open = true;
|
||||
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);
|
||||
|
||||
if (complete) {
|
||||
//переводим строку
|
||||
SerialPortTransmit(env->serialPortIo_VIRT, (uint8_t *) "\r\n", 2, env->timeout);
|
||||
// env->open = false;
|
||||
} else {
|
||||
// env->open = true;
|
||||
}
|
||||
osMutexRelease(env->access);
|
||||
}
|
||||
|
||||
// env->timeout = timeoutLocal;
|
||||
|
|
@ -175,6 +190,9 @@ void LoggerToSerialPort_Init(
|
|||
env->rtc = rtc;
|
||||
env->flags = flags;
|
||||
env->timeoutTransmittedLog = timeoutTransmittedLog;
|
||||
|
||||
env->access = osMutexNew(NULL);
|
||||
|
||||
// env->showDate = showDate;
|
||||
// env->showTime = showTime;
|
||||
// env->showLoglevel = showLoglevel;
|
||||
|
|
|
|||
Loading…
Reference in New Issue