Attaching data with a timeout signal [message #1758244] |
Sat, 25 March 2017 14:19  |
Eclipse User |
|
|
|
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 #1758374 is a reply to message #1758352] |
Tue, 28 March 2017 03:53  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.07060 seconds