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 2018/09/07 23:25:27 UTC

[GitHub] ccollins476ad closed pull request #1390: sys/console/full: Prevent permanent rx stall

ccollins476ad closed pull request #1390: sys/console/full: Prevent permanent rx stall
URL: https://github.com/apache/mynewt-core/pull/1390
 
 
   

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 252d576dae..bd40ff7fd9 100644
--- a/sys/console/full/src/uart_console.c
+++ b/sys/console/full/src/uart_console.c
@@ -45,6 +45,7 @@ static console_write_char write_char_cb;
 #if MYNEWT_VAL(CONSOLE_UART_RX_BUF_SIZE) > 0
 static struct console_ring cr_rx;
 static uint8_t cr_rx_buf[MYNEWT_VAL(CONSOLE_UART_RX_BUF_SIZE)];
+static volatile bool uart_console_rx_stalled;
 
 struct os_event rx_ev;
 #endif
@@ -208,6 +209,7 @@ uart_console_rx_char(void *arg, uint8_t byte)
 {
 #if MYNEWT_VAL(CONSOLE_UART_RX_BUF_SIZE) > 0
     if (uart_console_ring_is_full(&cr_rx)) {
+        uart_console_rx_stalled = true;
         return -1;
     }
 
@@ -237,12 +239,6 @@ uart_console_rx_char_event(struct os_event *ev)
         if (ret < 0) {
             return;
         }
-
-        /*
-         * It is possible that UART RX was stalled in the meantime since we were
-         * not consuming data from ring buffer - make sure RX is started.
-         */
-        uart_start_rx(uart_dev);
     }
 
     while (!uart_console_ring_is_empty(&cr_rx)) {
@@ -250,6 +246,14 @@ uart_console_rx_char_event(struct os_event *ev)
         b = uart_console_ring_pull_char(&cr_rx);
         OS_EXIT_CRITICAL(sr);
 
+        /* If UART RX was stalled due to a full receive buffer, restart RX now
+         * that we have removed a byte from the buffer.
+         */
+        if (uart_console_rx_stalled) {
+            uart_console_rx_stalled = false;
+            uart_start_rx(uart_dev);
+        }
+
         ret = console_handle_char(b);
         if (ret < 0) {
             return;


 

----------------------------------------------------------------
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