1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-12 19:10:27 +03:00

dmesg: log init messages to RAM until serial init

This commit is contained in:
Ray Morris 2025-04-28 17:27:07 -05:00
parent 0861a44903
commit e38e55a26c
2 changed files with 35 additions and 0 deletions

View file

@ -61,6 +61,11 @@ PG_RESET_TEMPLATE(logConfig_t, logConfig,
.topics = SETTING_LOG_TOPICS_DEFAULT
);
#if defined(DMESG_SIZE)
char dmesg_buffer[DMESG_SIZE];
char *dmesg_head = dmesg_buffer;
#endif
void logInit(void)
{
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_LOG);
@ -135,6 +140,18 @@ static void logPrint(const char *buf, size_t size)
} else if (mspLogPort) {
mspSerialPushPort(MSP_DEBUGMSG, (uint8_t*)buf, size, mspLogPort, MSP_V2_NATIVE);
}
#ifdef DMESG_SIZE
if ( (dmesg_head + size + 2) < (dmesg_buffer + DMESG_SIZE) ) {
for (unsigned int ii = 0; ii < size; ii++) {
*dmesg_head = buf[ii];
dmesg_head++;
}
dmesg_head[0] = '\r';
dmesg_head[1] = '\n';
dmesg_head = dmesg_head + 2;
}
#endif
}
static size_t logFormatPrefix(char *buf, const timeMs_t timeMs)

View file

@ -130,6 +130,11 @@ bool cliMode = false;
extern timeDelta_t cycleTime; // FIXME dependency on mw.c
extern uint8_t detectedSensors[SENSOR_INDEX_COUNT];
#ifdef DMESG_SIZE
extern char dmesg_buffer[DMESG_SIZE];
extern char *dmesg_head;
#endif
static serialPort_t *cliPort;
static bufWriter_t *cliWriter;
@ -4798,6 +4803,16 @@ static void cliUbloxPrintSatelites(char *arg)
}
#endif
#ifdef DMESG_SIZE
static void printDmesg(char *cmdline __attribute__((unused))) {
int size = dmesg_head - dmesg_buffer;
cliPrintLinef("log size written: %i", size);
for (int ii = 0; ii < size; ii++) {
cliWrite(dmesg_buffer[ii]);
}
}
#endif
static void cliHelp(char *cmdline);
// should be sorted a..z for bsearch()
@ -4829,6 +4844,9 @@ const clicmd_t cmdTable[] = {
CLI_COMMAND_DEF("dfu", "DFU mode on reboot", NULL, cliDfu),
CLI_COMMAND_DEF("diff", "list configuration changes from default",
"[master|battery_profile|control_profile|mixer_profile|rates|all] {showdefaults}", cliDiff),
#ifdef DMESG_SIZE
CLI_COMMAND_DEF("dmesg", "init log (DMESG_SIZE)", NULL, printDmesg),
#endif
CLI_COMMAND_DEF("dump", "dump configuration",
"[master|battery_profile|control_profile|mixer_profile|rates|all] {showdefaults}", cliDump),
#ifdef USE_RX_ELERES