Stack overflow with really simple function

opineiro
2024-09-16
2024-09-23
  • opineiro - 2024-09-16

    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!

     
  • ph0010421 - 2024-09-17

    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.

     
  • opineiro - 2024-09-19

    Hi and thanks for your reply.
    Could you explain a little bit more what you mean?
    I think I'm not following you

     
  • TimvH

    TimvH - 2024-09-20

    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.

     
  • opineiro - 2024-09-23

    Thanks, I'm going to rework everything with this in mind.

     

Log in to post a comment.