Обновление
This commit is contained in:
parent
b84f837913
commit
8edf3e2514
|
|
@ -10,7 +10,6 @@
|
||||||
#include "RtcIO.h"
|
#include "RtcIO.h"
|
||||||
#include <cmsis_os.h>
|
#include <cmsis_os.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
tSerialPortIO *serialPortIo_VIRT;
|
tSerialPortIO *serialPortIo_VIRT;
|
||||||
tSerialPortIO *serialPortIo_PHYSIC;
|
tSerialPortIO *serialPortIo_PHYSIC;
|
||||||
|
|
@ -25,6 +24,14 @@ typedef struct {
|
||||||
|
|
||||||
uint8_t buf_LOG[256];
|
uint8_t buf_LOG[256];
|
||||||
|
|
||||||
|
uint8_t bufPrintfLogger[MAX_COUNT_BUF_LOG][MAX_LEN_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_BUF_LOG];
|
||||||
|
uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG];
|
||||||
|
uint8_t countBufLoggerNames;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
osThreadId_t id;
|
osThreadId_t id;
|
||||||
uint32_t stack[384];
|
uint32_t stack[384];
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,52 @@
|
||||||
#include "Rtc.h"
|
#include "Rtc.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "CmsisRtosThreadUtils.h"
|
#include "CmsisRtosThreadUtils.h"
|
||||||
|
#include "memory.h"
|
||||||
#include CMSIS_device_header
|
#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) {
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < env->countBufLoggerNames; ++i) {
|
||||||
|
if (memcmp(env->bufLoggerNames[i], authorStatic, authorLen) == 0) {
|
||||||
|
return env->bufLogger[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configASSERT(env->countBufLoggerNames < MAX_COUNT_BUF_LOG);
|
||||||
|
|
||||||
|
uint8_t len = authorLen;
|
||||||
|
if (authorLen > MAX_LEN_BUF_NAME_LOG) {
|
||||||
|
len = MAX_LEN_BUF_NAME_LOG;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(env->bufLoggerNames[env->countBufLoggerNames], authorStatic, len);
|
||||||
|
++env->countBufLoggerNames;
|
||||||
|
|
||||||
|
return env->bufLogger[env->countBufLoggerNames - 1];
|
||||||
|
}
|
||||||
|
|
||||||
static void LoggerToSerialPort_TimeToString(time_t timestamp, char *strbuf) {
|
static void LoggerToSerialPort_TimeToString(time_t timestamp, char *strbuf) {
|
||||||
struct tm timestampTM;
|
struct tm timestampTM;
|
||||||
localtime_r(×tamp, ×tampTM);
|
localtime_r(×tamp, ×tampTM);
|
||||||
|
|
@ -23,14 +66,15 @@ static void LoggerToSerialPort_PrintLegend(
|
||||||
const uint8_t authorLen,
|
const uint8_t authorLen,
|
||||||
eLoggerLevel loglevel
|
eLoggerLevel loglevel
|
||||||
) {
|
) {
|
||||||
char str[128];
|
//char str[128];
|
||||||
|
char *str = (char *) getMemLoggerBufLog(env, authorStatic, authorLen);
|
||||||
size_t strLen = 0;
|
size_t strLen = 0;
|
||||||
|
|
||||||
time_t timestamp;
|
if (env->flags & (SERIAL_LOGGER_SHOW_DATE | SERIAL_LOGGER_SHOW_TIME)) {
|
||||||
|
|
||||||
|
time_t timestamp;
|
||||||
char timeString[24];
|
char timeString[24];
|
||||||
|
|
||||||
if (env->flags & (SERIAL_LOGGER_SHOW_DATE | SERIAL_LOGGER_SHOW_TIME)) {
|
|
||||||
if (env->rtc) {
|
if (env->rtc) {
|
||||||
RtcGet(env->rtc, ×tamp);
|
RtcGet(env->rtc, ×tamp);
|
||||||
timestamp += env->greenwichOffset * 3600;
|
timestamp += env->greenwichOffset * 3600;
|
||||||
|
|
@ -129,6 +173,7 @@ void LoggerToSerialPort_Init(
|
||||||
env->logger.env = env;
|
env->logger.env = env;
|
||||||
env->greenwichOffset = greenwichOffset;
|
env->greenwichOffset = greenwichOffset;
|
||||||
env->logger.logging = (LoggerGenericMethod) LoggerToSerialPort_Logging;
|
env->logger.logging = (LoggerGenericMethod) LoggerToSerialPort_Logging;
|
||||||
|
env->logger.getMemPrintfBufLog = (getMemPrintfBufLogMethod) getMemPrintfBufLog;
|
||||||
env->rtc = rtc;
|
env->rtc = rtc;
|
||||||
env->flags = flags;
|
env->flags = flags;
|
||||||
env->timeoutTransmittedLog = timeoutTransmittedLog;
|
env->timeoutTransmittedLog = timeoutTransmittedLog;
|
||||||
|
|
@ -144,7 +189,6 @@ void LoggerToSerialPort_Init(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static _Noreturn void LogTransmitter_Thread(tLoggerToSerialPort *env) {
|
static _Noreturn void LogTransmitter_Thread(tLoggerToSerialPort *env) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uint16_t len = env->serialPortIo_VIRT->receive(env->serialPortIo_VIRT->env, env->buf_LOG,
|
uint16_t len = env->serialPortIo_VIRT->receive(env->serialPortIo_VIRT->env, env->buf_LOG,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue