FlockLab Tutorial 4: GPIO Actuation
Introduction
Learn how to use the GPIO actuation service.
The "GPIO echo" app
The "GPIO echo" app used in this tutorial is a TinyOS image that runs on Tmote Sky nodes. The app traces the 2 incoming GPIO pins SIG1 and SIG2 (which will be toggled during the FlockLab test) and synchronizes the state of the outgoing GPIO pins INT1 and INT2 by actuating them accordingly: if SIG1 is set/cleared, the app will also set/clear INT1. The same applies for the pair SIG2/INT2.
You can download the source code for apps, pre-compiled images and the test configurations for all tutorials from here. The app for this tutorial can be found in the folder 'flocklab_tinyos/apps/tutorials/4_GPIOActuation'
.
After having downloaded the source code, have a look at it. As you can see, the code uses the FlockLab sensorboard definitions (see tutorial 1 for further info). You can either compile the app yourself or use the pre-compiled image in 'build/telosb/main.exe'
.
The test configuration
Take now a look at the FlockLab configuration XML which can be found in 'FlockLab_Testconfiguration.xml'
. The overall test configuration is the same as in tutorial 2. As in tutorial 3, the target image is embedded directly into the test configuration XML with the only difference being that this is done automatically by the Makefile.
Since we want to exploit the GPIO actuation service in this tutorial, there needs to be at least one block '<gpioActuationConf>'
. Each of these blocks consists of the following elements:
-
'<obsIds>'
: A list of observers to which the configuration applies. -
'<pinConf>'
: Configuration for a GPIO pin which is to be actuated. There can be several of these blocks for several pins or multiple actuations of the same pin respectively. Every pin configuration consists of: -
'<pin>'
: Name of the GPIO pin to actuate. -
'<level>'
: Which level to set the GPIO pin to. FlockLab can set a pin to'high'
or'low'
or it can'toggle'
the level of a pin. -
'<relativeTime>'
or'absoluteTime'
: Timing information about when to actuate the pin. FlockLab can either time the actuation of a pin relative to the starting time of a test or as an absolute value in time (using UTC as time zone). Please consult the XML documentation for restrictions that apply. - For periodic pin actuations, the block
'<periodic>'
can be used. It contains the following elements: -
'<intervalMicrosecs>'
: The interval which is to be used for the periodic actuation in microseconds. -
'<count>'
: Defines, how many times the actuation should be carried out.
For this tutorial, we want to toggle GPIO pin 'SIG1'
50 times with an interval of 1 second and an offset of 5 seconds from the beginning of the test. GPIO pin 'SIG2'
is set, cleared and toggled infrequently at different times during the test.
Furthermore, we want to continuously trace the GPIO pins 'INT1'
and 'INT2'
to cross-check the GPIO actuations.
Running the test
You can run the test now. This is done the same way as in tutorial 3 by uploading the test configuration XML with the embedded target image directly to the FlockLab web interface.
Evaluating the test
As in all tutorials so far, you will get the test results by email and also over the web interface and WebDAV. In the archive, the files 'gpioactuation.csv'
and 'gpiotracing.csv'
are of interest to evaluate the test. You should be able to see all the actuations that were configured for the test in both the GPIO actuation and the GPIO tracing test results since the app synchronized SIG1/INT1 and SIG2/INT2 respectively. There might be a small time lag between the actuation and the tracing timestamps since the node needs some time to handle the interrupt generated by the actuated pin.
As in tutorial 2, you will also get GPIO traces for when the node was turned on/off (GPIO pin 'RST'
).
Deleting tests and images
As a last step in this tutorial, delete the test configuration (and thus the test results) and the corresponding target image. Please proceed according to tutorial 2.