// // Created by CFIF on 13.11.22. // #ifndef UVEOS_ON_NATION_LOGGERTOSERIALPORT_H #define UVEOS_ON_NATION_LOGGERTOSERIALPORT_H #include "SerialPort.h" #include "LoggerInterface.h" #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 __attribute__((packed)) { uint8_t start_pkt; // 0x02 uint8_t type_pkt; uint8_t len_pkt; uint32_t timestamp; uint8_t channel; uint8_t flags; uint8_t dlc; uint32_t id; uint8_t data[8]; // максимум 8 байт } CanLogPacket_t; typedef struct { tSerialPortIO *serialPortIo_VIRT; tSerialPortIO *serialPortIo_PHYSIC; tRtcIO *rtc; uint32_t timeout; uint32_t timeoutTransmittedLog; uint8_t authorLimit; bool open; tLoggerInterface logger; uint16_t flags; int32_t greenwichOffset; uint8_t buf_LOG[256]; tLoggerDataBuf bufLogger[MAX_COUNT_BUF_LOG]; uint8_t bufLoggerNames[MAX_COUNT_BUF_LOG][MAX_LEN_BUF_NAME_LOG]; uint8_t countBufLoggerNames; uint8_t bufLoggerCan[32]; osMutexId_t access; struct { osThreadId_t id; uint32_t stack[384]; StaticTask_t controlBlock; osThreadAttr_t attr; } thread; } tLoggerToSerialPort; #define SERIAL_LOGGER_SHOW_AUTHOR 0b1 << 0 #define SERIAL_LOGGER_SHOW_LOG_LEVEL 0b1 << 1 #define SERIAL_LOGGER_SHOW_TIME 0b1 << 2 #define SERIAL_LOGGER_SHOW_DATE 0b1 << 3 void LoggerToSerialPort_Init( tLoggerToSerialPort *env, int32_t greenwichOffset, tSerialPortIO *serialPortIo_VIRT, tSerialPortIO *serialPortIo_PHYSIC, tRtcIO *rtc, uint16_t flags, uint32_t timeoutTransmittedLog // bool showDate, // bool showTime, // bool showLoglevel, // bool showAuthor ); void LogTransmitter_StartThread(tLoggerToSerialPort *env); void LoggerToSerialPort_Cmd(tLoggerToSerialPort *env, char *msg, uint16_t msgLen); #endif //UVEOS_ON_NATION_LOGGERTOSERIALPORT_H