[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Strings and structures in program memory

From: Trampas
Subject: [avr-gcc-list] Strings and structures in program memory
Date: Fri, 1 Dec 2006 11:43:06 -0500

I am trying to create a simple command processor and was trying to figure out how to get strings and even the commands structure to live and operate from program memory. Can anyone show me how to do this?


#define COMMAND(NAME, help)  { PSTR( #NAME ), NAME ## _cmd, PSTR( help ) }


//Command structure

struct Command


            PSTR name;

            int (*function) (int, char **);

            PSTR help;




int help_cmd(int, char **);

int exit_cmd(int, char **);


//List of supported commands

struct Command commands[] =


            {PSTR("help"), help_cmd, PSTR("help")}, //COMMAND (help, "Prints this message"),

            {PSTR("exit"), exit_cmd, PSTR("exit")},//COMMAND (exit, "Exits command mode"),          

            {PSTR(""),0,PSTR("")}, //End of list signal



Then to parse commands I was trying:


            //now let's parse the command




                        if (strcmp_P(buff,commands[i].name)==0)

                                    return (*commands[i].function)(numArgs,ptrArgv);




However this does not seem to work…






reply via email to

[Prev in Thread] Current Thread [Next in Thread]