diff options
-rw-r--r-- | avr/cli.c | 2 | ||||
-rw-r--r-- | avr/cmd_boot.c | 24 | ||||
-rw-r--r-- | include/cli.h | 9 |
3 files changed, 33 insertions, 2 deletions
@@ -313,7 +313,7 @@ static int cli_run_command_list(const char *cmd) /* - * Run a command using the selected parser. + * Run a command. * * @param cmd Command to run * @param flag Execution flags (CMD_FLAG_...) diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c index 448ed48..b8799aa 100644 --- a/avr/cmd_boot.c +++ b/avr/cmd_boot.c @@ -16,6 +16,8 @@ #include <util/atomic.h> #include "command.h" +#include "cli_readline.h" +#include "cli.h" #include "env.h" #include "con-utils.h" #include "z80-if.h" @@ -170,8 +172,9 @@ void print_con_usage(char esc) { printf_P(PSTR("\n" "------------------------------------------------\n" " ?,H - This Help\n" - " R - Reset (Restart) CPU\n" " Q,X - Return to command line\n" + " R - Reset (Restart) CPU\n" + " : - Execute monitor command\n" " \\ - code input:\n" " \\nnn 3 decimal digits character code\n" " \\Xhh 2 hexadecimal digits character code\n" @@ -191,6 +194,8 @@ command_ret_t do_console(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv (void) cmdtp; (void) flag; (void) argc; (void) argv; + printf_P(PSTR("Connecting to CPU. Escape character is '^%c'.\n"), + esc_char + 0x40); while (1) { @@ -237,6 +242,13 @@ command_ret_t do_console(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv goto quit; break; + case ':': + putchar('\n'); + int cmdlen = cli_readline(PSTR(": ")); + if (cmdlen > 0) + run_command(console_buffer, 0); + break; + case '\\': code = 0; state = 3; @@ -259,6 +271,11 @@ command_ret_t do_console(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv if (isdigit(ch)) { code = code * 10 + ch - '0'; state++; + } else { + if (state > 3) + z80_memfifo_putc(fifo_conin, code); + z80_memfifo_putc(fifo_conin, ch); + state = 0; } if (state > 5) { z80_memfifo_putc(fifo_conin, code); @@ -273,6 +290,11 @@ command_ret_t do_console(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv ch -= 'A' - 10; code = code * 16 + ch - '0'; state++; + }else { + if (state > 6) + z80_memfifo_putc(fifo_conin, code); + z80_memfifo_putc(fifo_conin, ch); + state = 0; } if (state > 7) { z80_memfifo_putc(fifo_conin, code); diff --git a/include/cli.h b/include/cli.h index f6fb2ab..4920cc4 100644 --- a/include/cli.h +++ b/include/cli.h @@ -66,6 +66,15 @@ void cli_loop(void); */ //int cli_simple_parse_line(char *line, char *argv[]); +/* + * Run a command. + * + * @param cmd Command to run + * @param flag Execution flags (CMD_FLAG_...) + * @return 0 on success, or != 0 on error. + */ +int run_command(const char *cmd, int flag); + int run_command_list(const char *cmd, int len); |