Skip to content

Commit 0fb1f81

Browse files
danielinuxdgarske
authored andcommitted
STM32H5 Test app: improved console
1 parent 9b61f89 commit 0fb1f81

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

test-app/app_stm32h5.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static void console_loop(void)
653653
int ret;
654654
int idx = 0;
655655
char cmd[CMD_BUFFER_SIZE];
656-
char c;
656+
unsigned char c;
657657
while (1) {
658658
printf("\r\n");
659659
printf("cmd> ");
@@ -662,9 +662,23 @@ static void console_loop(void)
662662
do {
663663
ret = uart_rx_isr((uint8_t *)&c, 1);
664664
if (ret > 0) {
665-
if (c == '\r')
666-
break;
667-
cmd[idx++] = c;
665+
if ((c >= 32) && (c < 127)) {
666+
printf("%c", c);
667+
fflush(stdout);
668+
cmd[idx++] = (char)c;
669+
} else if (c == '\r') {
670+
printf("\r\n");
671+
fflush(stdout);
672+
break; /* End of command. Parse it. */
673+
} else if (c == 0x08) { /* Backspace */
674+
if (idx > 0) {
675+
printf("%c", 0x08);
676+
printf(" ");
677+
printf("%c", 0x08);
678+
fflush(stdout);
679+
idx--;
680+
}
681+
}
668682
}
669683
} while (idx < (CMD_BUFFER_SIZE - 1));
670684
if (idx > 0) {

0 commit comments

Comments
 (0)