X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao_cmd.c;h=827545d0ee8842a94ed41fb376e1d0da38cc0de9;hp=7f7865364da5a4a10949a1a5e2d964aeecca1512;hb=e9584e846b9bd7926d61451d32ba5d7a30416f7b;hpb=8e62747b3692d0ac75b08eaf5c3e4b5d766be6ad diff --git a/ao_cmd.c b/ao_cmd.c index 7f786536..827545d0 100644 --- a/ao_cmd.c +++ b/ao_cmd.c @@ -18,20 +18,20 @@ #include "ao.h" __xdata uint16_t ao_cmd_lex_i; -__xdata uint8_t ao_cmd_lex_c; +__xdata char ao_cmd_lex_c; __xdata enum ao_cmd_status ao_cmd_status; static __xdata uint8_t lex_echo; #define CMD_LEN 32 -static __xdata uint8_t cmd_line[CMD_LEN]; +static __xdata char cmd_line[CMD_LEN]; static __xdata uint8_t cmd_len; static __xdata uint8_t cmd_i; static void put_string(char *s) { - __xdata uint8_t c; + __xdata char c; while (c = *s++) putchar(c); } @@ -39,7 +39,7 @@ put_string(char *s) static void readline(void) { - __xdata uint8_t c; + __xdata char c; if (lex_echo) put_string("> "); cmd_len = 0; @@ -152,9 +152,8 @@ ao_cmd_hex(void) ao_cmd_status = r; } -#if 0 -static void -decimal(void) +void +ao_cmd_decimal(void) { __xdata uint8_t r = ao_cmd_lex_error; @@ -162,7 +161,7 @@ decimal(void) ao_cmd_white(); for(;;) { if ('0' <= ao_cmd_lex_c && ao_cmd_lex_c <= '9') - ao_cmd_lex_i = (ao_cmd_lex_i * 10 ) | (ao_cmd_lex_c - '0'); + ao_cmd_lex_i = (ao_cmd_lex_i * 10) + (ao_cmd_lex_c - '0'); else break; r = ao_cmd_success; @@ -171,7 +170,6 @@ decimal(void) if (r != ao_cmd_success) ao_cmd_status = r; } -#endif static void eol(void) @@ -214,9 +212,18 @@ echo(void) lex_echo = ao_cmd_lex_i != 0; } -static const uint8_t help_txt[] = "All numbers are in hex"; +static void +version(void) +{ + printf("manufacturer %s\n", ao_manufacturer); + printf("product %s\n", ao_product); + printf("serial-number %u\n", ao_serial_number); + printf("software-version %s\n", ao_version); +} + +static const char help_txt[] = "All numbers are in hex"; -#define NUM_CMDS 10 +#define NUM_CMDS 11 static __code struct ao_cmds *__xdata (ao_cmds[NUM_CMDS]); static __xdata uint8_t ao_ncmds; @@ -258,7 +265,7 @@ ao_cmd_register(__code struct ao_cmds *cmds) void ao_cmd(void *parameters) { - __xdata uint8_t c; + __xdata char c; __xdata uint8_t cmd, cmds; __code struct ao_cmds * __xdata cs; void (*__xdata func)(void); @@ -299,6 +306,7 @@ __code struct ao_cmds ao_base_cmds[] = { { 'T', ao_task_info, "T Show task states" }, { 'E', echo, "E <0 off, 1 on> Set command echo mode" }, { 'd', dump, "d Dump memory" }, + { 'v', version, "v Show version" }, { 0, help, NULL }, };