You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/09/27 19:18:08 UTC

[6/6] incubator-mynewt-core git commit: console; make console history configurable with syscfg.

console; make console history configurable with syscfg.


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/8897a2f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8897a2f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8897a2f1

Branch: refs/heads/develop
Commit: 8897a2f1a64486ca5a3656cd9796b685a1b68683
Parents: 1c36256
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Sep 27 12:17:32 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Sep 27 12:17:32 2016 -0700

----------------------------------------------------------------------
 libs/console/full/pkg.yml        |  5 ++++-
 libs/console/full/src/cons_tty.c | 27 ++++++++++++++-------------
 2 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8897a2f1/libs/console/full/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/console/full/pkg.yml b/libs/console/full/pkg.yml
index f7b895f..80242ca 100644
--- a/libs/console/full/pkg.yml
+++ b/libs/console/full/pkg.yml
@@ -38,4 +38,7 @@ pkg.syscfg_defs:
         value: '0'
     CONSOLE_ECHO:
         description: 'Default console echo '
-        value: '0'
\ No newline at end of file
+        value: '1'
+    CONSOLE_HIST_ENABLE:
+        description: 'Console history '
+        value: 1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8897a2f1/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 b14fd07..f9690d3 100644
--- a/libs/console/full/src/cons_tty.c
+++ b/libs/console/full/src/cons_tty.c
@@ -33,8 +33,9 @@ int console_is_midline;
 
 #define CONSOLE_TX_BUF_SZ       32      /* IO buffering, must be power of 2 */
 #define CONSOLE_RX_BUF_SZ       128
+#define CONSOLE_RX_CHUNK        16
 
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
 #define CONSOLE_HIST_SZ         32
 #endif
 
@@ -71,7 +72,7 @@ struct console_tty {
     uint8_t ct_esc_seq:2;
 } console_tty;
 
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
 struct console_hist {
     uint8_t ch_head;
     uint8_t ch_tail;
@@ -129,7 +130,7 @@ console_queue_char(char ch)
     OS_EXIT_CRITICAL(sr);
 }
 
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
 static void
 console_hist_init(void)
 {
@@ -368,7 +369,7 @@ console_rx_char(void *arg, uint8_t data)
     struct console_ring *rx = &ct->ct_rx;
     int tx_space = 0;
     int i;
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
     uint8_t tx_buf[CONSOLE_RX_BUF_SZ];
 #else
     uint8_t tx_buf[3];
@@ -387,8 +388,6 @@ console_rx_char(void *arg, uint8_t data)
     /* echo */
     switch (data) {
     case '\r':
-        break;
-    case '\n':
         /*
          * linefeed
          */
@@ -396,7 +395,7 @@ console_rx_char(void *arg, uint8_t data)
         tx_buf[1] = '\r';
         tx_space = 2;
         console_add_char(rx, '\n');
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
         console_hist_add(rx);
 #endif
         if (ct->ct_rx_cb) {
@@ -426,7 +425,7 @@ console_rx_char(void *arg, uint8_t data)
         if (ct->ct_esc_seq != 2) {
             goto queue_char;
         }
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
         tx_space = console_hist_move(rx, tx_buf, data);
         tx_buf[tx_space] = 0;
         ct->ct_esc_seq = 0;
@@ -446,11 +445,13 @@ console_rx_char(void *arg, uint8_t data)
                 console_add_char(tx, '\b');
                 console_add_char(tx, ' ');
                 console_add_char(tx, '\b');
-                hal_uart_start_tx(CONSOLE_UART);
+                uart_start_tx(ct->ct_dev);
             }
-        }
-        if (tx_space == 0) {
-            goto out;
+            if (tx_space == 0) {
+                goto out;
+            }
+        } else {
+            goto queue_char;
         }
         break;
 #else
@@ -541,7 +542,7 @@ console_init(console_rx_cb rx_cb)
         ct->ct_echo_off = ! MYNEWT_VAL(CONSOLE_ECHO);
     }
 
-#ifdef CONSOLE_HIST_ENABLE
+#if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
     console_hist_init();
 #endif