制造商零件编号 A000073
ARDUINO UNO SMD R3 ATMEGA328
Arduino
License: Attribution Non-commercial Microcontrollers Software Terminals Arduino ESP32 ESP8266 Raspberry Pi MCU
The first step is to install the two necessary libraries using the Arduino IDE Library Manager. While manual installation is possible—especially in corporate
environments—the Library Manager provides a more convenient and streamlined approach.
Required libraries:
It is always recommended to use the latest available versions of these libraries to ensure compatibility and take advantage of the most recent features and bug fixes.
Among the examples provided by the Shellminator library, example 200 serves as an excellent starting point. Open this example and create a copy, as we will be using it as the foundation for our project. Before making any modifications, it is a good practice to compile and upload the code to your board to ensure everything is functioning correctly.
Once uploaded, you can connect to the serial port using a terminal emulator:
Set the baud rate to 115200 and open the connection. If everything is set up properly, resetting the board or pressing Ctrl + L should display the banner. Additionally, try entering the help command.
This command will list all available shortcuts and the built-in commands that the system currently supports.
As it stands, the default commands provided by the example are not particularly useful for our needs. To make the system more practical, let’s modify the cat command so that it performs a meaningful function. As an example, we can convert it into a command that prints the number of milliseconds elapsed since the system started.
To reflect this change, it makes sense to rename the command to millis. This requires a few modifications in the code:
At the top of the code, update the callback function prototype and rename the corresponding fields in the API_tree.
bool millis_func( char *args, CommandCaller* caller );
bool dog_func( char *args, CommandCaller* caller );
bool sum_func( char *args, CommandCaller* caller );
Commander::systemCommand_t API_tree[] = {
systemCommand( "millis", "Prints milliseconds since program start", millis_func ),
systemCommand( "dog", "Description for dog command.", dog_func ),
systemCommand( "sum", "This function sums two number from the argument list.", sum_func )
};
At the bottom of the code, rename the callback function and modify its implementation so that, instead of printing a text string, it outputs the result of the
Arduino millis() function.
bool millis_func(char *args, CommandCaller* caller ){
caller -> println( millis() );
return true;
}
With these changes, the command will provide real-time system uptime in milliseconds, making it a useful debugging tool.
If we test our modifications now, we should see that entering the millis command returns the current system uptime in milliseconds.
This demonstrates how an interactive terminal can provide real-time access to system data.
Consider how much more convenient this approach is compared to constantly printing debug messages via the Serial Monitor. Instead of cluttering the output with continuous logs, you can simply create query commands for the specific information you need. Then, you can request the data on demand, as many times as necessary, without modifying or restarting the system.
What we’ve covered so far is just a small glimpse of what the Shellminator and Commander-API libraries can offer. It's worth taking the time to go through the Shellminator documentation, as it is incredibly detailed, easy to follow, and filled with interactive examples to help you get started quickly.
Additionally, there is a quick introductory video on the topic that explains much more and can provide further insights into the capabilities of these libraries.
It's definitely worth watching.
Happy hacking! And if you create something truly impressive using these libraries, don't be shy—make sure to share it with the developers!