Skip to content

NicolasNewman/ArgParse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArgParse

Argument parsing library for arduino.

The library functions by splitting a string in the format FUNC_NAME(ARG1,ARG2,...) into an Args struct containing:

struct Args
{
    unsigned int argc;
    char **argv;
};

Note that arguments are allocated on the heap and must be freed, either manually or with free_args(Args args).

Functions

Args parse_args(String cmd); // Parse a string in the form `FUNC_NAME(ARG1,ARG2,...)` into an `Args` struct
void free_args(Args args); // Free the arguments from a `Args`` struct

Example

String cmd = "SET_COLOR(0,255,0)";
Args args = parse_args(cmd); // argc=4, argv=["SET_COLOR", "0", "255", "0"]
for (int i = 0; i < args.argc; i++) {
    Serial.println(args.argv[i]);
}
free_args(args);

About

Argument parsing library for Arduino

Resources

License

Stars

Watchers

Forks

Packages

No packages published