Command Storage

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
BeS__284136
Level 3
Level 3
5 sign-ins 10 replies posted 5 replies posted

Hello,

   

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?

   

Thanks

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

View solution in original post

0 Likes
2 Replies
BeS__284136
Level 3
Level 3
5 sign-ins 10 replies posted 5 replies posted

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?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

0 Likes