Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Problem with assigning values to large byte arrays
Problem with assigning values to large byte arrays [message #1780058] Tue, 16 January 2018 23:27 Go to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
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 #1780073 is a reply to message #1780058] Wed, 17 January 2018 08:04 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
Hi,

this is really strange. Could you provide us with a very small FB (xml and cpp) which reproduces the problem so that I can run it through a debugger.
Re: Problem with assigning values to large byte arrays [message #1780137 is a reply to message #1780073] Wed, 17 January 2018 22:59 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
Attached are all the files. I created a new SIFB with default interfaces. I then changed the type of RD from ANY to USINT. Can this be the problem? newtest.h to follow in the next post.
Re: Problem with assigning values to large byte arrays [message #1780138 is a reply to message #1780137] Wed, 17 January 2018 23:01 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
newtest.h in the attachment
  • Attachment: newtest.h
    (Size: 2.56KB, Downloaded 17 times)
Re: Problem with assigning values to large byte arrays [message #1780226 is a reply to message #1780138] Thu, 18 January 2018 20:24 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
May i ask on which system you are testing? i just gave your code a try on windows using VS and cygwin and when running your FB with i 32 for both versions it worked totally normal.
Re: Problem with assigning values to large byte arrays [message #1780236 is a reply to message #1780226] Thu, 18 January 2018 22:47 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
I am testing it on a raspberry pi. 4DIAC is running on a CentOS VM and the raspberry pi is connected to it through ethernet.
Re: Problem with assigning values to large byte arrays [message #1780246 is a reply to message #1780236] Fri, 19 January 2018 08:03 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
could you run the forte on your raspi with gdb to check if there is any output there?
Re: Problem with assigning values to large byte arrays [message #1780378 is a reply to message #1780246] Mon, 22 January 2018 02:22 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
I have checked with print statements. Output array bb gets printed fine on the console but REQ and CNF events donot get fired when i > 24.

[Updated on: Mon, 22 January 2018 03:31]

Report message to a moderator

Re: Problem with assigning values to large byte arrays [message #1780400 is a reply to message #1780378] Mon, 22 January 2018 08:22 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
I'm sorry but printf is no gdb. The reason I aksed for gdb is that I strongly expect an exception in the thread where your fb is executed. As forte is running in your setup at least 4 to 5 threads even if one thread is throwing an exception the others will continue. Even things like monitoring or deploying new resources will work. I've seen that. So please just run forte with gdb so that we get maybe a stacktrace or more information what is wrong here. You don't need to debug with gdb just running:

gdb forte
r
Re: Problem with assigning values to large byte arrays [message #1780468 is a reply to message #1780400] Mon, 22 January 2018 22:41 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
I had already tried gdb on forte step by step debugging prior to using printf but couldn't figure out what was wrong as I have little knowledge of forte's code. Attached are two stacktrace files, one with a breakpoint set after the sendOutputEvent of my SIFB. The other is simple forte run without debugging. Please let me know if you need more information.

Regards
Re: Problem with assigning values to large byte arrays [message #1780750 is a reply to message #1780468] Fri, 26 January 2018 15:26 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
hm. Looks like a normal output. I guess I have to try it also directly on a raspi.
Re: Problem with assigning values to large byte arrays [message #1780914 is a reply to message #1780750] Mon, 29 January 2018 22:36 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
and meanwhile, can you also advise me the most relevant part of FORTE code that deals with updating the event counter and send output to 4DIAC? Although I have tried to go through the code especially sendOutputEvent() but couldn't find anything. I will look at it in-depth.
Re: Problem with assigning values to large byte arrays [message #1780916 is a reply to message #1780914] Mon, 29 January 2018 22:54 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
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.

Re: Problem with assigning values to large byte arrays [message #1780937 is a reply to message #1780916] Tue, 30 January 2018 08:10 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 76
Registered: February 2016
Member
Hi,

I just tested the fb you uploaded in a BeagleBone Black and had no problems. I used the last nightly version on 4DIAC and the last version of forte.

I deployed a newtest FB, monitored and triggered REQ manually. As in the attached picture, I can see that all values are written and a CNF event was triggered.

I'd recommend to recompile again forte with the exact fb files you uploaded here. I also tried with 4DIAC 1.8.4 and didn't have any problems, so I don't think it's a monitoring problem.

Can you upload a picture of the FB failing? Is there any way you can connect something to the CNF event so you could check that the event is actually not triggered?

Re: Problem with assigning values to large byte arrays [message #1780989 is a reply to message #1780937] Wed, 31 January 2018 03:21 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
Thanks Alois and Jose,

As Jose said, I tried connected CNF to another FB and IT WORKS!!! The values are just not displaying on the watched variables. :(

Thanks a lot.

I have one more issue if anyone can guide me. I am trying to send ULINT (8 bytes) of data from a publisher to a subscriber. The publisher sends the data alright and I can see through the tcpdump that the correct data is being received but subscriber FB's status string shows DATA_TYPE_ERROR hence nothing in RD (type of ANY). I have used forte's PUBLISH_1 and SUBSCRIBE_1 SIFBs. It happens whether I connect it to TYPE2TYPE FBs or not.
Re: Problem with assigning values to large byte arrays [message #1780998 is a reply to message #1780989] Wed, 31 January 2018 07:32 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 76
Registered: February 2016
Member
Good that we could narrow the cause of the problem. It seems now that it's on 4DIAC's monitoring. Can you tell us which version of 4DIAC and FORTE are you using when you get this issue?

Regarding your other issue, you have to make sure that your suscriber is also a ULINT(it should always be the same type of the publisher that's sending). So, you should connect some ULINT FB to the RD of your subscriber, like F_ULINT_TO_STRING (there isn't any ULINT2ULINT apparently).
Re: Problem with assigning values to large byte arrays [message #1781057 is a reply to message #1780998] Wed, 31 January 2018 22:26 Go to previous messageGo to next message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
Thanks for the reply. I am using 4DIAC-IDE version 1.8.4, build id: 2017-02-01_1155. I am not sure about forte version. forte -h does not show any version information but I guess I have 1.9.0.M1.
Re: Problem with assigning values to large byte arrays [message #1781077 is a reply to message #1781057] Thu, 01 February 2018 08:39 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 524
Registered: January 2014
Senior Member
I know that we had an issue when monitoring arrays. This has been fixed somewhere between M1 and now. May I ask that you take the latest development branch from git?

git clone http://git.eclipse.org/gitroot/4diac/org.eclipse.4diac.forte.git
cd org.eclipse.4diac.forte
git checkout develop
Re: Problem with assigning values to large byte arrays [message #1781867 is a reply to message #1781077] Wed, 14 February 2018 02:22 Go to previous message
Awais Tanveer is currently offline Awais TanveerFriend
Messages: 21
Registered: April 2016
Junior Member
Thanks. I will do that and let you know.
Previous Topic:Where to find source for older versions
Next Topic:Commentary Feature
Goto Forum:
  


Current Time: Sat May 26 02:39:59 GMT 2018

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

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

Back to the top