You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2017/11/27 09:14:43 UTC

[mynewt-core] branch master updated: sys/console: Fix console freeze

This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f37257  sys/console: Fix console freeze
2f37257 is described below

commit 2f3725787c5290a8b7b81d8da3541c5e8690c929
Author: MichaƂ Narajowski <mi...@codecoup.pl>
AuthorDate: Fri Nov 24 14:09:57 2017 +0100

    sys/console: Fix console freeze
    
    console_queue_char() may be called from interrupt context
    and waiting for uart to drain the buffer may cause the console to
    freeze. In these situations we should drop the character if
    the buffer is full.
    
    This is an easy solution to this problem, but we should redesign
    console to not do this kind of processing in interrupt context.
---
 sys/console/full/src/uart_console.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sys/console/full/src/uart_console.c b/sys/console/full/src/uart_console.c
index df33cc7..5d708f1 100644
--- a/sys/console/full/src/uart_console.c
+++ b/sys/console/full/src/uart_console.c
@@ -39,6 +39,7 @@ static struct console_ring cr_tx;
 static uint8_t cr_tx_buf[MYNEWT_VAL(CONSOLE_UART_TX_BUF_SIZE)];
 typedef void (*console_write_char)(struct uart_dev*, uint8_t);
 static console_write_char write_char_cb;
+static bool skip_if_tx_full;
 
 struct console_ring {
     uint8_t cr_head;
@@ -71,6 +72,10 @@ console_queue_char(struct uart_dev *uart_dev, uint8_t ch)
 
     OS_ENTER_CRITICAL(sr);
     while (CONSOLE_HEAD_INC(&cr_tx) == cr_tx.cr_tail) {
+        if (skip_if_tx_full) {
+            OS_EXIT_CRITICAL(sr);
+            return;
+        }
         /* TX needs to drain */
         uart_start_tx(uart_dev);
         OS_EXIT_CRITICAL(sr);
@@ -167,7 +172,12 @@ console_tx_char(void *arg)
 static int
 console_rx_char(void *arg, uint8_t byte)
 {
-    return console_handle_char(byte);
+    int rc;
+
+    skip_if_tx_full = true;
+    rc = console_handle_char(byte);
+    skip_if_tx_full  = false;
+    return rc;
 }
 
 int

-- 
To stop receiving notification emails like this one, please contact
['"commits@mynewt.apache.org" <co...@mynewt.apache.org>'].