Hi, I have an issue with a function which sends a message through API Rest. I'm using a function from httpCLient library.
I have tested this function inside a program and it works fine. But when I want to use it inside a function (so I can call it simultaneously from 2 different points on the main program) it gives a stack overflow error.
In detail it says: "C0297 Stack Overflow on Main Task. Stack sizes... Call hierarchy:"
I have simplified as much as I can the function, but I'm hitting a wall with this. Anybody has an idea of what's wrong?
Thanks!
Hello
I wouldn't call an FB from inside a FUN; it feels wrong to me.
I have had something similar. Try declaring the FB instances as GlobaVars rather than the instance memory.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have declared the function block in a function and call the instance also from a function. This is not correct, because a function is initialised with every call.
The http client function block should be declared as Global Variable if you want to cal it from a Function, but probably it is better to declare it in a Program and also call the instance of the http function block from the same Program.... The variables of a Program are not initialised with each call.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I have an issue with a function which sends a message through API Rest. I'm using a function from httpCLient library.
I have tested this function inside a program and it works fine. But when I want to use it inside a function (so I can call it simultaneously from 2 different points on the main program) it gives a stack overflow error.
In detail it says: "C0297 Stack Overflow on Main Task. Stack sizes... Call hierarchy:"
I have simplified as much as I can the function, but I'm hitting a wall with this. Anybody has an idea of what's wrong?
Thanks!
Hello
I wouldn't call an FB from inside a FUN; it feels wrong to me.
I have had something similar. Try declaring the FB instances as GlobaVars rather than the instance memory.
Hi and thanks for your reply.
Could you explain a little bit more what you mean?
I think I'm not following you
You have declared the function block in a function and call the instance also from a function. This is not correct, because a function is initialised with every call.
The http client function block should be declared as Global Variable if you want to cal it from a Function, but probably it is better to declare it in a Program and also call the instance of the http function block from the same Program.... The variables of a Program are not initialised with each call.
Thanks, I'm going to rework everything with this in mind.