Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Titan GPIO test port for Raspberry Pi
Titan GPIO test port for Raspberry Pi [message #1752909] Mon, 30 January 2017 14:36 Go to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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),

index.php/fa/28266/0/

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

Re: Titan GPIO test port for Raspberry Pi [message #1752916 is a reply to message #1752909] Mon, 30 January 2017 16:06 Go to previous messageGo to next message
Gustavo Gonnet is currently offline Gustavo GonnetFriend
Messages: 36
Registered: October 2015
Location: Montreal, Quebec, Canada
Member
Hey, this is very very cool!
thank you for posting it.
Gustavo.
Re: Titan GPIO test port for Raspberry Pi [message #1752945 is a reply to message #1752916] Tue, 31 January 2017 07:37 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hey Gustavo,

long time no hear.
Thank you for the good words.

Best regards
Elemer
Re: Titan GPIO test port for Raspberry Pi [message #1752949 is a reply to message #1752909] Tue, 31 January 2017 08:19 Go to previous message
Lenard Nagy is currently offline Lenard NagyFriend
Messages: 54
Registered: September 2016
Member
Just to be on the safe side and spare You from failing: The latest officially released version of Titan does not compile this sample code. To compile it You will want to compile Your own Titan from source on the Raspberry. The next official release will contain the modification and will compile this code.
Previous Topic:How do test systems evolve on the long run?
Next Topic:Using the address type in Titan
Goto Forum:
  


Current Time: Thu Mar 28 18:02:03 GMT 2024

Powered by FUDForum. Page generated in 0.02452 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top