Announcement

Collapse
No announcement yet.

what can cause a ADDRESS TRAP ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • what can cause a ADDRESS TRAP ?

    hello,

    since a few weeks i'am implementing a program for the 4.3 DT display module.
    now i'am getting a ADRESS TRAP exception after downloading the program to the display.

    ADDRESS TRAP
    PC=2458
    SP=-3371
    UserHeap 24430
    SysHeap 11984


    I usually write code for web- and mobile apps and dont know much about those problems.
    the error occurs after one more line of code. it doesnt matter which specific line of code.

    at first it was a simple assignment of a global variable. but the address trap comes also after a print() command.

    any ideas what the reason can be ? i attached my .aux file. maybe it's helpful.

    best regards,
    Alex
    Attached Files
    Last edited by AlexBln; 28th May 2019, 02:53 PM.

  • #2
    Have you tried to increase your Stack Size?
    #STACK 4096

    Also, this can happen when your program is infinitely recursive or when you've set an invalid parameter.

    at first it was a simple assignment of a global variable. but the address trap comes also after a print() command.
    Perhaps you can give us a rundown of your program.

    Best Regards,
    Kevin

    Comment


    • #3
      hello kevin,

      thanks for the reply.
      i tried to increase the stack size to 4096, but it didnt resolve the problem.
      my program is for a 3d printer interface. i have multiple screens/forms, that send some commands via serial communication to receive the status data.

      at the beginning i had some problems with recursive behavior, but i think now i have adapted the code.

      the address trap appeared a few days ago..
      i just declared 3 or 4 global variables and have written an if else statement. in this if else statement are some assignments.
      if i remove the if/else statement, the code works again....
      Last edited by AlexBln; 28th May 2019, 05:35 PM.

      Comment


      • John Kevin
        John Kevin commented
        Editing a comment
        Could you add a snippet of your code so we can take a look?
        Last edited by John Kevin; 28th May 2019, 06:49 PM.

    • #4
      yes of course, i send you the complete code.

      if you delete the if else statement in filamentMenuWindow.fnc (line 40 - 70) the code works fine.
      Last edited by AlexBln; 6th June 2019, 05:33 PM.

      Comment


      • #5
        Hi,

        It seems that you are not calling the filamentMenuWindow() on any of your program, so it is weird that this is causing the address trap.

        On your "startForm.fnc" file you have a 'repeat forever' statement, although you have a 'break' command on the loop,
        I don't think that you need to run this 'if-condition' in a loop.
        Can you try to comment this ('repeat forever') out and run the program again?

        I have tried to do this and the address trap seems to disappear.
        I have not simulated your program entirely so I don't know if this is the only thing causing the issue.
        You may want to check and verify this.

        Best Regards,
        Kevin

        Comment


        • #6
          Hello Kevin,

          thank you for your help.

          I run the filamentMenuWindow(), when the user goes to the menu form and clicks on the 'filament button' (menuWindow.fnc --> line 99-103--> Entw01.visi --> line 81-83).
          I think i need to run the repeat/forever statement in the startForm.fnc, because i want to run the startRequest() until some conditions are true.

          if i comment out the complete startForm.fnc, i didnt get the address trap. but when i just comment out the repeat/forever and let the if/else there, i'am gettting the error.
          its seems no matter which file/func i comment out. the address trap disappers after a few lines of code less than before.
          it seems to be a problem with the quantity...
          Last edited by AlexBln; 29th May 2019, 07:42 PM.

          Comment


          • #7
            Hi,

            I run the filamentMenuWindow(), when the user goes to the menu form and clicks on the 'filament button' (menuWindow.fnc --> line 99-103--> Entw01.visi --> line 81-83).
            I haven't notice that until you point it out. Thank you.

            I think i need to run the repeat/forever statement in the startForm.fnc, because i want to run the startRequest() until some conditions are true.
            Actually, there are too many redirects on your program and keeping up on the process of what is running is really hard for me.

            if i comment out the complete startForm.fnc, i didnt get the address trap. but when i just comment out the repeat/forever and let the if/else there, i'am gettting the error.
            its seems no matter which file/func i comment out. the address trap disappers after a few lines of code less than before.
            it seems to be a problem with the quantity...
            I doubt that the quantity of the code is the problem. If I may suggest, can you try to cut the sub-process on your code? This may help us to further debug your program.
            Also, although the code on each form is separated by the .fnc file, the way you call it is actually redundant. If you can manage to handle it efficiently that would also help.

            Best Regards,
            Kevin

            Comment


            • #8
              Hey Kevin,

              thank you for the response.

              Actually, there are too many redirects on your program and keeping up on the process of what is running is really hard for me
              ... I believe you about that..sorry

              If I may suggest, can you try to cut the sub-process on your code? This may help us to further debug your program.
              Also, although the code on each form is separated by the .fnc file, the way you call it is actually redundant. If you can manage to handle it efficiently that would also help.
              ok, i will try it.
              but how can i "cut the sub-process" for debugging and why is the seperation in fnc. files reduandant. i just want to organize my code with that.

              Best regards ,
              Alex

              Comment


              • #9
                i think the address trap comes every time, when the program cant access some variables..
                i defined the "responsible" variables as global vars, but not at the very beginning of my programm.
                if i move them to the top, it works so far. i will test a bit and will get back to you.

                best regards,
                alex

                Comment


                • John Kevin
                  John Kevin commented
                  Editing a comment
                  Ok, let me know. Thanks

              • #10
                Hi Alex,
                but how can i "cut the sub-process" for debugging
                Perhaps, you can isolate each process (e.g. Serial comms) and if there are no errors/problems you can add the next process that your program wants to execute.

                Also, although the code on each form is separated by the .fnc file, the way you call it is actually redundant.
                What I mean by this is that you are inheriting the inherited file itself, please see the attached image. Although, I am not sure if this is
                causing the issue it is always a good coding practice to manage it properly.


                Best Regards,
                Kevin
                Attached Files

                Comment


                • #11
                  Hi Kevin,

                  ok thanks. i deleted the inherit lines...

                  Comment


                  • John Kevin
                    John Kevin commented
                    Editing a comment
                    Ok, keep me posted.

                • #12
                  Hello Kevin,

                  it worked for a few weeks now, but since 2-3 days i am getting ADDRESS TRAPS again.

                  When i implement just a little line of code , for example like the following:

                  Code:
                  if(globalVar == 1)
                  do something
                  endif
                  and then compile (without errors) and download the software to my display, the error appears immediatly.
                  it's strange because the error occurs indiscrimintely.

                  when i restart the display after this procedure, the software works...
                  so the trap just came after the download from the workshop IDE.

                  can you please help me ?
                  i can not go on like that

                  best regards,
                  Alex

                  Comment


                  • #13
                    Hi Alex,

                    Can you post here your updated program? so we can take a look.
                    I will try to conduct a test, and maybe I can find something to resolve the issue

                    Best Regards,
                    Kevin

                    Comment


                    • #14
                      Hi Kevin,

                      i think it i got the problem (maybe...).
                      if i use the str_Find() function to often, iam getting the error .

                      is there maybe an alternative function for that ?
                      i do this for example every second :



                      Code:
                      func coordinateIntefaces()
                      
                             pchSerialBuffer := str_Ptr(SerialBuffer);
                      
                              if(str_Find(&pchSerialBuffer, "PYOT-PAUSE-W") || str_Find(&pchSerialBuffer, "PYOT-STOP-W"))
                                  pyot_pause := 1;
                              else if(str_Find(&pchSerialBuffer, "PYOT-RESET-W"))
                                   pyot_reset := 1;
                                   sendFromWebinterface := 1;
                      
                              /*********************** Filament Basic Commands******************/
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-LOAD-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-LOAD-W";
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-UNLOAD-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-UNLOAD-W";
                              else if(str_Find(&pchSerialBuffer,"PYOT-FILAMENT-CHANGE1-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-CHANGE1-W";
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-CHANGE2-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-CHANGE2-W";
                      
                      
                              /*********************** Filament Repeat Commands******************/
                              else if(str_Find(&pchSerialBuffer,"PYOT-FILAMENT-CHANGE1-REPEAT-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-CHANGE1-REPEAT-W";
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-CHANGE2-REPEAT-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-CHANGE2-REPEAT-W";
                              else if(str_Find(&pchSerialBuffer,"PYOT-FILAMENT-LOAD-REPEAT-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-LOAD-REPEAT-W";
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-UNLOAD-REPEAT-W"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-UNLOAD-REPEAT-W";
                      
                             /*********************** Filament Quit Commands******************/
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-FINISH-W") && (currentForm == "filamentMenuWindow"))
                                   filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-FINISH-W";
                              else if(str_Find(&pchSerialBuffer, "PYOT-FILAMENT-CANCEL-W") && (currentForm == "filamentMenuWindow"))
                                  filamentMessage := 1;
                                   filamentMsg_Info := "PYOT-FILAMENT-CANCEL-W";
                              endif
                      
                            endfunc
                      if i disable the coordInterfce() method, the error disappears.
                      i also uploaded the complete software in the attachments
                      but without the address trap. if you write one more strFind method call , the error appears again.

                      best regards,
                      Alex
                      Attached Files
                      Last edited by AlexBln; 24th June 2019, 10:27 PM.

                      Comment


                      • #15
                        Hi Alex,

                        I am still trying to look for the possible cause of the issue.

                        i think it i got the problem (maybe...).
                        if i use the str_Find() function to often, iam getting the error .
                        The Address Trap seems to appear just by printing something on the main program so
                        I think this may have something to do with code size.

                        it seems to be a problem with the quantity...
                        This may be true in your case.
                        Have you tried to use a separate flashbank to store some of your code?
                        I think this forum thread may give you an idea on how to implement it:
                        https://forum.4dsystems.com.au/node/61777

                        If you want to to use an uSD card, this forum thread may help you.
                        https://forum.4dsystems.com.au/node/53017

                        Let me know if it helps.
                        Best Regards,
                        Kevin

                        Comment


                        • AlexBln
                          AlexBln commented
                          Editing a comment
                          "Have you tried to use a separate flashbank to store some of your code?"

                          I tried it now. i seperated a part of my program to flashbank 1. everytime i switch between the two flashbanks i`am getting error 29. because i use global variables in both flashbanks.

                          "If you want to to use an uSD card, this forum thread may help you."
                          i would like to do that. i seems to be the easiest way to keep my program running, but if i copy the .4XE file onto my sd card and write file_Run(".4XE",0) nothing happens..

                          what am i doing wrong ?
                          best regards
                          Alex
                      Working...
                      X