CLI - Command Line Interface
Allows to transmit operational commands and change the configuration and behavior of the device using a PC with a Serial/COM (UART) connection.
The device is connected to the computer through the USB port. The computer recognizes it as a COM device and allows to initiate a connection with a terminal (CLI) such as Putty or the one that integrates PlatformIO in VS Code.
SERIAL_CLI macro in
conf-user.h allows to configure the CLI module.
#define SERIAL_CLI 0
Accepts 4 possible values
|-1||Disable CLI module|
|0||Enable CLI module on SERIAL_DEBUG|
|1||Enable CLI module on SERIAL_S1|
|2||Enable CLI module on SERIAL_S2|
SERIAL_CLI is equal to
0, so the CLI module is started on the debug port. Usually the debug port is connected to the USB port of the PCB. See the Serial Ports section for more info.
How to Use the CLI
Plese, follow this steps
- Connect a device with Rhomb.IoT to your computer (previously flashed).
- Open the Rhomb.IoT project with VS Code
- Open the serial terminal from the PlatformIO toolbar
- The Rhomb.IoT debug information should appear. Try pressing the Reset button on the PCB if nothing appears:
------------------------------------ RHOMB.IOT - The Modular IoT Firmware version 0.1.0 [I] 0 INIT timerisr ESP32 [I] 0 INIT device [I] 0 SET new device name: TEST [I] 0 INIT cmds [I] 0 MAIN ISR pin: 0 [I] 0 IO OUTPUT: 12 [I] 0 INIT Tempo [I] 0 LOAD SPIFFS [I] 0 Previus config loaded [I] 0 INIT sleep [I] 0 INIT Watchdog [I] 0 INIT Sensors [I] 0 vbat: 4184 [I] 0 vsys: 4944 [I] 0 vin: 3369 [I] 0 INIT Serial CLI [I] 0 SET OPMODE NORMAL
- Do not close the terminal, place the mouse over it and click so that the terminal window gets the focus
- Now type some characters and hit enter, for example "hello":
[...] [I] 0 vsys: 4944 [I] 0 vin: 3325 [I] 0 INIT Serial CLI [I] 0 SET OPMODE NORMAL [I] 2 LINE: hola
As seen at the end, pressing "enter" on the keyboard will display the line that has been entered. In this case the word "hola" doesn't represent anything, so Rhomb.IoT will simply ignore it.
Suppose we now build an operational command and send it to the terminal:
In the terminal we will see something similar to this:
[...] [I] 0 vsys: 4935 [I] 0 vin: 3325 [I] 0 INIT Serial CLI [I] 0 SET OPMODE NORMAL [I] 1 LINE: hola [I] 2 LINE: $123456789|8:60|4# [V] 2 COMMAND ID: 123456789 [V] 2 COMMAND PROPS: 8:60 [V] 2 COMMAND SIZE: 4 [V] 2 Size of command: 4 [V] 2 propValue: 8:60 [V] 2 prop: 8 [V] 2 value: 60 OK 123456789
We see that CLI has received the line (
[I] 2 LINE: $123456789|8:60|4#), then the command is parsed and the string
OK 123456789 is returned, indicating that the command has been processed correctly.
In case of sending an incorrect command, the final message would contain an error:
[I] 112 LINE: $123456789|8:60|2# [V] 112 COMMAND ID: 123456789 [V] 112 COMMAND PROPS: 8:60 [V] 112 COMMAND SIZE: 2 [V] 112 Size of command: 4 [V] 112 Command validation failed - invalid size ERROR 123456789
In the above example (
$123456789|8:60|2#) the number 2, the body size, is incorrect, it should be 4.