4.1 AVIL shell



AVIL shell is basically a sketch that receive the AVIL program's name you want to run interactively from the user, acting like a tiny "command shell".
It's an interesting way to get a standalone and programmable machine out of your Arduino.

This sketch make use of the system intarface as a convenient object to write output and get input regardless of the configurations.
Here's the sketch you have to use: ./AVIL_shell.ino

1 #include <avil.h>
2 #include <sys.h>
3 
4 
5 avil interpreter;
6 char cmd[30];
7 
8 void setup(void) {
9   if(!interpreter.init()){
10       Sys::userOutput(F("init error\n\r"));
11       while(1);
12   }
13   cmd[0]='\0';
14 }
15 
16 
17 void loop(void) {
18 
19   Sys::userOutput(F("\n\r>"));
20   //get a user input
21   if(Sys::userInput(cmd, 30)){
22       Sys::userOutput(F("\n\r"));
23       interpreter.run(cmd);
24   }
25   else{
26       Sys::userOutput(F("bad input!\n"));
27   }  
28 }

Run the sketch and connect via telnet (to do this you need to uncomment the directive #define ETH_IO in compopt.h, see Configurations):
Hit "Enter" and you'll be prompted to insert a program's name (you'll se an error but it's normal..it's generated because he's trying to execute an "empty" command) :

Hit "Enter" again to run the program:

Hit "ESC"+"Enter" to stop the program execution and you'll be prompted again:


Obviously you can do this also connecting via serial commenting the directive #define ETH_IO in compopt.h (see Configurations)

Remember that every time you connect via serial to an Arduino it will reset automatically!(here's a way to disable the auto reset)

To add functionalities to this tiny "shell" I created a collections of AVIL programs (you'll find them in the sd folder you find in the library itself) that simply wraps some of the basic calls available.
In this way you have, by default, this set of commands you can run from terminal:

You can use it from terminal with the same syntax, but you must pass them their argument explicitly (no variables)
So for example you can create a new file with:

And you can then append to it a couple of new lines by doing:

And finally print it with:

This lead to the last step of my development (for the moment) where i used AVIL to create a "standalone machine" remotely interfaced with a PC to: