summaryrefslogtreecommitdiff
path: root/cmd/conitrace.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-09-07 19:43:11 +0200
committerTom Rini <trini@konsulko.com>2018-09-25 21:49:18 -0400
commit29cfc096a7d3aeefdabbe4487097857ea821a553 (patch)
tree811a726505318c97190c8d5a1da077a44fd53939 /cmd/conitrace.c
parent03190a7888493058c3a0fd6c50fd0b8dadd165ee (diff)
cmd: add conitrace command
The 'conitrace' command prints the codes received from the console input as hexadecimal numbers. This developer utility is useful for testing the handling of special keys by keyboard drivers. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd/conitrace.c')
-rw-r--r--cmd/conitrace.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/cmd/conitrace.c b/cmd/conitrace.c
new file mode 100644
index 0000000000..85c5422b7e
--- /dev/null
+++ b/cmd/conitrace.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * The 'conitrace' command prints the codes received from the console input as
+ * hexadecimal numbers.
+ *
+ * Copyright (c) 2018, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ */
+#include <common.h>
+#include <command.h>
+
+static int do_conitrace(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ bool first = true;
+
+ printf("Waiting for your input\n");
+ printf("To terminate type 'x'\n");
+
+ /* Empty input buffer */
+ while (tstc())
+ getc();
+
+ for (;;) {
+ int c = getc();
+
+ if (first && (c == 'x' || c == 'X'))
+ break;
+
+ printf("%02x ", c);
+ first = false;
+
+ /* 1 ms delay - serves to detect separate keystrokes */
+ udelay(1000);
+ if (!tstc()) {
+ printf("\n");
+ first = true;
+ }
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char conitrace_help_text[] = "";
+#endif
+
+U_BOOT_CMD_COMPLETE(
+ conitrace, 2, 0, do_conitrace,
+ "trace console input",
+ conitrace_help_text, NULL
+);