Problem with assigning values to large byte arrays [message #1780058] |
Tue, 16 January 2018 18:27  |
Eclipse User |
|
|
|
Hello,
I am trying to create a simple SIFB. The data output is a 32-byte(USINT) array. When I assign simple values to this array up to 24 bytes (through the loop or manually), everything works fine but as soon as I increase the index from 24, nothing happens. Forte does not crash but output event after the loop does not get fired as well.
Here is the simple code that I am trying but it does not work:
unsigned char i ;
for(i = 0; i < 32; i++)
bb()[i] = i;
sendOutputEvent(scm_nEventCNFID); //does not get fired when i > 24
Any help would be appreciated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Problem with assigning values to large byte arrays [message #1780916 is a reply to message #1780914] |
Mon, 29 January 2018 17:54   |
Eclipse User |
|
|
|
I'm currently traveling a lot and its hard form me to get access to a raspi. Maybe someone else can also perform some tests.
Regarding your event sending question. This strongly depends what kind of event you would like to send. If the event to sound is a result of an input event (e.g., INIT, REQ) then sendOutputEvent is the correct method. However if you write a resource initiated FB (aka Responder, e.g., simialr to a subscribe) and you would like to send an output event because of some non application event then a little bit more complicated process is needed.
The latter situation we call in 4diac external event (e.g., a message on the network arrived, an interrupt occurred). As these are somehow disturbances to the execution in 4diac they need to be treated with an external event handler (ie.., a class deriving from CExternalEventHandler). Typically you have one instance of such a class per external event source. From forte 1.9.0.M2 on you need to specially register such handlers in your CMakeList.txt. There are several examples for that.
In the interupthandling function of your external event handler you can determine which FB needs to be activated and hand over any data to the FB. However you must not call sendOutputEvent in this exeuction context. What you need to do is to invoke the method startNewEventChain provided by CExternalEventHandler and hand over a reference to your FB, which by the way needs to derive from CEventSourceFB. this will result that the special event "cg_nExternalEventID" will be sent to your FB in a thread capable of handling IEC 61499. in your FB's executeEvent you can check for this event perform any data post processing steps, apply the data to the FB's outputs and then invoke sendOutputEvent with the event to trigger.
I hope this helps.
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09184 seconds