Skip to content

Repository files navigation

MinBaseCLI

A minimal Command Line Interface C++ library implementation with HAL emphasis to be used in different kind of devices and frameworks.

Supported Devices & Frameworks

Current devices/frameworks supported:

  • Arduino
  • AVR
  • ESP-IDF
  • STM32
  • Linux
  • Windows

It's simply to add support to other devices and frameworks, check next sections.

Adding new Device Support

To add a new device/framework support to the library, you need to create a new Hardware Abstraction Layer component for it and implement the corresponding low level functions while maintain the same commons functions interface that minbasecli expose to be used...

  1. Create a directory and sources in hal directory for a new device support (lets use "newdev" name as example):
hal/newdev
hal/newdev/minbasecli_newdev.h
hal/newdev/minbasecli_newdev.cpp

Note: Use any of the other device support implementation of minbasecli_X.h/cpp files as example to edit.

  1. Include new device support sources in "minbasecli_hal_select.h" using an existing global define that allows to know which device/framework is being compiled (this define should exists in some way in device framework, otherwise, you need to pass it to the compiler at build time, i.e. using -DMY_NEW_DEV for gcc compiler):
/* ... *//*****************************************************************************//* Hardware Abstraction Layer: NewDevice */
#elif defined(MY_NEW_DEV)
// Interface HAL Selection
#include"hal/newdev/minbasecli_newdev.h"
#defineMINBASECLI_HALMINBASECLI_NEWDEV// Default CLI Baud Rate Speed to use if not provided
#if !defined(MINBASECLI_DEFAULT_BAUDS)
#defineMINBASECLI_DEFAULT_BAUDS115200
#endif// Maximum CLI read buffer size
#if !defined(MINBASECLI_MAX_READ_SIZE)
#defineMINBASECLI_MAX_READ_SIZE64
#endif// Maximum CLI Command length
#if !defined(MINBASECLI_MAX_CMD_LEN)
#defineMINBASECLI_MAX_CMD_LEN24
#endif// Maximum CLI Command Argument length
#if !defined(MINBASECLI_MAX_ARGV_LEN)
#defineMINBASECLI_MAX_ARGV_LEN32
#endif// Maximum number of arguments to check on a received CLI command
#if !defined(MINBASECLI_MAX_ARGV)
#defineMINBASECLI_MAX_ARGV4
#endif// Maximum Print formatted number array size
#if !defined(MINBASECLI_MAX_PRINT_SIZE)
#defineMINBASECLI_MAX_PRINT_SIZE22
#endif// Maximum number of commands that can be added to the CLI
#if !defined(MINBASECLI_MAX_CMD_TO_ADD)
#defineMINBASECLI_MAX_CMD_TO_ADD16
#endif// Maximum length of command description text
#if !defined(MINBASECLI_MAX_CMD_DESCRIPTION)
#defineMINBASECLI_MAX_CMD_DESCRIPTION64
#endif/*****************************************************************************//* ... */
  1. Implement low level layer functionalities to control interface of the CLI in the minbasecli_newdev.h/cpp files:
/* ... */boolMINBASECLI_NEWDEV::hal_setup(void* iface, constuint32_t baud_rate)
{
// Specific device/framework interface initialization// should be written here
}
size_tMINBASECLI_NEWDEV::hal_iface_available()
{
// Specific device/framework return num bytes received from interface// should be written here
}
uint8_tMINBASECLI_NEWDEV::hal_iface_read(void)
{
// Specific device/framework interface read and return incoming bytes// should be written here
}
voidMINBASECLI_ARDUINO::hal_iface_print(constuint8_t data_byte)
{
// Specific device/framework interface print text// should be written here
}
/* ... */

About

A minimal Command Line Interface C++ library implementation with HAL emphasis to be used in different kind of devices and frameworks.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages