Commit from zer0 on branch b_zer0 (2007-11-21 22:54 CET)
=================================

enhance rdline and parse.
Use progmem in simple cases.

  aversive  include/aversive/pgmspace.h                 1.1.2.4
  aversive  modules/base/math/fixed_point/test/.config  1.7.4.7
  aversive  modules/ihm/parse/parse.c                   1.1.2.6
  aversive  modules/ihm/parse/parse.h                   1.1.2.6
  aversive  modules/ihm/parse/parse_string.h            1.1.2.5
  aversive  modules/ihm/rdline/rdline.c                 1.1.2.6
  aversive  modules/ihm/rdline/rdline.h                 1.1.2.3
  aversive  modules/ihm/rdline/test/.config             1.1.2.3


====================================
aversive/include/aversive/pgmspace.h  (1.1.2.3 -> 1.1.2.4)
====================================

@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: pgmspace.h,v 1.1.2.3 2007-11-15 11:15:46 zer0 Exp $
+ *  Revision : $Id: pgmspace.h,v 1.1.2.4 2007-11-21 21:54:38 zer0 Exp $
  *
  */
 
@@ -31,12 +31,14 @@
 
 #include <avr/pgmspace.h>
 
+
 #else
 
 #include <stdint.h>
 
 #define printf_P printf
 #define memcmp_P memcmp
+#define strcat_P strcat
 #define strcmp_P strcmp
 #define strncmp_P strncmp
 #define strlen_P strlen
@@ -45,8 +47,11 @@
 #define PGM_P const char *
 #define PSTR(x) x
 #define PROGMEM
-#define pgm_read_word(x) (*(x))
-#define pgm_read_byte(x) (*(x))
+
+/* XXX don't define it, it's dangerous because it can be used to read
+ * an address that have not the same size */
+/* #define pgm_read_word(x) (*(x)) */
+/* #define pgm_read_byte(x) (*(x)) */
 
 typedef void prog_void;
 typedef char prog_char;


===================================================
aversive/modules/base/math/fixed_point/test/.config  (1.7.4.6 -> 1.7.4.7)
===================================================

@@ -75,6 +75,7 @@
 # Enable math library in generation options to see all modules
 #
 CONFIG_MODULE_CIRBUF=y
+# CONFIG_MODULE_CIRBUF_LARGE is not set
 CONFIG_MODULE_FIXED_POINT=y
 # CONFIG_MODULE_VECT2 is not set
 # CONFIG_MODULE_SCHEDULER is not set
@@ -117,6 +118,11 @@
 # IHM modules
 #
 # CONFIG_MODULE_MENU is not set
+# CONFIG_MODULE_RDLINE is not set
+# CONFIG_MODULE_RDLINE_CREATE_CONFIG is not set
+# CONFIG_MODULE_RDLINE_KILL_BUF is not set
+# CONFIG_MODULE_RDLINE_HISTORY is not set
+# CONFIG_MODULE_PARSE is not set
 
 #
 # External devices modules


==================================
aversive/modules/ihm/parse/parse.c  (1.1.2.5 -> 1.1.2.6)
==================================

@@ -1,8 +1,33 @@
+/*  
+ *  Copyright Droids Corporation (2007)
+ *  Olivier MATZ <[EMAIL PROTECTED]>
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: parse.c,v 1.1.2.6 2007-11-21 21:54:39 zer0 Exp $
+ *
+ *
+ */
+
 #include <stdio.h>
 #include <string.h>
 #include <inttypes.h>
 #include <ctype.h>
 
+#include <aversive/pgmspace.h>
+
 #include "parse.h"
 
 /* XXX */
@@ -242,8 +267,7 @@
        char tmpbuf[64], completion_buf[64];
        uint8_t incomplete_token_len;
        int8_t completion_len = -1;
-       int8_t nb_token = -1;
-       uint8_t buf_len = strlen(buf);
+       int8_t nb_token = 0;
        uint8_t i, n;
        int8_t l;
        uint8_t nb_completable;
@@ -252,28 +276,12 @@
 
        debug_printf("%s called\n", __FUNCTION__);
        /* count the number of complete token to parse */
-       for (i=0 ; i<buf_len ; i++) {
-               if (nb_token == -1) {
-                       if (!isblank(buf[i])) {
-                               nb_token = 0;
-                       }
-                       incomplete_token = buf+i;
-               }
-               else {
-                       if (isblank(buf[i])) {
-                               incomplete_token = buf+i+1;
-                               if (!isblank(buf[i-1])) {
-                                       nb_token++;
-                               }
-                       }
-               }
+       for (i=0 ; buf[i] ; i++) {
+               if (!isblank(buf[i]) && isblank(buf[i+1]))
+                       nb_token++;
+               if (isblank(buf[i]) && !isblank(buf[i+1]))
+                       incomplete_token = buf+i+1;
        }
-
-       if (nb_token == -1) {
-               nb_token = 0;
-               incomplete_token++;
-       }
-
        incomplete_token_len = strlen(incomplete_token);
 
        /* first call -> do a first pass */
@@ -306,7 +314,7 @@
                        for (i=0 ; i<n ; i++) {
                                if (token->ops->complete_get_elt(token, i, 
tmpbuf, sizeof(tmpbuf)-1) < 0)
                                        continue;
-                               strcat(tmpbuf, " "); /* we have at least room 
for one char */
+                               strcat_P(tmpbuf, PSTR(" ")); /* we have at 
least room for one char */
                                debug_printf("   choice <%s>\n", tmpbuf);
                                /* does the completion match the beginning of 
the word ? */
                                if (!strncmp(incomplete_token, tmpbuf, 
incomplete_token_len)) {
@@ -374,10 +382,13 @@
                        (*state)++;
                        if (token && token->ops->get_help) {
                                token->ops->get_help(token, tmpbuf, 
sizeof(tmpbuf));
-                               snprintf(dst, size, "[%s]: %s", tmpbuf, 
inst->help_str?:"No help");
+                               if (inst->help_str)
+                                       snprintf_P(dst, size, PSTR("[%s]: %s"), 
tmpbuf, inst->help_str);
+                               else
+                                       snprintf_P(dst, size, PSTR("[%s]: No 
help"), tmpbuf);
                        }
                        else {
-                               snprintf(dst, size, "[RETURN]");
+                               snprintf_P(dst, size, PSTR("[RETURN]"));
                        }
                        return 1;
                }
@@ -385,7 +396,7 @@
                for (i=0 ; i<n ; i++) {
                        if (token->ops->complete_get_elt(token, i, tmpbuf, 
sizeof(tmpbuf)-1) < 0)
                                continue;
-                       strcat(tmpbuf, " "); /* we have at least room for one 
char */
+                       strcat_P(tmpbuf, PSTR(" ")); /* we have at least room 
for one char */
                        debug_printf("   choice <%s>\n", tmpbuf);
                        /* does the completion match the beginning of the word 
? */
                        if (!strncmp(incomplete_token, tmpbuf, 
incomplete_token_len)) {


==================================
aversive/modules/ihm/parse/parse.h  (1.1.2.5 -> 1.1.2.6)
==================================

@@ -1,3 +1,26 @@
+/*  
+ *  Copyright Droids Corporation (2007)
+ *  Olivier MATZ <[EMAIL PROTECTED]>
+ * 
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Revision : $Id: parse.h,v 1.1.2.6 2007-11-21 21:54:39 zer0 Exp $
+ *
+ *
+ */
+
 #ifndef _PARSE_H_
 #define _PARSE_H_
 
@@ -7,6 +30,7 @@
 #define offsetof(type, field)  ((size_t) &( ((type *)0)->field) )
 #endif
 
+#define PARSE_SUCCESS        0
 #define PARSE_AMBIGUOUS     -1
 #define PARSE_NOMATCH       -2
 #define PARSE_BAD_ARGS      -3
@@ -20,10 +44,15 @@
  * parsed chars on success and a negative value on error.
  *
  * complete_get_nb() returns the number of possible values for this
- * token if completion is possible.
+ * token if completion is possible. If it is NULL or if it returns 0, 
+ * no completion is possible.
+ *
+ * complete_get_elt() copy in dstbuf (the size is specified in the
+ * parameter) the i-th possible completion for this token.  returns 0
+ * on success or and a negative value on error.
  *
- * complete_get_elt() XXX
- * get_help() XXX
+ * get_help() fills the dstbuf with the help for the token. It returns
+ * -1 on error and 0 on success.
  */
 struct token_ops {
        /** parse(token ptr, buf, res pts) */
@@ -46,7 +75,9 @@
 };
 
 /**
- * XXX
+ * Store a instruction, which is a pointer to a callback function and
+ * its parameter that is called when the instruction is parsed, a help
+ * string, and a list of token composing this instruction.
  */
 struct inst {
        /* f(parsed_struct, data) */
@@ -56,15 +87,44 @@
        void * tokens[];
 };
 
+/**
+ * A context is identified by its name, and contains a list of
+ * instruction 
+ */
 struct ctx {
        char * name;
-       void * insts[];
+       struct inst * insts[];
 };
 
-
+/**
+ * Try to parse a buffer according to the specified context. The
+ * argument buf must ends with "\n\0". The function returns
+ * PARSE_AMBIGUOUS, PARSE_NOMATCH or PARSE_BAD_ARGS on error. Else it
+ * calls the associated function (defined in the context) and returns
+ * 0 (PARSE_SUCCESS).
+ */
 int8_t parse(struct ctx * ctx, const char * buf);
+
+/**
+ * complete() must be called with *state==0.
+ * It returns < 0 on error. 
+ *
+ * Else it returns:
+ * 2 on completion (one possible choice). In this case, the chars
+ *   are appended in dst buffer.
+ * 1 if there is several possible choices. In this case, you must 
+ *   call the function again, keeping the value of state intact.
+ * 0 when the iteration is finished. The dst is not valid for this 
+ *   last call.
+ *
+ * The returned dst buf ends with \0.
+ * 
+ */
 int8_t complete(struct ctx * ctx, const char *buf, int16_t *state, 
                char *dst, uint8_t size);
+
+
+/* true if(!c || iscomment(c) || isblank(c) || isendofline(c)) */
 int isendoftoken(char c);
 
 #endif /* _PARSE_H_ */


=========================================
aversive/modules/ihm/parse/parse_string.h  (1.1.2.4 -> 1.1.2.5)
=========================================

@@ -3,6 +3,7 @@
 
 #include "parse.h"
 
+/* size of a parsed string */
 #define STR_TOKEN_SIZE 32
 
 typedef char fixed_string_t[STR_TOKEN_SIZE];


====================================
aversive/modules/ihm/rdline/rdline.c  (1.1.2.5 -> 1.1.2.6)
====================================

@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: rdline.c,v 1.1.2.5 2007-11-15 11:15:46 zer0 Exp $
+ *  Revision : $Id: rdline.c,v 1.1.2.6 2007-11-21 21:54:39 zer0 Exp $
  *
  *
  */
@@ -105,7 +105,9 @@
 
 static uint8_t vt100_parser(struct rdline *rdl, char c);
 static int8_t match_command(char * buf, uint8_t size);
-static void rdline_printf(struct rdline * rdl, const char * fmt, ...);
+static void rdline_puts_P(struct rdline * rdl, const prog_char * buf);
+static void rdline_miniprintf_P(struct rdline * rdl, 
+                               const prog_char * buf, uint8_t val);
 
 #ifdef CONFIG_MODULE_RDLINE_HISTORY
 static void rdline_remove_old_history_item(struct rdline * rdl);
@@ -116,7 +118,7 @@
 
 void rdline_init(struct rdline * rdl, void (*write_char)(char),
                 void (*validate)(const char *, uint8_t size),
-                int8_t (*complete)(const char *, uint8_t size, char * dstbuf,
+                int8_t (*complete)(const char *, char * dstbuf,
                                    uint8_t dstsize, int16_t * state))
 {
        memset(rdl, 0, sizeof(*rdl));
@@ -185,13 +187,13 @@
        uint8_t i;
        char tmp;
 
-       rdline_printf(rdl, vt100_clear_right);
+       rdline_puts_P(rdl, PSTR(vt100_clear_right));
        if (!CIRBUF_IS_EMPTY(&rdl->right)) {
                CIRBUF_FOREACH(&rdl->right, i, tmp) {
                        rdl->write_char(tmp);
                }
-               rdline_printf(rdl, vt100_multi_left, 
-                            CIRBUF_GET_LEN(&rdl->right));
+               rdline_miniprintf_P(rdl, PSTR(vt100_multi_left), 
+                                   CIRBUF_GET_LEN(&rdl->right));
        }
 }
 
@@ -200,7 +202,7 @@
        uint8_t i;
        char tmp;
 
-       rdline_printf(rdl, vt100_home);
+       rdline_puts_P(rdl, PSTR(vt100_home));
        for (i=0 ; i<rdl->prompt_size ; i++)
                rdl->write_char(rdl->prompt[i]);
        CIRBUF_FOREACH(&rdl->left, i, tmp) {
@@ -236,7 +238,7 @@
                        tmp = cirbuf_get_tail(&rdl->left);
                        cirbuf_del_tail(&rdl->left);
                        cirbuf_add_head(&rdl->right, tmp);
-                       rdline_printf(rdl, vt100_left_arr);
+                       rdline_puts_P(rdl, PSTR(vt100_left_arr));
                        break;
 
                case KEY_CTRL_F:
@@ -246,21 +248,21 @@
                        tmp = cirbuf_get_head(&rdl->right);
                        cirbuf_del_head(&rdl->right);
                        cirbuf_add_tail(&rdl->left, tmp);
-                       rdline_printf(rdl, vt100_right_arr);
+                       rdline_puts_P(rdl, PSTR(vt100_right_arr));
                        break;
 
                case KEY_WLEFT:
                        while (! CIRBUF_IS_EMPTY(&rdl->left) && 
                               (tmp = cirbuf_get_tail(&rdl->left)) && 
                               isblank(tmp)) {
-                               rdline_printf(rdl, vt100_left_arr);
+                               rdline_puts_P(rdl, PSTR(vt100_left_arr));
                                cirbuf_del_tail(&rdl->left);
                                cirbuf_add_head(&rdl->right, tmp);
                        }
                        while (! CIRBUF_IS_EMPTY(&rdl->left) && 
                               (tmp = cirbuf_get_tail(&rdl->left)) && 
                               !isblank(tmp)) {
-                               rdline_printf(rdl, vt100_left_arr);
+                               rdline_puts_P(rdl, PSTR(vt100_left_arr));
                                cirbuf_del_tail(&rdl->left);
                                cirbuf_add_head(&rdl->right, tmp);
                        }                       
@@ -270,14 +272,14 @@
                        while (! CIRBUF_IS_EMPTY(&rdl->right) && 
                               (tmp = cirbuf_get_head(&rdl->right)) && 
                               isblank(tmp)) {
-                               rdline_printf(rdl, vt100_right_arr);
+                               rdline_puts_P(rdl, PSTR(vt100_right_arr));
                                cirbuf_del_head(&rdl->right);
                                cirbuf_add_tail(&rdl->left, tmp);
                        }
                        while (! CIRBUF_IS_EMPTY(&rdl->right) && 
                               (tmp = cirbuf_get_head(&rdl->right)) && 
                               !isblank(tmp)) {
-                               rdline_printf(rdl, vt100_right_arr);
+                               rdline_puts_P(rdl, PSTR(vt100_right_arr));
                                cirbuf_del_head(&rdl->right);
                                cirbuf_add_tail(&rdl->left, tmp);
                        }                       
@@ -285,18 +287,18 @@
 
                case KEY_BKSPACE:
                        if(!cirbuf_del_tail_safe(&rdl->left)) {
-                               rdline_printf(rdl, vt100_bs);
+                               rdline_puts_P(rdl, PSTR(vt100_bs));
                                display_right_buffer(rdl);
                        }
                        break;
 
                case KEY_META_BKSPACE:
                        while (! CIRBUF_IS_EMPTY(&rdl->left) && 
isblank(cirbuf_get_tail(&rdl->left))) {
-                               rdline_printf(rdl, vt100_bs);
+                               rdline_puts_P(rdl, PSTR(vt100_bs));
                                cirbuf_del_tail(&rdl->left);
                        }
                        while (! CIRBUF_IS_EMPTY(&rdl->left) && 
!isblank(cirbuf_get_tail(&rdl->left))) {
-                               rdline_printf(rdl, vt100_bs);
+                               rdline_puts_P(rdl, PSTR(vt100_bs));
                                cirbuf_del_tail(&rdl->left);
                        }
                        display_right_buffer(rdl);
@@ -317,8 +319,8 @@
                case KEY_CTRL_A:
                        if (CIRBUF_IS_EMPTY(&rdl->left))
                                break;
-                       rdline_printf(rdl, vt100_multi_left, 
-                                    CIRBUF_GET_LEN(&rdl->left));
+                       rdline_miniprintf_P(rdl, PSTR(vt100_multi_left), 
+                                           CIRBUF_GET_LEN(&rdl->left));
                        while (! CIRBUF_IS_EMPTY(&rdl->left)) {
                                tmp = cirbuf_get_tail(&rdl->left);
                                cirbuf_del_tail(&rdl->left);
@@ -329,8 +331,8 @@
                case KEY_CTRL_E:
                        if (CIRBUF_IS_EMPTY(&rdl->right))
                                break;
-                       rdline_printf(rdl, vt100_multi_right, 
-                                    CIRBUF_GET_LEN(&rdl->right));
+                       rdline_miniprintf_P(rdl, PSTR(vt100_multi_right), 
+                                           CIRBUF_GET_LEN(&rdl->right));
                        while (! CIRBUF_IS_EMPTY(&rdl->right)) {
                                tmp = cirbuf_get_head(&rdl->right);
                                cirbuf_del_head(&rdl->right);
@@ -343,7 +345,7 @@
                        cirbuf_get_buf_head(&rdl->right, rdl->kill_buf, 
RDLINE_BUF_SIZE);
                        rdl->kill_size = CIRBUF_GET_LEN(&rdl->right);
                        cirbuf_del_buf_head(&rdl->right, rdl->kill_size);
-                       rdline_printf(rdl, vt100_clear_right);
+                       rdline_puts_P(rdl, PSTR(vt100_clear_right));
                        break;
 
                case KEY_CTRL_Y:
@@ -360,7 +362,7 @@
 #endif /* CONFIG_MODULE_RDLINE_KILL_BUF */
 
                case KEY_CTRL_C:
-                       rdline_printf(rdl, "\r\n");
+                       rdline_puts_P(rdl, PSTR("\r\n"));
                        rdline_newline(rdl, rdl->prompt);
                        break;
 
@@ -393,12 +395,11 @@
                                 *  le buffer se termine par 0
                                 */
                                
-                               ret = rdl->complete(rdl->left_buf, 
CIRBUF_GET_LEN(&rdl->left)+2,
-                                                   tmp_buf, sizeof(tmp_buf), 
+                               ret = rdl->complete(rdl->left_buf, tmp_buf, 
sizeof(tmp_buf), 
                                                    &complete_state);
                                /* no completion or error */
                                if (ret <= 0) {
-                                       return 2; /* XXX ? why 2 ? I don't 
remember */
+                                       return 2;
                                }
 
                                
@@ -424,9 +425,8 @@
                                        for (i=0 ; tmp_buf[i] ; i++)
                                                rdl->write_char(tmp_buf[i]);
                                        rdl->write_char('\n');
-                                       ret = rdl->complete(rdl->left_buf, 
CIRBUF_GET_LEN(&rdl->left)+2,
-                                                           tmp_buf, 
sizeof(tmp_buf), 
-                                                           &complete_state);
+                                       ret = rdl->complete(rdl->left_buf, 
tmp_buf, 
+                                                           sizeof(tmp_buf), 
&complete_state);
                                }
 
                                rdline_redisplay(rdl);
@@ -437,7 +437,7 @@
                case KEY_RETURN2:
                        rdline_get_buffer(rdl);
                        rdl->status = RDLINE_INIT;
-                       rdline_printf(rdl, "\r\n");
+                       rdline_puts_P(rdl, PSTR("\r\n"));
 #ifdef CONFIG_MODULE_RDLINE_HISTORY
                        if (rdl->history_cur_line != -1)
                                rdline_remove_first_history_item(rdl);
@@ -470,7 +470,6 @@
                        break;
 
                case KEY_DOWN_ARR:
-
                        if (rdl->history_cur_line - 1 < 0)
                                break;
                        
@@ -490,7 +489,7 @@
 
                default:
                        break;
-                       }
+               }
 
                return 0;
        }
@@ -690,7 +689,12 @@
        uint8_t i = 0;
        
        for (i=0 ; i<sizeof(rdline_commands)/sizeof(const prog_char *) ; i++) {
+#ifdef HOST_VERSION
+               cmd = *(rdline_commands + i);
+#else
                cmd = (const prog_char *) pgm_read_word (rdline_commands + i);
+#endif
+
                if (size == strlen_P(cmd) &&
                    !strncmp_P(buf, cmd, strlen_P(cmd))) {
                        return i;
@@ -701,15 +705,56 @@
 }
 
 static void 
-rdline_printf(struct rdline * rdl, const char * fmt, ...)
+rdline_puts_P(struct rdline * rdl, const prog_char * buf)
 {
-       va_list ap;
-       char buf[16];
-       uint8_t n,i;
-
-       va_start(ap, fmt);
-       n=vsnprintf(buf, 16, fmt, ap);
-       for (i=0 ; i<n ; i++)
-               rdl->write_char(buf[i]);
-       va_end(ap);
+       char c;
+#ifdef HOST_VERSION
+       while ( (c = *(buf++)) != '\0' ) {
+               rdl->write_char(c);
+       }
+#else
+       while ( (c=pgm_read_byte(buf++)) != '\0' ) {
+               rdl->write_char(c);
+       }
+#endif
 }
+
+/* a very very basic printf with one arg and one format 'u' */
+static void 
+rdline_miniprintf_P(struct rdline * rdl, const prog_char * buf, uint8_t val)
+{
+       char c, started=0, div=100;
+
+#ifdef HOST_VERSION
+       while ( (c=*(buf++)) ) {
+#else
+       while ( (c=pgm_read_byte(buf++)) ) {
+#endif
+               if (c=='%') {
+#ifdef HOST_VERSION
+                       c = *(buf++);
+#else
+                       c = pgm_read_byte(buf++);
+#endif
+                       if (c=='u') { /* val is never more than 255 */
+                               while (div) {
+                                       c = val / div;
+                                       if (c || started) {
+                                               rdl->write_char(c+'0');
+                                               started = 1;
+                                       }
+                                       val %= div;
+                                       div /= 10;
+                               }
+                       }
+                       else {
+                               rdl->write_char('%');
+                               rdl->write_char(c);
+                       }
+               }
+               else {
+                       rdl->write_char(c);
+               }
+       }
+}
+


====================================
aversive/modules/ihm/rdline/rdline.h  (1.1.2.2 -> 1.1.2.3)
====================================

@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- *  Revision : $Id: rdline.h,v 1.1.2.2 2007-10-03 20:43:16 zer0 Exp $
+ *  Revision : $Id: rdline.h,v 1.1.2.3 2007-11-21 21:54:39 zer0 Exp $
  *
  *
  */
@@ -47,8 +47,6 @@
 
 /*
  * TODO : 
- * - history
- * - make it configurable (kill buff, history, line length)
  * - uint8_t -> int ?
  * - use cirbuf_for_each ? optimze ?
  */ 
@@ -107,18 +105,22 @@
        char prompt[RDLINE_PROMPT_SIZE];
        uint8_t prompt_size;
 
+#ifdef CONFIG_MODULE_RDLINE_KILL_BUF
        char kill_buf[RDLINE_BUF_SIZE];
        uint8_t kill_size;
+#endif
 
+#ifdef CONFIG_MODULE_RDLINE_HISTORY
        /* history */
        struct cirbuf history;
        char history_buf[RDLINE_HISTORY_BUF_SIZE];
        int8_t history_cur_line;
+#endif
 
        /* callbacks and func pointers */
        void (*write_char)(char);
        void (*validate)(const char *, uint8_t size);
-       int8_t (*complete)(const char *, uint8_t size, char * dstbuf, 
+       int8_t (*complete)(const char *, char * dstbuf, 
                           uint8_t dstsize, int16_t * state);
 
        /* vt100 parser */
@@ -139,7 +141,7 @@
  */
 void rdline_init(struct rdline * rdl, void (*write_char)(char),
                 void (*validate)(const char *, uint8_t size),
-                int8_t (*complete)(const char *, uint8_t size, char * dstbuf,
+                int8_t (*complete)(const char *, char * dstbuf,
                                    uint8_t dstsize, int16_t * state));
 
 
@@ -172,7 +174,7 @@
 /**
  * append a char to the readline buffer. 
  * Return 1 when the line has been validated.
- * Return 2 when the line has been completed.
+ * Return 2 when the asked to complete the buffer.
  * Return -1 if it is not running.
  * Return -2 if EOF (ctrl-d on an empty line).
  * Else return 0.
@@ -205,7 +207,7 @@
 void rdline_clear_history(struct rdline * rdl);
 
 /**
- *
+ * Get the i-th history item
  */
 char * rdline_get_history_item(struct rdline * rdl, uint8_t i);
 


========================================
aversive/modules/ihm/rdline/test/.config  (1.1.2.2 -> 1.1.2.3)
========================================

@@ -1,5 +1,5 @@
 #
-# Automatically generated make config: don't edit
+# Automatically generated by make menuconfig: don't edit
 #
 
 #
@@ -53,11 +53,11 @@
 #
 # Generation options
 #
-# CONFIG_OPTM_0 is not set
+CONFIG_OPTM_0=y
 # CONFIG_OPTM_1 is not set
 # CONFIG_OPTM_2 is not set
 # CONFIG_OPTM_3 is not set
-CONFIG_OPTM_S=y
+# CONFIG_OPTM_S is not set
 CONFIG_MATH_LIB=y
 # CONFIG_FDEVOPEN_COMPAT is not set
 # CONFIG_MINIMAL_PRINTF is not set
@@ -70,10 +70,6 @@
 #
 # Base modules
 #
-
-#
-# Enable math library in generation options to see all modules
-#
 CONFIG_MODULE_CIRBUF=y
 # CONFIG_MODULE_CIRBUF_LARGE is not set
 # CONFIG_MODULE_FIXED_POINT is not set
@@ -87,10 +83,6 @@
 #
 # Communication modules
 #
-
-#
-# uart needs circular buffer, mf2 client may need scheduler
-#
 CONFIG_MODULE_UART=y
 CONFIG_MODULE_UART_CREATE_CONFIG=y
 # CONFIG_MODULE_I2C is not set
@@ -122,6 +114,7 @@
 CONFIG_MODULE_RDLINE_CREATE_CONFIG=y
 CONFIG_MODULE_RDLINE_KILL_BUF=y
 CONFIG_MODULE_RDLINE_HISTORY=y
+# CONFIG_MODULE_PARSE is not set
 
 #
 # External devices modules
@@ -158,10 +151,6 @@
 # Control system modules
 #
 # CONFIG_MODULE_CONTROL_SYSTEM_MANAGER is not set
-
-#
-# Filters
-#
 # CONFIG_MODULE_PID is not set
 # CONFIG_MODULE_RAMP is not set
 # CONFIG_MODULE_QUADRAMP is not set
@@ -171,10 +160,6 @@
 #
 # Crypto modules
 #
-
-#
-# Crypto modules depend on utils module
-#
 # CONFIG_MODULE_AES is not set
 # CONFIG_MODULE_AES_CTR is not set
 # CONFIG_MODULE_MD5 is not set
@@ -184,20 +169,12 @@
 #
 # Encodings modules
 #
-
-#
-# Encoding modules depend on utils module
-#
 # CONFIG_MODULE_BASE64 is not set
 # CONFIG_MODULE_HAMMING is not set
 
 #
 # Debug modules
 #
-
-#
-# Debug modules depend on utils module
-#
 # CONFIG_MODULE_DIAGNOSTIC is not set
 # CONFIG_MODULE_DIAGNOSTIC_CREATE_CONFIG is not set
 CONFIG_MODULE_ERROR=y


Commit from zer0 (2007-11-21 22:54 CET)
================

enhance rdline and parse.
Use progmem in simple cases.

  aversive_projects  microb2008/main/.config  1.7


=========================================
aversive_projects/microb2008/main/.config  (1.6 -> 1.7)
=========================================

@@ -1,5 +1,5 @@
 #
-# Automatically generated by make menuconfig: don't edit
+# Automatically generated make config: don't edit
 #
 
 #
@@ -70,6 +70,10 @@
 #
 # Base modules
 #
+
+#
+# Enable math library in generation options to see all modules
+#
 CONFIG_MODULE_CIRBUF=y
 # CONFIG_MODULE_CIRBUF_LARGE is not set
 CONFIG_MODULE_FIXED_POINT=y
@@ -83,6 +87,10 @@
 #
 # Communication modules
 #
+
+#
+# uart needs circular buffer, mf2 client may need scheduler
+#
 CONFIG_MODULE_UART=y
 CONFIG_MODULE_UART_CREATE_CONFIG=y
 CONFIG_MODULE_I2C=y
@@ -151,6 +159,10 @@
 # Control system modules
 #
 CONFIG_MODULE_CONTROL_SYSTEM_MANAGER=y
+
+#
+# Filters
+#
 CONFIG_MODULE_PID=y
 # CONFIG_MODULE_RAMP is not set
 CONFIG_MODULE_QUADRAMP=y
@@ -160,6 +172,10 @@
 #
 # Crypto modules
 #
+
+#
+# Crypto modules depend on utils module
+#
 # CONFIG_MODULE_AES is not set
 # CONFIG_MODULE_AES_CTR is not set
 # CONFIG_MODULE_MD5 is not set
@@ -169,12 +185,20 @@
 #
 # Encodings modules
 #
+
+#
+# Encoding modules depend on utils module
+#
 # CONFIG_MODULE_BASE64 is not set
 # CONFIG_MODULE_HAMMING is not set
 
 #
 # Debug modules
 #
+
+#
+# Debug modules depend on utils module
+#
 # CONFIG_MODULE_DIAGNOSTIC is not set
 # CONFIG_MODULE_DIAGNOSTIC_CREATE_CONFIG is not set
 CONFIG_MODULE_ERROR=y

_______________________________________________
Avr-list mailing list
Avr-list@droids-corp.org
CVSWEB : http://cvsweb.droids-corp.org/cgi-bin/viewcvs.cgi/aversive
WIKI : http://wiki.droids-corp.org/index.php/Aversive
DOXYGEN : http://zer0.droids-corp.org/doxygen_aversive/html/
BUGZILLA : http://bugzilla.droids-corp.org
COMMIT LOGS : http://zer0.droids-corp.org/aversive_commitlog

Répondre à