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

[GitHub] utzig closed pull request #677: sys/console: Fix console freeze

utzig closed pull request #677: sys/console: Fix console freeze
URL: https://github.com/apache/mynewt-core/pull/677
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sys/console/full/src/uart_console.c b/sys/console/full/src/uart_console.c
index df33cc7e3..5d708f140 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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services