mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 03:19:58 +03:00
dmesg: log init messages to RAM until serial init
This commit is contained in:
parent
0861a44903
commit
e38e55a26c
2 changed files with 35 additions and 0 deletions
|
@ -61,6 +61,11 @@ PG_RESET_TEMPLATE(logConfig_t, logConfig,
|
||||||
.topics = SETTING_LOG_TOPICS_DEFAULT
|
.topics = SETTING_LOG_TOPICS_DEFAULT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if defined(DMESG_SIZE)
|
||||||
|
char dmesg_buffer[DMESG_SIZE];
|
||||||
|
char *dmesg_head = dmesg_buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
void logInit(void)
|
void logInit(void)
|
||||||
{
|
{
|
||||||
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_LOG);
|
const serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_LOG);
|
||||||
|
@ -135,6 +140,18 @@ static void logPrint(const char *buf, size_t size)
|
||||||
} else if (mspLogPort) {
|
} else if (mspLogPort) {
|
||||||
mspSerialPushPort(MSP_DEBUGMSG, (uint8_t*)buf, size, mspLogPort, MSP_V2_NATIVE);
|
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)
|
static size_t logFormatPrefix(char *buf, const timeMs_t timeMs)
|
||||||
|
|
|
@ -130,6 +130,11 @@ bool cliMode = false;
|
||||||
extern timeDelta_t cycleTime; // FIXME dependency on mw.c
|
extern timeDelta_t cycleTime; // FIXME dependency on mw.c
|
||||||
extern uint8_t detectedSensors[SENSOR_INDEX_COUNT];
|
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 serialPort_t *cliPort;
|
||||||
|
|
||||||
static bufWriter_t *cliWriter;
|
static bufWriter_t *cliWriter;
|
||||||
|
@ -4798,6 +4803,16 @@ static void cliUbloxPrintSatelites(char *arg)
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
static void cliHelp(char *cmdline);
|
||||||
|
|
||||||
// should be sorted a..z for bsearch()
|
// 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("dfu", "DFU mode on reboot", NULL, cliDfu),
|
||||||
CLI_COMMAND_DEF("diff", "list configuration changes from default",
|
CLI_COMMAND_DEF("diff", "list configuration changes from default",
|
||||||
"[master|battery_profile|control_profile|mixer_profile|rates|all] {showdefaults}", cliDiff),
|
"[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",
|
CLI_COMMAND_DEF("dump", "dump configuration",
|
||||||
"[master|battery_profile|control_profile|mixer_profile|rates|all] {showdefaults}", cliDump),
|
"[master|battery_profile|control_profile|mixer_profile|rates|all] {showdefaults}", cliDump),
|
||||||
#ifdef USE_RX_ELERES
|
#ifdef USE_RX_ELERES
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue