Crea sito

The System Interface



The system interface in a "software shield" that hide the implementation of some generic functions the intepreter's business logic needs.
In this way not the AVIL interpreter can run in the same way on different hardware.
This was initially useful to debug AVIL on my PC and may be it will be useful in porting AVIL on other hardware platforms.

You can (if you ar brave enough) have a look at ../libraries/AVIL/sys.h, the header file that defines the interface functions.
The implementation of abovementioned functions are in ../libraries/AVIL/arduinoSys.cpp OR ../libraries/AVIL/pcSys.cpp (depending on what you set in the configuration file).

If you arrived arrived at this point you don't need big explanation to understand the meaning of this functions:

1 class Sys
2 {
3 public:
4 
5     //system initialization
6     bool static init();
7     //check if file exists
8     bool static fileExists(const char* fileName);
9     //get file line
10     bool static getFileLine(char* fileName, unsigned int lineNumber, char *line);
11 
12     //input from user
13     bool static userInput(char* dst, size_t size);
14     //output to user
15     void static userOutput(const char* msg);
16     #if SYSTEM == ARDU_UNO
17     void static userOutput(const __FlashStringHelper* msg);
18     #endif
19     void static userOutput(char c);
20     void static userOutput(int num);
21 
22 
23     //condition to stop a running program
24     bool static killSignalReceived();
25     //call to a custom function
26     bool static callFunc(const char* sysProgramName);
27     //check
28     bool static funcExists(const char* programName);
29     //runtime error
30     void static runtimeError(unsigned int errorCode, unsigned int programLine);
31 
32 private:
33 
34     Sys();
35 
36 };

But it could be useful for you to know that you can use the functions userOutput/userInput in your sketch to conveniently manage input/output (they are automatically redirected to/from serial or ethernet (depending on what you set in the configuration file).
To use these functions you must include the System Interfaca in your sketch like this:

1 #include <avil.h>
2 #include <sys.h>

Using these functions I easily created an interesting minimal "interactive shell".