2 Replies Latest reply on Jan 4, 2017 12:21 AM by user_1377889

    Command Storage




      I am writing a program that takes command strings off a UART bluetooth module (see attached). I have the parser working and initially thought I would only have a handful of commands. I am now finding out I will need many more commands.


      I have it setup currently in an inefficient manner, a way that make it difficult to add additional commands. I will be re-writing the main c program to scan an array of commands that I wish to define in the header.


      What is the best method to store a long list of character strings in a header so I do not have to use the #define specifier over and over, then redefine them in an array?



        • 1. Re: Command Storage

          To put it more simply, what I wish to do is create a lookup table of string commands that my main program will reference.


          What is the best method to do this? Is this typically done in a header?

          • 2. Re: Command Storage

            lookup table of string commands


            When I take this literally, I would create an array of strings which I could index and search for occurence of a given item.


            To shorten the needed code, I would extend the array of strings to an array of structs containing the address of the function that handles the command.