X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fao_cmd.c;h=58039f3a20df24860438ca0815cebfb5f160197c;hb=2d77c18b15834046b7b79d49d87211828f2409e9;hp=33619b245086b8f8ad8a6de1f4cada00d542b64d;hpb=210dbaa23cdacf3a6f2d6e23493e96ee2ac9bca7;p=fw%2Faltos diff --git a/src/ao_cmd.c b/src/ao_cmd.c index 33619b24..58039f3a 100644 --- a/src/ao_cmd.c +++ b/src/ao_cmd.c @@ -171,6 +171,20 @@ ao_cmd_decimal(void) ao_cmd_status = r; } +uint8_t +ao_match_word(__code char *word) +{ + while (*word) { + if (ao_cmd_lex_c != *word) { + ao_cmd_status = ao_cmd_syntax_error; + return 0; + } + word++; + ao_cmd_lex(); + } + return 1; +} + static void eol(void) { @@ -179,37 +193,21 @@ eol(void) } static void -dump(void) +echo(void) { - __xdata uint16_t c; - __xdata uint8_t * __xdata start, * __xdata end; - - ao_cmd_hex(); - start = (uint8_t __xdata *) ao_cmd_lex_i; ao_cmd_hex(); - end = (uint8_t __xdata *) ao_cmd_lex_i; - if (ao_cmd_status != ao_cmd_success) - return; - c = 0; - while (start <= end) { - if ((c & 7) == 0) { - if (c) - putchar('\n'); - ao_cmd_put16((uint16_t) start); - } - putchar(' '); - ao_cmd_put8(*start); - ++c; - start++; - } - putchar('\n'); + lex_echo = ao_cmd_lex_i != 0; } static void -echo(void) +ao_reboot(void) { - ao_cmd_hex(); - lex_echo = ao_cmd_lex_i != 0; + ao_cmd_white(); + if (!ao_match_word("eboot")) + return; + WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_64; + ao_sleep(AO_SEC_TO_TICKS(2)); + ao_panic(AO_PANIC_REBOOT); } static void @@ -305,7 +303,7 @@ __code struct ao_cmds ao_base_cmds[] = { { '?', help, "? Print this message" }, { 'T', ao_task_info, "T Show task states" }, { 'E', echo, "E <0 off, 1 on> Set command echo mode" }, - { 'd', dump, "d Dump memory" }, + { 'r', ao_reboot, "r eboot Reboot" }, { 'v', version, "v Show version" }, { 0, help, NULL }, };