Skip to content

Commit ab5dfac

Browse files
committed
Add uhk snaplog command.
1 parent f3384ee commit ab5dfac

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

device/src/proxy_log_backend.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ void ProxyLog_GetFill(uint16_t* occupied, uint16_t* length) {
7777
*length = PROXY_BACKEND_BUFFER_SIZE;
7878
}
7979

80+
void ProxyLog_SnapToStatusBuffer(void) {
81+
StateWormhole_Open();
82+
StateWormhole.persistStatusBuffer = true;
83+
84+
uint16_t pos = bufferPosition;
85+
uint16_t len = bufferLength;
86+
87+
for (uint16_t i = 0; i < len; i++) {
88+
char c = buffer[pos];
89+
Macros_SanitizedPut(&c, &c + 1);
90+
pos = (pos + 1) % PROXY_BACKEND_BUFFER_SIZE;
91+
}
92+
}
93+
8094
static void processLog(const struct log_backend *const backend, union log_msg_generic *msg);
8195

8296
void panic(const struct log_backend *const backend) {

device/src/proxy_log_backend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
void InitProxyLogBackend(void);
2424
uint16_t ProxyLog_ConsumeLog(uint8_t* outBuf, uint16_t outBufSize);
2525
void ProxyLog_GetFill(uint16_t* occupied, uint16_t* length);
26+
void ProxyLog_SnapToStatusBuffer(void);
2627

2728
#endif /* __MACRO_SET_COMMAND_H__ */

device/src/shell.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,13 @@ static int cmd_uhk_logs(const struct shell *shell, size_t argc, char *argv[])
381381
return 0;
382382
}
383383

384+
static int cmd_uhk_snaplog(const struct shell *shell, size_t argc, char *argv[])
385+
{
386+
ProxyLog_SnapToStatusBuffer();
387+
printk("Log snapped to status buffer.\n");
388+
return 0;
389+
}
390+
384391

385392
static int reinitShell(const struct device *const dev)
386393
{
@@ -485,6 +492,7 @@ void InitShellCommands(void)
485492
SHELL_CMD_ARG(mouseMultipliers, NULL, "print mouse multipliers", cmd_uhk_mouseMultipliers, 1, 0),
486493
SHELL_CMD_ARG(logPriority, NULL, "set log priority", cmd_uhk_logPriority, 2, 0),
487494
SHELL_CMD_ARG(logs, NULL, "Set/get proxy log enabled", cmd_uhk_logs, 1, 1),
495+
SHELL_CMD_ARG(snaplog, NULL, "Snap log buffer to status buffer", cmd_uhk_snaplog, 1, 0),
488496
SHELL_CMD_ARG(shells, NULL, "list available shell backends", cmd_uhk_shells, 1, 0),
489497
SHELL_CMD_ARG(irqs, NULL, "list enabled IRQs and their priorities", cmd_uhk_irqs, 1, 0),
490498
SHELL_SUBCMD_SET_END);

0 commit comments

Comments
 (0)