Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Ignore any unsolicited message
Ignore any unsolicited message [message #1735748] Wed, 22 June 2016 12:01 Go to next message
murli sharma is currently offline murli sharmaFriend
Messages: 85
Registered: November 2015
Member
Hi,

I want to wait for a message from either port1 or port2 and if any message comes in any other port, it should be handled separately (in some altstep) and the function should wait for receiving the message from port1 or port2.

I have code similar to the following:
function receive_messages() {
    activate(default_altstep);  //handles all messages except from port1 or port2
    alt {
        port1.receive {}
        port2.receive {}
    }
    deactivate(default_altstep);
}


But in this code, if message other then what is expected in the alt is received the alt exits and the control goes to the default_altstep and then the function terminates.

I can't understand the problem with this code or any other approach.
Please help.

Thanks
Re: Ignore any unsolicited message [message #1735751 is a reply to message #1735748] Wed, 22 June 2016 12:37 Go to previous message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 759
Registered: January 2015
Senior Member
Hi Murli,

to achieve this, you need to restart the evaluation of alt by for example inserting it into a loop, as below:

function receive_messages() {
var boolean  v_loop:=true;   

activate(default_altstep);  //handles all messages except from port1 or port2

while (v_loop)
{
    alt {
        []port1.receive { 

		:
		v_loop:=false
   	}
        []port2.receive {

		:
		v_loop:=false
			}
    }//endalt
  
}//endwhile

  deactivate(default_altstep);

}//endfunction



while will be executed until you receive something on port 1 or 2; this will also break the loop by setting v_loop to false.


I hope this helps

Best regards
Elemer


Previous Topic:Is it possible to execute ttcn3 test cases via cli?
Next Topic:Advanced TTCN-3 usage: working with record of structures when performance matters
Goto Forum:
  


Current Time: Fri Jun 22 05:56:18 GMT 2018

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

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

Back to the top