From f16cf261979ca29d7d0d89e9e8e3d1dfe1077b50 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Tue, 1 Aug 2017 16:16:16 +0200 Subject: [PATCH] shell: flash: use console_getc() instead of getc() --- source/shell/flash.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/shell/flash.c b/source/shell/flash.c index 55b4eca..410a49a 100644 --- a/source/shell/flash.c +++ b/source/shell/flash.c @@ -14,9 +14,7 @@ struct flash_dev *flash = NULL; -/* TODO: implement a parser for hex arrays that is more user-friendly. - * Also implement dry runs for programmers. */ -static void parse_hex(FILE *fp, char *buf, size_t len) +static void parse_hex(struct console *con, char *buf, size_t len) { size_t i; char s[3]; @@ -24,8 +22,8 @@ static void parse_hex(FILE *fp, char *buf, size_t len) for (i = 0; i < len; ++i) { memset(s, '\0', 3); - while ((s[0] = getc(fp)) && !isxdigit(s[0])); - while ((s[1] = getc(fp)) && !isxdigit(s[1])); + while (console_getc(s + 0, con) && !isxdigit(s[0])); + while (console_getc(s + 1, con) && !isxdigit(s[1])); *buf++ = strtoul(s, NULL, 16); } @@ -192,7 +190,7 @@ static int do_flash_write(struct console *con, size_t argc, const char **argv) while (len) { nbytes = min(len, 256); - parse_hex(con->fp, buf, nbytes); + parse_hex(con, buf, nbytes); printf("\n"); print_hex_ascii(con->fp, addr, buf, nbytes);