2018-09-07 17:43:11 +00:00
|
|
|
// 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>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2018-09-07 17:43:11 +00:00
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
static int do_conitrace(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
2018-09-07 17:43:11 +00:00
|
|
|
{
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
printf("Waiting for your input\n");
|
|
|
|
printf("To terminate type 'x'\n");
|
|
|
|
|
|
|
|
/* Empty input buffer */
|
|
|
|
while (tstc())
|
2020-10-23 10:46:04 +00:00
|
|
|
getchar();
|
2018-09-07 17:43:11 +00:00
|
|
|
|
|
|
|
for (;;) {
|
2020-10-23 10:46:04 +00:00
|
|
|
int c = getchar();
|
2018-09-07 17:43:11 +00:00
|
|
|
|
|
|
|
if (first && (c == 'x' || c == 'X'))
|
|
|
|
break;
|
|
|
|
|
|
|
|
printf("%02x ", c);
|
|
|
|
first = false;
|
|
|
|
|
2020-12-26 23:12:28 +00:00
|
|
|
/* 10 ms delay - serves to detect separate keystrokes */
|
|
|
|
udelay(10000);
|
2018-09-07 17:43:11 +00:00
|
|
|
if (!tstc()) {
|
|
|
|
printf("\n");
|
|
|
|
first = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-10-07 19:13:08 +00:00
|
|
|
U_BOOT_LONGHELP(conitrace, "");
|
2018-09-07 17:43:11 +00:00
|
|
|
|
|
|
|
U_BOOT_CMD_COMPLETE(
|
|
|
|
conitrace, 2, 0, do_conitrace,
|
|
|
|
"trace console input",
|
|
|
|
conitrace_help_text, NULL
|
|
|
|
);
|