]> git.droids-corp.org - fpv.git/commitdiff
imuboard/cmdline: read chars per burst
authorOlivier Matz <zer0@droids-corp.org>
Thu, 18 Sep 2014 17:46:28 +0000 (19:46 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 18 Sep 2014 17:46:28 +0000 (19:46 +0200)
this enhance reactivity when we are logging on sdcard

imuboard/cmdline.c
imuboard/cmdline.h

index 91360a9a5a937eed5535180663afbce01ebeeaa3..4eee0612fd021d016157fffd64eabbefaaa40aec 100644 (file)
@@ -192,34 +192,34 @@ static void flush_logs_cb(struct callout_mgr *cm, struct callout *tim,
 }
 
 
-int cmdline_poll(void)
+void cmdline_poll(void)
 {
        const char *history, *buffer;
        int8_t ret, same = 0;
        int16_t c;
 
-       c = cmdline_dev_recv(NULL);
-       if (c < 0)
-               return -1;
-
-       ret = rdline_char_in(&imuboard.rdl, c);
-       if (ret == 1) {
-               buffer = rdline_get_buffer(&imuboard.rdl);
-               history = rdline_get_history_item(&imuboard.rdl, 0);
-               if (history) {
-                       same = !memcmp(buffer, history, strlen(history)) &&
-                               buffer[strlen(history)] == '\n';
+       while (1) {
+               c = cmdline_dev_recv(NULL);
+               if (c < 0)
+                       break;
+
+               ret = rdline_char_in(&imuboard.rdl, c);
+               if (ret == 1) {
+                       buffer = rdline_get_buffer(&imuboard.rdl);
+                       history = rdline_get_history_item(&imuboard.rdl, 0);
+                       if (history) {
+                               same = !memcmp(buffer, history, strlen(history)) &&
+                                       buffer[strlen(history)] == '\n';
+                       }
+                       else
+                               same = 0;
+                       if (strlen(buffer) > 1 && !same)
+                               rdline_add_history(&imuboard.rdl, buffer);
+
+                       if (imuboard.rdl.status != RDLINE_STOPPED)
+                               rdline_newline(&imuboard.rdl, imuboard.prompt);
                }
-               else
-                       same = 0;
-               if (strlen(buffer) > 1 && !same)
-                       rdline_add_history(&imuboard.rdl, buffer);
-
-               if (imuboard.rdl.status != RDLINE_STOPPED)
-                       rdline_newline(&imuboard.rdl, imuboard.prompt);
        }
-
-       return 0;
 }
 
 void cmdline_init(void)
index 034244a6003a7409fee2fd609db28c08cb4d6891..0adfa0ec6ae4d584d0a8fbb06afb90f7be29e82b 100644 (file)
@@ -35,7 +35,7 @@ void emergency(char c);
 void mylog(struct error * e, ...);
 
 /* poll cmdline */
-int cmdline_poll(void);
+void cmdline_poll(void);
 
 int cmdline_dev_send(char c, FILE* f);
 int cmdline_dev_recv(FILE* f);