From: Olivier Matz Date: Thu, 18 Sep 2014 17:46:28 +0000 (+0200) Subject: imuboard/cmdline: read chars per burst X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=37d943da645f754f0770ff6c5b547d7d397cf56d;p=fpv.git imuboard/cmdline: read chars per burst this enhance reactivity when we are logging on sdcard --- diff --git a/imuboard/cmdline.c b/imuboard/cmdline.c index 91360a9..4eee061 100644 --- a/imuboard/cmdline.c +++ b/imuboard/cmdline.c @@ -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) diff --git a/imuboard/cmdline.h b/imuboard/cmdline.h index 034244a..0adfa0e 100644 --- a/imuboard/cmdline.h +++ b/imuboard/cmdline.h @@ -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);