diff options
| author | Keith Packard <keithp@keithp.com> | 2018-08-15 19:13:45 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2018-10-13 08:22:50 -0700 |
| commit | c417ab1de2a083b5fcff2e081e4feb2a65887903 (patch) | |
| tree | 614c7564321ea38402883992daeaea8f30bfe6b1 /src/drivers/ao_btm.c | |
| parent | c6e57291d91f1f6c4de5c54a5cfd3eef66d9f830 (diff) | |
altos: Make cmd number parsing functions return value
Don't use a global variable to hold the result.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_btm.c')
| -rw-r--r-- | src/drivers/ao_btm.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/drivers/ao_btm.c b/src/drivers/ao_btm.c index 3591f8f2..2930d00e 100644 --- a/src/drivers/ao_btm.c +++ b/src/drivers/ao_btm.c @@ -32,7 +32,7 @@ int8_t ao_btm_stdio; uint8_t ao_btm_connected; -#define BT_DEBUG 0 +#define BT_DEBUG 1 #if BT_DEBUG char ao_btm_buffer[256]; @@ -76,6 +76,7 @@ ao_btm_dump(void) { int i; char c; + uint16_t r; for (i = 0; i < ao_btm_ptr; i++) { c = ao_btm_buffer[i]; @@ -85,8 +86,8 @@ ao_btm_dump(void) putchar(ao_btm_buffer[i]); } putchar('\n'); - ao_cmd_decimal(); - if (ao_cmd_status == ao_cmd_success && ao_cmd_lex_i) + r = ao_cmd_decimal(); + if (ao_cmd_status == ao_cmd_success && r) ao_btm_ptr = 0; ao_cmd_status = ao_cmd_success; } @@ -94,13 +95,17 @@ ao_btm_dump(void) static void ao_btm_speed(void) { - ao_cmd_decimal(); - if (ao_cmd_lex_u32 == 57600) + switch (ao_cmd_decimal()) { + case 57600: ao_serial_btm_set_speed(AO_SERIAL_SPEED_57600); - else if (ao_cmd_lex_u32 == 19200) + break; + case 19200: ao_serial_btm_set_speed(AO_SERIAL_SPEED_19200); - else + break; + default: ao_cmd_status = ao_cmd_syntax_error; + break; + } } static uint8_t ao_btm_enable; |
