Skip to content

devlabnet/YACL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

YACL Yet Another Command Line

A simple and most powerfull cmd parser.

This library is for handling commands over i.e. serial and short data transfers.

For handling show all examples.

Getting Started

To start using YACL, just include the library header and initialize the Command Line Engine "YACL_USE_YACLLIB" in your sketch file :

#include <yaclLib.h>
YACL_USE_YACLLIB;

Then Define the functions to call for each "command TOKEN"

//******************************
// Add your commands function code here
//------------------------------
void myCommandTest() {
    // Here the command code to run when receiving the "Test" token
    // .....
}

Then Add your commands "token" and related "function names"

//******************************
// Add your commands "token" and "function names" here
//------------------------------
YACL_CMDS_LIST myCommands[] = {
    {"Test", myCommandTest}
};
//******************************

Then init the command line in your setup() function and Check (as often as possible) for any commands from the serial in the loop() function

void setup() {
    Serial.begin(115200);
    // INIT THE COMMANDS
    YACL_INIT_CMDS(Serial, myCommands);
}

void loop() {
    // CHECK FOR COMMANDS AS OFTEN AS POSSIBLE
    YACL_CHECK_CMDS;
}

For a more complex exemple, look at the "Calculator" in the examples. All samples are heavily documented and should be self explanatory.

Predefined MACROS

To ease coding, some Predefined Macros are available:
  • Get Numeric Value (if no numeric is available or if not a well formatted, YACL_OK will return false):
    • YACL_GETINT: Return the next INT in the command Line
    • YACL_GETLONG: Return the next LONG in the command Line
    • YACL_GETFLOAT: Return the next FLOAT in the command Line
    • YACL_OK: Return false if expected number is not found or is not well formatted.
  • Get String Value:
    • YACL_GETSTR: Return the next STRING in the command Line
  • Print/Write:
    • YACL_PRINT(x): Print x value, this is the same as Serial.print(x)
    • YACL_PRINTLN(x): same as Serial.println(x)
    • YACL_PRINT2(x, y): Print x value in specific format, this is the same as Serial.print(x, FORMAT)
    • YACL_PRINTLN2(x, y): same as Serial.println(x, FORMAT)
    • YACL_WRITE(x): Writes binary data to the serial port
  • Last Token:
    • YACL_TOKEN: Return the last command line token found

About

YACL (Arduino) Yet Another Command Line

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages