Version v1.2.0 (command setup and callbacks) by J-Rios · Pull Request #10 · J-Rios/minbasecli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
768174b
Command callback functions support
J-Rios Jul 9, 2022
6eaf080
Builtin help command function for added commands
J-Rios Jul 9, 2022
08e35db
Show help cmd description for custom/builtin help
J-Rios Jul 9, 2022
3df2a7e
Linux callbacks example added
J-Rios Jul 9, 2022
342171d
Arduino callbacks example added
J-Rios Jul 9, 2022
ff369d2
Windows callbacks example added
J-Rios Jul 9, 2022
53782a2
AVR callbacks example added
J-Rios Jul 9, 2022
fc3ca25
Arduino example callback remove exit command
J-Rios Jul 9, 2022
b7b8f37
CI build AVR callbacks example
J-Rios Jul 9, 2022
673fa70
Removed avr-uart-driver GIT submodule
J-Rios Jul 9, 2022
d8f4aee
AVR examples added avr-uart-driver library
J-Rios Jul 9, 2022
a584df1
Support default C++98 targets (remove C++11 used elements)
J-Rios Jul 9, 2022
affb874
Fix AVR examples to safe RAM memory and allows build for tiny targets
J-Rios Jul 9, 2022
bee0d5b
Fix Arduino callback example
J-Rios Jul 9, 2022
c3f53f5
ESPIDF callbacks example added
J-Rios Jul 9, 2022
5b70a8c
Set PIO examples minbasecli dependency version to v1.2.0
J-Rios Jul 9, 2022
6125c8c
Remove trailing spaces
J-Rios Jul 9, 2022
0cc3f9c
Merge pull request #6 from J-Rios/callbacks
J-Rios Jul 10, 2022
09a51bb
Arduino examples PSTR() to free RAM on AVR targets
J-Rios Jul 10, 2022
1110569
CI examples use local minbasecli version
J-Rios Jul 10, 2022
689c63b
CI enable jobs on development branch PR
J-Rios Jul 10, 2022
4fe37e1
Update PIO platforms to lastest stable versions
J-Rios Jul 10, 2022
e05ab33
Add PIO ESP32-C3 Arduino target
J-Rios Jul 10, 2022
ec98350
CI fix build next AVR and linux examples
J-Rios Jul 10, 2022
2e85fa6
CI fix build next AVR and linux examples
J-Rios Jul 10, 2022
2bf1842
Merge pull request #7 from J-Rios/ci-local-lib
J-Rios Jul 10, 2022
ff1ce43
GIT ignore build directory
J-Rios Mar 4, 2023
277ba89
CLI setup null default interface
J-Rios Mar 4, 2023
c424431
Show VSCode max characters per line ruler
J-Rios Mar 4, 2023
f6b37f7
Pointer to CLI in command callbacks
J-Rios Mar 4, 2023
bea18a5
Update examples for pointer to CLI command callbaks
J-Rios Mar 4, 2023
246d0ee
Merge pull request #8 from J-Rios/callbacks-this
J-Rios Mar 4, 2023
fd4c8e8
Specific HAL selector and config file
J-Rios Mar 4, 2023
7370da2
Removed unnecessary includes in HAL selector header
J-Rios Mar 4, 2023
7439e49
Fix Arduino example usage without progmem usage
J-Rios Mar 4, 2023
aa2f4b6
AVR example fix static declaration guard
J-Rios Mar 4, 2023
7f87353
Merge pull request #9 from J-Rios/memory-improvements
J-Rios Mar 4, 2023
346aafb
Update code style
J-Rios Mar 5, 2023
d390924
Updated README file
J-Rios Mar 5, 2023
9a4ba69
Update library version to v1.2.0
J-Rios Mar 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/build_avr.yml
8 changes: 7 additions & 1 deletion .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- development

jobs:
build_linux:
Expand All @@ -26,6 +27,11 @@ jobs:
sudo apt-get -y install cflow
- name: Build
run: |
cd examples/linux/basic_usage/build
cd examples/linux/
cd basic_usage/build/
make clean
make build
cd ../../
cd basic_usage_callbacks/build/
make clean
make build
15 changes: 8 additions & 7 deletions .github/workflows/build_pio_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ on:
pull_request:
branches:
- main
- development

jobs:
build_pio_arduino:

runs-on: ubuntu-latest
strategy:
matrix:
example: [examples/arduino/basic_usage/src/main.cpp]

steps:
- uses: actions/checkout@v2
- name: Cache pip
Expand All @@ -33,6 +30,10 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Run PlatformIO
run: pio ci --project-conf="examples/arduino/basic_usage/platformio.ini"
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}
run: |
pio run -c examples/arduino/platformio.ini \
-d examples/arduino/basic_usage \
-e arduino_uno_atmega328 -e arduino_esp32 -e arduino_esp8266
pio run -c examples/arduino/platformio.ini \
-d examples/arduino/basic_usage_callbacks \
-e arduino_uno_atmega328 -e arduino_esp32 -e arduino_esp8266
15 changes: 8 additions & 7 deletions .github/workflows/build_pio_espidf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ on:
pull_request:
branches:
- main
- development

jobs:
build_pio_espidf:

runs-on: ubuntu-latest
strategy:
matrix:
example: [examples/espidf/basic_usage/src/main.cpp]

steps:
- uses: actions/checkout@v2
- name: Cache pip
Expand All @@ -33,6 +30,10 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Run PlatformIO
run: pio ci --project-conf="examples/espidf/basic_usage/platformio.ini"
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}
run: |
pio run -c examples/espidf/platformio.ini \
-d examples/espidf/basic_usage \
-e espidf_esp32 -e espidf_esp32_c3
pio run -c examples/espidf/platformio.ini \
-d examples/espidf/basic_usage_callbacks \
-e espidf_esp32 -e espidf_esp32_c3
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
**/*.hex
**/memory_ram.txt
**/memory_program.txt

build/
src/main.cpp
src/main.c
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.rulers": [ 79 ]
}
79 changes: 52 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,63 @@ hal/newdev

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

2. Include new device support sources in "minbasecli.h" using an existing global define that allows to know wich 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):
2. 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):

```c++

/* ... */

/* Use Specific HAL for build system */

#if defined(__linux__)
#include "hal/linux/minbasecli_linux.h"
#define MINBASECLI_HAL MINBASECLI_LINUX
#elif defined(_WIN32) || defined(_WIN64)
#include "hal/windows/minbasecli_windows.h"
#define MINBASECLI_HAL MINBASECLI_WINDOWS
#elif defined(ARDUINO)
#include "hal/arduino/minbasecli_arduino.h"
#define MINBASECLI_HAL MINBASECLI_ARDUINO
#elif defined(__AVR)
#include "hal/avr/minbasecli_avr.h"
#define MINBASECLI_HAL MINBASECLI_AVR
#elif defined(ESP_PLATFORM)
#include "hal/espidf/minbasecli_espidf.h"
#define MINBASECLI_HAL MINBASECLI_ESPIDF
#elif defined(MY_NEW_DEV) // This has been include
#include "hal/newdev/minbasecli_newdev.h" // This has been include
#define MINBASECLI_HAL MINBASECLI_NEWDEV // This has been include
#else
#warning "minbasecli - Unsupported device/system."
#define HAL_NONE
#include "hal/none/minbasecli_none.h"
#define MINBASECLI_HAL MINBASECLI_NONE
#endif
/*****************************************************************************/

/* Hardware Abstraction Layer: NewDevice */

#elif defined(MY_NEW_DEV)

// Interface HAL Selection
#include "hal/newdev/minbasecli_newdev.h"
#define MINBASECLI_HAL MINBASECLI_NEWDEV

// Default CLI Baud Rate Speed to use if not provided
#if !defined(MINBASECLI_DEFAULT_BAUDS)
#define MINBASECLI_DEFAULT_BAUDS 115200
#endif

// Maximum CLI read buffer size
#if !defined(MINBASECLI_MAX_READ_SIZE)
#define MINBASECLI_MAX_READ_SIZE 64
#endif

// Maximum CLI Command length
#if !defined(MINBASECLI_MAX_CMD_LEN)
#define MINBASECLI_MAX_CMD_LEN 24
#endif

// Maximum CLI Command Argument length
#if !defined(MINBASECLI_MAX_ARGV_LEN)
#define MINBASECLI_MAX_ARGV_LEN 32
#endif

// Maximum number of arguments to check on a received CLI command
#if !defined(MINBASECLI_MAX_ARGV)
#define MINBASECLI_MAX_ARGV 4
#endif

// Maximum Print formatted number array size
#if !defined(MINBASECLI_MAX_PRINT_SIZE)
#define MINBASECLI_MAX_PRINT_SIZE 22
#endif

// Maximum number of commands that can be added to the CLI
#if !defined(MINBASECLI_MAX_CMD_TO_ADD)
#define MINBASECLI_MAX_CMD_TO_ADD 16
#endif

// Maximum length of command description text
#if !defined(MINBASECLI_MAX_CMD_DESCRIPTION)
#define MINBASECLI_MAX_CMD_DESCRIPTION 64
#endif

/*****************************************************************************/

/* ... */

Expand Down
24 changes: 16 additions & 8 deletions examples/arduino/basic_usage/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

[platformio]
default_envs = arduino_esp32 ; Build ESP32 with Arduino Framework
;default_envs = arduino_esp32_c3 ; Build ESP32-C3 with Arduino Framework
;default_envs = arduino_esp8266 ; Build ESP8266 with Arduino Framework
;default_envs = arduino_uno_atmega328 ; Build Arduino Uno with Arduino Framework
;default_envs = arduino_mega_atmega2560 ; Build Arduino Mega with Arduino Framework
Expand All @@ -19,51 +20,58 @@ default_envs = arduino_esp32 ; Build ESP32 with Arduino Framework
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[env]
lib_deps = minbasecli@1.1.1
lib_deps = minbasecli

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Arduino Build Configs

; ESP32 Arduino
[env:arduino_esp32]
platform = espressif32@3.5.0
platform = espressif32@5.0.0
board = esp32dev
framework = arduino

; ESP32-C3 Arduino
[env:arduino_esp32_c3]
platform = espressif32@5.0.0
board = esp32-c3-devkitm-1
framework = arduino
board_build.mcu = esp32c3

; ESP8266 Arduino
[env:arduino_esp8266]
platform = espressif8266@3.2.0
platform = espressif8266@4.0.1
board = esp12e
framework = arduino

; Arduino Uno (atmega328)
[env:arduino_uno_atmega328]
platform = atmelavr@3.3.0
platform = atmelavr@4.0.0
board = uno
framework = arduino

; Arduino Mega (atmega2560)
[env:arduino_mega_atmega2560]
platform = atmelavr@3.3.0
platform = atmelavr@4.0.0
board = megaatmega2560
framework = arduino

; Arduino Nano (atmega168)
[env:arduino_nano_atmega168]
platform = atmelavr@3.3.0
platform = atmelavr@4.0.0
board = nanoatmega168
framework = arduino

; Arduino Nano (atmega328)
[env:arduino_nano_atmega328]
platform = atmelavr@3.3.0
platform = atmelavr@4.0.0
board = nanoatmega328
framework = arduino

; Arduino Pro Micro (atmega32u4)
[env:arduino_micro_atmega32u4]
platform = atmelavr@3.3.0
platform = atmelavr@4.0.0
board = micro
framework = arduino
;build_flags = -DUSBCON=1
42 changes: 21 additions & 21 deletions examples/arduino/basic_usage/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @file examples/arduino/basic_usage/basic_usage.ino
* @file examples/arduino/basic_usage/src/main.cpp
* @author Jose Miguel Rios Rubio <jrios.github@gmail.com>
* @date 02-04-2022
* @version 1.0.1
* @date 05-03-2023
* @version 1.0.3
*
* @section DESCRIPTION
*
Expand Down Expand Up @@ -75,7 +75,7 @@ void setup()
Serial.begin(SERIAL_BAUDS);

// CLI init to use Serial as interface
Cli.setup(&Serial);
Cli.setup(&Serial, SERIAL_BAUDS);
Cli.printf("\nCommand Line Interface is ready\n\n");
}

Expand All @@ -84,58 +84,58 @@ void loop()
t_cli_result cli_read;

// If any command was received
if(Cli.manage(&cli_read))
if (Cli.manage(&cli_read))
{
// Show read result element
Cli.printf("Command received: %s\n", cli_read.cmd);
Cli.printf("Number of arguments: %d\n", (int)(cli_read.argc));
for(int i = 0; i < cli_read.argc; i++)
Cli.printf(" Argument %d: %s", i, cli_read.argv[i]);
Cli.printf("Number of arguments: %d\n"), (int)(cli_read.argc);
for (int i = 0; i < cli_read.argc; i++)
{ Cli.printf(" Argument %d: %s", i, cli_read.argv[i]); }
Cli.printf("\n");

// Handle Commands
if(strcmp(cli_read.cmd, "help") == 0)
if (strcmp(cli_read.cmd, "help") == 0)
{
Cli.printf("Available Commands:\n");
Cli.printf(" help - Current info.\n");
Cli.printf(" led [on/off] - Turn LED ON or OFF\n");
Cli.printf(" version - Shows current firmware version\n");
Cli.printf(" led [on/off] - Turn LED ON or OFF.\n");
Cli.printf(" version - Shows current firmware version.\n");
}
else if(strcmp(cli_read.cmd, "led") == 0)
else if (strcmp(cli_read.cmd, "led") == 0)
{
bool invalid_argv = false;
char* led_mode = NULL;

// Check for argument
if(cli_read.argc == 0)
invalid_argv = true;
if (cli_read.argc == 0)
{ invalid_argv = true; }
else
{
led_mode = cli_read.argv[0];
if(strcmp(led_mode, "on") == 0)
if (strcmp(led_mode, "on") == 0)
{
Cli.printf("Turning LED ON.\n");
digitalWrite(COMMAND_LED, HIGH);
}
else if(strcmp(led_mode, "off") == 0)
else if (strcmp(led_mode, "off") == 0)
{
Cli.printf("Turning LED OFF.\n");
digitalWrite(COMMAND_LED, LOW);
}
else
invalid_argv = true;
{ invalid_argv = true; }
}

if(invalid_argv)
Cli.printf("led command needs \"on\" or \"off\" arg.\n");
if (invalid_argv)
{ Cli.printf("led command needs \"on\" or \"off\" arg.\n"); }
}
else if(strcmp(cli_read.cmd, "version") == 0)
else if (strcmp(cli_read.cmd, "version") == 0)
{
Cli.printf("FW App Version: %s\n", FW_APP_VERSION);
}
// ...
else
Cli.printf("Unkown command.\n");
{ Cli.printf("Unkown command.\n"); }
Cli.printf("\n");
}
}
5 changes: 5 additions & 0 deletions examples/arduino/basic_usage_callbacks/.gitignore
Loading