Merge tag 'tpm-master-28012025' of https://source.denx.de/u-boot/custodians/u-boot-tpm
[u-boot.git] / cmd / conitrace.c
blob6cc113328ebc85fac20790580e129503065b5694
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * The 'conitrace' command prints the codes received from the console input as
4 * hexadecimal numbers.
6 * Copyright (c) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de>
7 */
8 #include <command.h>
9 #include <linux/delay.h>
11 static int do_conitrace(struct cmd_tbl *cmdtp, int flag, int argc,
12 char *const argv[])
14 bool first = true;
16 printf("Waiting for your input\n");
17 printf("To terminate type 'x'\n");
19 /* Empty input buffer */
20 while (tstc())
21 getchar();
23 for (;;) {
24 int c = getchar();
26 if (first && (c == 'x' || c == 'X'))
27 break;
29 printf("%02x ", c);
30 first = false;
32 /* 10 ms delay - serves to detect separate keystrokes */
33 udelay(10000);
34 if (!tstc()) {
35 printf("\n");
36 first = true;
40 return CMD_RET_SUCCESS;
43 U_BOOT_LONGHELP(conitrace, "");
45 U_BOOT_CMD_COMPLETE(
46 conitrace, 2, 0, do_conitrace,
47 "trace console input",
48 conitrace_help_text, NULL