You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2019/11/27 21:38:22 UTC

[mynewt-core] branch master updated: sys/console: Restore old style CR LF handling for nlip

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

vipulrahane 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 153dfb8  sys/console: Restore old style CR LF handling for nlip
     new 10f19ec  Merge pull request #2114 from kasjer/kasjer/console-nlip-compatiblity
153dfb8 is described below

commit 153dfb8b7d13f0cf16298fd6e3b5235909fe2f30
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Nov 27 13:25:30 2019 +0100

    sys/console: Restore old style CR LF handling for nlip
    
    There were reports that latest console changes affect
    existing eco-system that depends on CR and LF characters
    to be handled even if console is instructed to ignore
    non-nlip traffic.
    
    This change allow simple test that device is alive by
    pressing Enter on keyboard.
    Original code also echo back some other random non
    printable characters but this is not restored.
---
 sys/console/full/src/console.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/console/full/src/console.c b/sys/console/full/src/console.c
index 2ae1be9..491b9c2 100644
--- a/sys/console/full/src/console.c
+++ b/sys/console/full/src/console.c
@@ -1048,12 +1048,11 @@ handle_nlip(uint8_t byte)
     struct console_input *input;
 
     input = current_line_ev->ev_arg;
-    handled = 0;
+    handled = 1;
 
     switch (nlip_state) {
     case NLIP_PKT_START2:
     case NLIP_DATA_START2:
-        handled = 1;
         insert_char(&input->line[cur], byte);
         if (byte == '\n') {
             input->line[cur] = '\0';
@@ -1065,7 +1064,6 @@ handle_nlip(uint8_t byte)
         break;
     case NLIP_PKT_START1:
         if (byte == CONSOLE_NLIP_PKT_START2) {
-            handled = 1;
             nlip_state = NLIP_PKT_START2;
             /* Disable echo to not flood the UART */
             console_echo(0);
@@ -1073,11 +1071,11 @@ handle_nlip(uint8_t byte)
             insert_char(&input->line[cur], CONSOLE_NLIP_PKT_START2);
         } else {
             nlip_state = 0;
+            handled = g_console_ignore_non_nlip;
         }
         break;
     case NLIP_DATA_START1:
         if (byte == CONSOLE_NLIP_DATA_START2) {
-            handled = 1;
             nlip_state = NLIP_DATA_START2;
             /* Disable echo to not flood the UART */
             console_echo(0);
@@ -1085,15 +1083,17 @@ handle_nlip(uint8_t byte)
             insert_char(&input->line[cur], CONSOLE_NLIP_DATA_START2);
         } else {
             nlip_state = 0;
+            handled = g_console_ignore_non_nlip;
         }
         break;
     default:
         if (byte == CONSOLE_NLIP_DATA_START1) {
-            handled = 1;
             nlip_state = NLIP_DATA_START1;
         } else if (byte == CONSOLE_NLIP_PKT_START1) {
-            handled = 1;
             nlip_state = NLIP_PKT_START1;
+        } else {
+            /* For old code compatibility end of lines characters pass through */
+            handled = g_console_ignore_non_nlip && byte != '\r' && byte != '\n';
         }
         break;
     }
@@ -1147,7 +1147,7 @@ console_handle_char(uint8_t byte)
     }
     input = current_line_ev->ev_arg;
 
-    if (handle_nlip(byte) || g_console_ignore_non_nlip) {
+    if (handle_nlip(byte)) {
         return 0;
     }