Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Attaching data with a timeout signal
Attaching data with a timeout signal [message #1758244] Sat, 25 March 2017 18:19 Go to next message
John Dawes is currently offline John DawesFriend
Messages: 19
Registered: November 2016
Junior Member
Hi,

Is it possible to attach data with a timeout signal? I tried the following to set the timer and tried to access it using *rtdata. It did not work.

int i=5;
UMLRTTimespec t1(2,0);
timer.informIn(t1, &i, &UMLRTType_int);




John
Re: Attaching data with a timeout signal [message #1758292 is a reply to message #1758244] Mon, 27 March 2017 08:49 Go to previous messageGo to next message
Peter Cigehn is currently offline Peter CigehnFriend
Messages: 49
Registered: September 2014
Member
Hi,

I am not fully sure what it is that did not work. I guess is that since *rtdata is a void pointer, you need to explicitly cast to an int pointer yourself, if that is what you meant did not work.

*(int *)rtdata


I have attached an small example model which demonstrates how this works.

Hope this helps,

/Peter Cigéhn
Re: Attaching data with a timeout signal [message #1758342 is a reply to message #1758292] Mon, 27 March 2017 20:16 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Yes, I can confirm that Peter's cast works.

For "normal" protocol messages, i.e. messages from user-defined protocols, the code generator will look at its parameters, and try to infer the type to use when declaring the rtdata macro in the generated code, but (at least currently) it does not do that for Timing messages, so in this case rtdata always gets typed as void * and therefore you need to cast it to the appropriate type.

Re: Attaching data with a timeout signal [message #1758352 is a reply to message #1758342] Tue, 28 March 2017 02:20 Go to previous messageGo to next message
John Dawes is currently offline John DawesFriend
Messages: 19
Registered: November 2016
Junior Member

Thank you very much guys. It worked.


Re: Attaching data with a timeout signal [message #1758374 is a reply to message #1758352] Tue, 28 March 2017 07:53 Go to previous message
Peter Cigehn is currently offline Peter CigehnFriend
Messages: 49
Registered: September 2014
Member
Hi again,

Regarding the need for an explicit type cast in this specific case is, as Ernesto tries to explain, that the timeout protocol message can be seen as being defined with a single parameter typed by *, i.e. it can carry any data. Hence the reason why you in this specific case needed to pass along the type descriptor that it actually is an 'int' that is being sent.

So at code-generation time there is no way for the code generator to know which type is going to be sent at run-time. So the only viable solution is to provide a void pointer via rtdata.

This is the same also for user defined protocols, where you define the protocol message parameter to be typed by *, which makes it possible to pass along any type of data, including none at all. Also for those cases, rtdata will be a void pointer.

For any other case, rtdata will be typed according to the type of the (first) parameter of the protocol message. Then there should be no need for an explicit type case, since the type information already exist at code generation time (and hence type safe sends are achieved).

/Peter Cigéhn
Previous Topic:Papyrus-rt gets stock
Next Topic:How to use deep history in Papyrus-RT
Goto Forum:
  


Current Time: Fri Dec 06 17:22:00 GMT 2024

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

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

Back to the top