Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 8f78cd3bc -> b6fa07ad9
console; change the API for read to return whether it's partial. Remove the argument to RX callback. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/524192c4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/524192c4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/524192c4 Branch: refs/heads/develop Commit: 524192c4e7a409009071c02f6461ca6389fdc026 Parents: 8f78cd3 Author: Marko Kiiskila <[email protected]> Authored: Wed May 25 13:09:30 2016 -0700 Committer: Marko Kiiskila <[email protected]> Committed: Wed May 25 13:09:30 2016 -0700 ---------------------------------------------------------------------- libs/console/full/include/console/console.h | 4 ++-- libs/console/full/src/cons_tty.c | 10 ++++++---- libs/console/stub/include/console/console.h | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/524192c4/libs/console/full/include/console/console.h ---------------------------------------------------------------------- diff --git a/libs/console/full/include/console/console.h b/libs/console/full/include/console/console.h index 2f062f9..a196f01 100644 --- a/libs/console/full/include/console/console.h +++ b/libs/console/full/include/console/console.h @@ -21,12 +21,12 @@ #include <stdarg.h> -typedef void (*console_rx_cb)(int full_line); +typedef void (*console_rx_cb)(void); int console_init(console_rx_cb rx_cb); int console_is_init(void); void console_write(const char *str, int cnt); -int console_read(char *str, int cnt); +int console_read(char *str, int cnt, int *newline); void console_blocking_mode(void); void console_echo(int on); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/524192c4/libs/console/full/src/cons_tty.c ---------------------------------------------------------------------- diff --git a/libs/console/full/src/cons_tty.c b/libs/console/full/src/cons_tty.c index a50f1a6..7dfd0b7 100644 --- a/libs/console/full/src/cons_tty.c +++ b/libs/console/full/src/cons_tty.c @@ -185,7 +185,7 @@ console_write(const char *str, int cnt) } int -console_read(char *str, int cnt) +console_read(char *str, int cnt, int *newline) { struct console_tty *ct = &console_tty; struct console_ring *cr = &ct->ct_rx; @@ -193,6 +193,7 @@ console_read(char *str, int cnt) int i; uint8_t ch; + *newline = 0; OS_ENTER_CRITICAL(sr); for (i = 0; i < cnt; i++) { if (cr->cr_head == cr->cr_tail) { @@ -210,12 +211,13 @@ console_read(char *str, int cnt) ch = console_pull_char(cr); if (ch == '\n') { *str = '\0'; + *newline = 1; break; } *str++ = ch; } OS_EXIT_CRITICAL(sr); - if (i >= 0) { + if (i > 0 || *newline) { hal_uart_start_rx(CONSOLE_UART); } return i; @@ -263,7 +265,7 @@ console_rx_char(void *arg, uint8_t data) * RX queue full. Reader must drain this. */ if (ct->ct_rx_cb) { - ct->ct_rx_cb(0); + ct->ct_rx_cb(); } return -1; } @@ -280,7 +282,7 @@ console_rx_char(void *arg, uint8_t data) tx_space = 2; console_add_char(rx, '\n'); if (ct->ct_rx_cb) { - ct->ct_rx_cb(1); + ct->ct_rx_cb(); } break; case CONSOLE_ESC: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/524192c4/libs/console/stub/include/console/console.h ---------------------------------------------------------------------- diff --git a/libs/console/stub/include/console/console.h b/libs/console/stub/include/console/console.h index d0858e2..99db457 100644 --- a/libs/console/stub/include/console/console.h +++ b/libs/console/stub/include/console/console.h @@ -6,7 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, @@ -21,7 +21,7 @@ #include <stdarg.h> -typedef void (*console_rx_cb)(int full_line); +typedef void (*console_rx_cb)(void); static int inline console_is_init(void) @@ -36,8 +36,9 @@ console_init(console_rx_cb rxcb) } static int inline -console_read(char *str, int cnt) +console_read(char *str, int cnt, int *newline) { + *newline = 0; return 0; }
