Hardware Reference
In-Depth Information
an Ethernet server. The Process.h include is required when running processes
(or commands) on the Linux side. The Mailbox.h include is required when
using the mailbox interface system. The Console.h include is required when
simulating a console on the Linux side, and FileIO.h is required when read-
ing and writing i les to the micro-SD card and when reading i les from Linux.
To begin the Bridge library, use begin() :
Bridge.begin();
This function does not take any parameters and does not return any values.
It must be called in setup() and is a blocking function; it does not return until
the operation has i nished and stops the sketch until it has completed. It takes
roughly 3 seconds to initialize the Bridge system.
To exchange information between the two devices, a put/get system exists.
put() places data into a Python dictionary on Linino. It requires two elements: the
key and a value. The key is a name; the value can be numerical or text but is
stored in text format. Stored data may look like this:
username: john
age: 42
profession: programmer
highscore: 880
To place data on the Linux side, use put() :
Bridge.put(key, value);
This function requires two parameters: the key and the value and does not
return any data. This information is sent to the Atheros processor and placed
inside the Python dictionary. If the key does not exist, it is created, and the
contents of value are stored. If the key already exists, the contents of value are
stored and replace whatever was previously there. To fetch values stored in the
dictionary, use get() :
int result = Bridge.get(key, buffer, buffer_length);
This function takes three parameters: key is the text key to search for in the dic-
tionary; buffer is a char array that will be used to store the result; and buf-
fer_length is the size of buffer . This function returns an int , the amount of
bytes that have been placed into the buffer. If no data is available, this function
returns 0.
The Bridge class is a simple way to transfer data to and from the Linux side,
and includes features like error correction to ensure that data is always cor-
rectly transferred.
Process
The Process class runs and manages applications running on Linux. To begin
using the Process class, you must i rst create a Process object:
Process p;
 
Search WWH ::




Custom Search