All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] cmd: add conitrace command
@ 2018-09-07 17:43 Heinrich Schuchardt
  2018-09-26 12:49 ` [U-Boot] [U-Boot,1/1] " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2018-09-07 17:43 UTC (permalink / raw)
  To: u-boot

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>
---
 cmd/Kconfig     |  6 ++++++
 cmd/Makefile    |  1 +
 cmd/conitrace.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 cmd/conitrace.c

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 13d4c991bf..cf97a0f2be 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1338,6 +1338,12 @@ config CMD_CACHE
 	help
 	  Enable the "icache" and "dcache" commands
 
+config CMD_CONITRACE
+	bool "conitrace - trace console input codes"
+	help
+	  Enable the 'conitrace' command which displays the codes received
+	  from the console input as hexadecimal numbers.
+
 config CMD_DISPLAY
 	bool "Enable the 'display' command, for character displays"
 	help
diff --git a/cmd/Makefile b/cmd/Makefile
index 3487c80455..88045dea97 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_CMD_CACHE) += cache.o
 obj-$(CONFIG_CMD_CBFS) += cbfs.o
 obj-$(CONFIG_CMD_CLK) += clk.o
 obj-$(CONFIG_CMD_CONFIG) += config.o
+obj-$(CONFIG_CMD_CONITRACE) += conitrace.o
 obj-$(CONFIG_CMD_CONSOLE) += console.o
 obj-$(CONFIG_CMD_CPU) += cpu.o
 obj-$(CONFIG_DATAFLASH_MMC_SELECT) += dataflash_mmc_mux.o
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
+);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [U-Boot,1/1] cmd: add conitrace command
  2018-09-07 17:43 [U-Boot] [PATCH 1/1] cmd: add conitrace command Heinrich Schuchardt
@ 2018-09-26 12:49 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2018-09-26 12:49 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 07, 2018 at 07:43:11PM +0200, Heinrich Schuchardt wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180926/e9083096/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-26 12:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07 17:43 [U-Boot] [PATCH 1/1] cmd: add conitrace command Heinrich Schuchardt
2018-09-26 12:49 ` [U-Boot] [U-Boot,1/1] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.