Commit from zer0 on branch b_zer0 (2007-10-14 12:17 CEST)
=================================

start to use progmem

  aversive  modules/ihm/parse/parse_num.c      1.1.2.4
  aversive  modules/ihm/parse/test/.config     1.1.2.3
  aversive  modules/ihm/parse/test/commands.c  1.1.2.2
  aversive  modules/ihm/parse/test/main.c      1.1.2.5
  aversive  modules/ihm/rdline/rdline.c        1.1.2.4


======================================
aversive/modules/ihm/parse/parse_num.c  (1.1.2.3 -> 1.1.2.4)
======================================

@@ -338,7 +338,7 @@
                                *(int8_t *)res = (int8_t) res1;
                        return (buf-srcbuf);
                }
-               else if ( type == INT16 && res1 <= S16_MAX + 1 ) {
+               else if ( type == INT16 && res1 <= (uint16_t)S16_MAX + 1 ) {
                        if (res)
                                *(int16_t *)res = (int16_t) res1;
                        return (buf-srcbuf);


=======================================
aversive/modules/ihm/parse/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=y
+# CONFIG_OPTM_0 is not set
 # CONFIG_OPTM_1 is not set
 # CONFIG_OPTM_2 is not set
 # CONFIG_OPTM_3 is not set
-# CONFIG_OPTM_S is not set
+CONFIG_OPTM_S=y
 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
@@ -159,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
@@ -172,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
@@ -185,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
@@ -207,8 +183,8 @@
 #
 # Programmer options
 #
-CONFIG_AVRDUDE=y
-# CONFIG_AVARICE is not set
+# CONFIG_AVRDUDE is not set
+CONFIG_AVARICE=y
 
 #
 # Avrdude


==========================================
aversive/modules/ihm/parse/test/commands.c  (1.1.2.1 -> 1.1.2.2)
==========================================

@@ -20,7 +20,7 @@
 void cmd1_parsed(void * parsed_result, void * data)
 {
        struct cmd1_result * res = parsed_result;
-       printf("MATCH %s %s %d %s\n", res->arg0, res->arg1, res->arg2, 
res->arg3);
+       printf("MATCH %s %s %d %s\n", res->arg0, res->arg1, (int)res->arg2, 
res->arg3);
 }
 
 struct token_string cmd1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd1_result, 
arg0, "cmd1");
@@ -75,7 +75,7 @@
 {
        struct cmd3_result * res = parsed_result;
        
-       printf("MATCH %s %f\n", res->arg0, res->arg1);
+       printf("MATCH %s %f\n", res->arg0, (double)res->arg1);
 }
 
 struct token_string cmd3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd3_result, 
arg0, "toto#titi");


======================================
aversive/modules/ihm/parse/test/main.c  (1.1.2.4 -> 1.1.2.5)
======================================

@@ -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: main.c,v 1.1.2.4 2007-10-03 20:43:16 zer0 Exp $
+ *  Revision : $Id: main.c,v 1.1.2.5 2007-10-14 10:17:02 zer0 Exp $
  *
  *
  */
@@ -113,10 +113,10 @@
 {
 #ifdef HOST_VERSION
        struct termios oldterm, term;
-       char buf[127];
        int n, i;
        int8_t ret;
 #endif
+       char buf[127];
        int err;
        int16_t state=0;
 
@@ -151,15 +151,15 @@
        printf("\n");
        err = parse_num(&tok_num, "123", &result_num);
        if (err >= 0)
-               printf("Match : <%d> (consumed %d)\n", result_num.arg0, err);
+               printf("Match : <%d> (consumed %d)\n", (int)result_num.arg0, 
err);
        
        err = parse_num(&tok_num, "0x55", &result_num);
        if (err >= 0)
-               printf("Match : <%d> (consumed %d)\n", result_num.arg0, err);
+               printf("Match : <%d> (consumed %d)\n", (int)result_num.arg0, 
err);
        
        err = parse_num(&tok_num, "121321003115165 ", &result_num);
        if (err >= 0)
-               printf("Match : <%d> (consumed %d)\n", result_num.arg0, err);
+               printf("Match : <%d> (consumed %d)\n", (int)result_num.arg0, 
err);
        
        if (parse(&main_ctx, "toto 3.3\n"))
                printf("does not match... :'(\n");


====================================
aversive/modules/ihm/rdline/rdline.c  (1.1.2.3 -> 1.1.2.4)
====================================

@@ -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.3 2007-10-03 20:43:16 zer0 Exp $
+ *  Revision : $Id: rdline.c,v 1.1.2.4 2007-10-14 10:17:02 zer0 Exp $
  *
  *
  */
@@ -27,80 +27,79 @@
 #include <stdarg.h>
 #include <ctype.h>
 
+#include <aversive/pgmspace.h>
+
 #include <cirbuf.h>
 #include "rdline.h"
 
+static const prog_char cmd0[] = vt100_up_arr;
+static const prog_char cmd1[] = vt100_down_arr;
+static const prog_char cmd2[] = vt100_right_arr;
+static const prog_char cmd3[] = vt100_left_arr;
+static const prog_char cmd4[] = "\177";
+static const prog_char cmd5[] = "\n";
+static const prog_char cmd6[] = "\001";
+static const prog_char cmd7[] = "\005";
+static const prog_char cmd8[] = "\013";
+static const prog_char cmd9[] = "\031";
+static const prog_char cmd10[] = "\003";
+static const prog_char cmd11[] = "\006";
+static const prog_char cmd12[] = "\002";
+static const prog_char cmd13[] = vt100_suppr;
+static const prog_char cmd14[] = vt100_tab;
+static const prog_char cmd15[] = "\004";
+static const prog_char cmd16[] = "\014";
+static const prog_char cmd17[] = "\r";
+static const prog_char cmd18[] = "\033\177";
+static const prog_char cmd19[] = vt100_word_left;
+static const prog_char cmd20[] = vt100_word_right;
+static const prog_char cmd21[] = "?";
 
-
-static const char * rdline_commands[] = {
-       vt100_up_arr,
+static const prog_char * rdline_commands[] PROGMEM = {
+       cmd0,
 #define KEY_UP_ARR 0
-       
-       vt100_down_arr,
+       cmd1,
 #define KEY_DOWN_ARR 1
-
-       vt100_right_arr,
+       cmd2,
 #define KEY_RIGHT_ARR 2
-
-       vt100_left_arr,
+       cmd3,
 #define KEY_LEFT_ARR 3
-
-       "\177",
+       cmd4,
 #define KEY_BKSPACE 4
-
-       "\n",
+       cmd5,
 #define KEY_RETURN 5
-
-       "\001",
+       cmd6,
 #define KEY_CTRL_A 6
-
-       "\005",
+       cmd7,
 #define KEY_CTRL_E 7
-
-       "\013",
+       cmd8,
 #define KEY_CTRL_K 8
-
-       "\031",
+       cmd9,
 #define KEY_CTRL_Y 9
-
-       "\003",
+       cmd10,
 #define KEY_CTRL_C 10
-
-       "\006",
+       cmd11,
 #define KEY_CTRL_F 11
-
-       "\002",
+       cmd12,
 #define KEY_CTRL_B 12
-
-       vt100_suppr,
+       cmd13,
 #define KEY_SUPPR 13
-
-       vt100_tab,
+       cmd14,
 #define KEY_TAB 14
-
-       "\004",
+       cmd15,
 #define KEY_CTRL_D 15
-
-       "\014",
+       cmd16,
 #define KEY_CTRL_L 16
-
-       "\r",
+       cmd17,
 #define KEY_RETURN2 17
-
-       "\033\177",
+       cmd18,
 #define KEY_META_BKSPACE 18
-
-       vt100_word_left,
+       cmd19,
 #define KEY_WLEFT 19
-
-       vt100_word_right,
+       cmd20,
 #define KEY_WRIGHT 20
-
-       "?",
+       cmd21,
 #define KEY_HELP 21
-
-
-       NULL,
 };
 
 
@@ -216,7 +215,9 @@
        uint8_t n, i;
        int8_t cmd;
        char tmp;
+#ifdef CONFIG_MODULE_RDLINE_HISTORY
        char * buf;
+#endif
        
        if (rdl->status != RDLINE_RUNNING)
                return -1;
@@ -370,8 +371,6 @@
                case KEY_TAB:
                case KEY_HELP:
                        cirbuf_align_left(&rdl->left);
-                       //                      
rdl->left_buf[CIRBUF_GET_LEN(&rdl->left)] = '?'; /* XXX ? */
-                       //rdl->left_buf[CIRBUF_GET_LEN(&rdl->left)+1] = '\0';
                        rdl->left_buf[CIRBUF_GET_LEN(&rdl->left)] = '\0'; 
                        if (rdl->complete) {
                                char tmp_buf[127]; /* XXX */
@@ -687,17 +686,17 @@
 static int8_t
 match_command(char * buf, uint8_t size)
 {
-       const char ** cmd = rdline_commands;
+       const prog_char * cmd;
        uint8_t i = 0;
        
-       while(*cmd) {
-               if (size == strlen(*cmd) &&
-                   ! memcmp(buf, *cmd, size)) {
+       for (i=0 ; i<sizeof(rdline_commands)/sizeof(const prog_char *) ; i++) {
+               cmd = (const prog_char *) pgm_read_word (rdline_commands + i);
+               if (size == strlen_P(cmd) &&
+                   ! memcmp_P(buf, cmd, size)) {
                        return i;
                }
-               cmd ++;
-               i++;
        }
+
        return -1;
 }
 

_______________________________________________
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 à