Neutrino: A small Arduino command-line tool library for beginners(by a beginner)

Hi all,

I'm a Arduino beginner, happily uploaded my blinking sketch a couple weeks ago. After writing and uploading some experimenting sketches, I realised I need some extent of integration. So I wrote this small helper library, where I can bind a task function to a command name, and register it to the system. I then can call each task by sending its command name to Arduino via Serial (or via other means).

It's a trivial idea and trivial implementation, but I found it's triggering my imagination. After registering some simple tasks, I can then use these tasks as building blocks and do something more useful by combing them. So I'd like to share it here.

It's called "Neutrino" (named after a small, chargeless particle which is also a building block of the universe), and the Github page contains a very detailed introduction. Very birefly, it's as follows.

/* First, include and define a global Neutrino object. */
#include <Neutrino.h>

Neutrino neu = Neutrino(true);  // define a global task handler. "true" to automatically add a "_help" command.
// ... other codes


/* Second, define your task functions. Each task function should take no arguments and return an int8_t type variable as its exit code. */

int8_t led_control()
{
  // your codes to control some led
  return 0; // an exit code
}



/*Third, register each task you defined above to a command name. (Usually in "setup" function but not compulsory.) */

neu.add_command("led", led_control);  // Here the led_control function is bind to "led" command. */


/* Last, when you get some command stirng(possibly from Serial, sent by a user), you can parse it and run the corresponding task:

uint8_t retval = neu.parse_command(command); //Here "command" is a string variable.


/* To display the help information (a list of all commands available): */

neu.print_help_info();

When the bool variable in the constructor is set to "true", a command "_help" is automatically registered, which simply call "neu.print_help_info();" Therefore, when a user needs to recall the available command names, she/he can simply send a "_help" command.

There are more to come, of course, and I'll be happy if people find it interesting. Meanwhile, I'd also like to receive any suggestion or advice from experienced Arduino developers.

Cheers and happy coding! 8)

Thanks for sharing!

I appreciate that you've taken the time to provide some documentation. That gets skipped too often.

I think your installation instructions are unnecessarily complicated. They also assume the location of the sketchbook folder, which could be in different locations depending on OS and whether the user has configured the IDE to use a non-default folder. I suggest that you change them to use the Arduino IDE's Sketch > Include Library > Add .ZIP Library feature. Not only does that reduce the number of steps, it also ensures the library will be installed correctly. If that is something you're interested in, I'd be happy to submit a pull request for the change to the readme file.

Hi, thanks for your reply and comments! I agree that adding .zip is much simpler. I wrote that way only because I was used to that and didn't think much. Yes, I'd appreciate it to receive a pull request for this and any improvement! It always feels good to gain any support from the warm Arduino community! :slight_smile: