problem with exception

jbarrio
2017-12-20
2017-12-27
  • jbarrio - 2017-12-20

    hello:
    I have a problem, I am generating a library with its own blocks.
    If I use a function block that has a variable retain in my library, an exception is generated, when I use the block function in a program. What can be the cause?

    thanks

    IMG: Captura.PNG

    IMG: Captura.PNG

     
  • Ingo

    Ingo - 2017-12-20

    Difficult to say w/o knowing more about the code. But when you right click on the logger message to show the position of the exception, does CODESYS show you the position?

    Gesendet von meinem LG-H870 mit Tapatalk

     
  • jbarrio - 2017-12-21

    yes go to first FB in the program, is a problem with the system retain memory for raspberry for cmpapp, but I do not understand why it does not work.
    Copy code program and library in case you want to take a look.

    When it restarts after a power outage, it starts in exception.
    thanks

    prueba_proyecto.project [130.34 KiB]

    bibli_prueba.library [85.3 KiB]

     
  • Ingo

    Ingo - 2017-12-21

    I tried to reproduce your problem, but sadly without success. I had SP11 with an RPI Zero W running here, so I tried it with that. What I noticed in your project was, that you placed the whole "persistent FB" into a "retain persistent" variable list.

    This seems to be bad, as your FB itself defines already retains. So, your Persistent variables list says "persistent!" and your FB says "retains!". If this doesn't only confuse me, but also the compiler, I could imagine that it leads to side effects.

    Your first approach looks cleaner to me. So that you declare the basic variables within your FB as "retain". FBs are consisting of code and data. So placing a whole instance of an FB in a retain area is IMHO bad practice. I prefer to define as few variables as retain as possible.

     
  • jbarrio - 2017-12-21

    good and many thanks for the help.
    I have removed the general persistent list, but I continue with the problem.
    Charge well the first time, but as soon as I save variables and remove the light, it restarts in exception in the first FB of the program.
    I use sp 11 patch 4.
    The reason for using the whole block to be retained is because after a complete program load the variables are not maintained if they are not declared in that area

    IMG: Captura.PNG

     
  • jbarrio - 2017-12-22

    Good:
    I've been doing tests with the subject.
    As a conclusion, if there is an FB within another FB and in either of the two there are persistent variables, failure, with functions (other than FB) does not happen.

     
  • jbarrio - 2017-12-27

    I continue with the problems ...
    I really did not expect to have so many problems with this.

    someone knows why a function that is in an FB does not have internal values ​​come out "???" and that you need a break point.
    Some functions, if they work well inside FB but others do not ... (the timer almost none)

    Or I do not understand well how to do it or it can not be done.

     
  • Ingo

    Ingo - 2017-12-27

    Yeah, that's a general concept issue. w/o a breakpoint CODESYS can only monitor "global data". For example variables in GVLs, FB instance variables, etc...
    All data in functions and methods are only allocated while the function is executed.

    Gesendet von meinem LG-H870 mit Tapatalk

     
  • jbarrio - 2017-12-27

    finally, even if I do not like the solution, I have chosen not to use blocks for later programs, but to create programs with a module that writes all the persistent variables to others. In this way, it seems that everything works correctly, in case it is worth someone to help.

     

Log in to post a comment.