Titan GPIO test port for Raspberry Pi [message #1752909] |
Mon, 30 January 2017 14:36 |
|
Dear all,
Titan was born in an industrial environment and one thing that is frequently associated with is complexity:
it is executed in complex setups (server clusters), it is capable to mimic convoluted traffic mixes and data flows over
intricate telecom networks; it also has a steep learning curve as it requires the knowledge of a domain specific language plus the
knowledge of the tool itself.
This complexity may appear scary sometimes. If someone worked with NBAP or RANAP signaling, knows exactly what I'm talking about: an average NBAP message may easily fill 40-50 A4 pages
in regular (10-12) size font if printed.
However this is not necessarily the case; one may start with simple test cases requiring basic test ports (UDP, HTTP)
and simple code and can acquire the feeling of "flow" , that is, of success and joy of accomplishment.
To ease this, and to permit our users to play with Titan, we have produced a build for Raspbian/Raspberry Pi.
In continuation of this idea, we have also published recently a GPIO test port for Raspberry Pi, available at the below links
git clone git://git.eclipse.org/gitroot/titan/titan.TestPorts.GPIO.git
git clone http://git.eclipse.org/gitroot/titan/titan.TestPorts.GPIO.git
The port can be used to set a logical low or high value to any of the 27 pins of the GPIO if set for output,
or else read logical values form any of the 27 pins if programmed for input.
An instance of a port corresponds to a pin; an array of ports can be used for convenience.
The GPIO is described in detail here:
https://www.raspberrypi.org/documentation/usage/gpio/
A piece of code to exemplify usage:
module GPIOTests {
import from GPIOPinPort all;
type component GPIO {
port GPIO_Pin_Port gpio27; //single port declaration
port GPIO_Pin_Port gpio[2..26]; //port array declaration
timer t_short;
}
testcase TC_GPIOPinTests_all_off() runs on GPIO {
log("Starting GPIO PIN port tests");
log("Mapping port");
//Map the port, this will export the gpio
map(self:gpio[11], system:gpio[11]);
map(self:gpio27, system:gpio27);
map(self:gpio[26], system:gpio[26]);
t_short.start(0.1);
t_short.timeout;
//Set direction on the gpio to OUT
var GPIO_PIN_DIRECTION gpio27_direction := OUT;
gpio27.send(gpio27_direction);
var GPIO_PIN_VALUE gpio27_value := HIGH;
gpio27.send(gpio27_value);
t_short.start(1.0); //send a pulse of 1 second duration ; if a lED is connected, it will flash shortly
t_short.timeout;
gpio27_value := LOW;
gpio27.send(gpio27_value);
log("Start waiting for signal to appear...");
var integer v_index;
var GPIO_PIN_DIRECTION gpio_direction := IN;
gpio[26].send(gpio_direction);
gpio[11].send(gpio_direction);
t_short.start(5.0);
alt {
[] gpio[26].receive {
setverdict(pass,"message received on port index 27");
}
[] any from gpio.receive -> @index value v_index {
setverdict(fail,"unexpected message received on port index: ",v_index);
}
[] t_short.timeout {
log("Timeout while waiting for input to change");
setverdict(inconc);
}
}
//Unmap the port, this will unexport the gpio
log("Unmapping ports");
t_short.start(1.0);
t_short.timeout;
unmap(self:gpio27, system:gpio27);
unmap(self:gpio[11], system:gpio[11]);
unmap(self:gpio[26], system:gpio[26]);
setverdict(pass);
}
control {
execute(TC_GPIOPinTests_all_off());
}
}
This code has been tested with LEDs and switches ( see picture),
but a similar code can be used to drive simple home automation circuits,
LEGO motors (with an appropriate driver which supports current etc. requirements), you name it; also, a language course exemplifying usage of TTCN-3 can be built around this setup. It's a low cost and simple alternative to get familiar with the language and with Titan.
Best regards
Elemer
[Updated on: Mon, 30 January 2017 15:42] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02452 seconds