Announcement

Collapse
No announcement yet.

File_Exec

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

  • File_Exec

    I have finally got around to branching my code off into smaller portions so that I can have it all running at once, and I was planning on using the File_Exec function to help with this. However this function seems to have problems when calling files above a certain size (or from a project of a certain size).

    Basically, if I exec a .4FN / .4XE file that is approx 340bytes or larger, the arguments get corrupted and sometimes the function will not run at all. Similarly if I execute from a large program issues occur.

    I have provided some basic code which allows you to see the failure

    ExecTest.4dg
    Code:
    #platform "uOLED-32028-P1T"#constant TRUE 1#constant FALSE 0var l_abArgList[5];func main()var r;gfx_Cls();print("Calling remote app\nw/ Args\n");pause(1000);l_abArgList[0] := 4;l_abArgList[1] := 30;l_abArgList[2] := 70;l_abArgList[3] := 500;l_abArgList[4] := 1000;r := file_Exec("Test.4FN", l_abArgList);print("\n\nReturned ", r, "\n");repeat forever;endfunc
    ExecFunc.4dg

    Code:
    #platform "uOLED-32028-P1T"#STACK 40#constant TRUE 1#constant FALSE 0#DATAbyte lotsOfData "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"byte lotsOfData2 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"#ENDfunc main(var a, var b, var c, var d)var r;print("\n\n\nRemote function:\n");print("Args: ", a, " ", b, " ", c, " ", d, "\n");pause(5000);return 42;endfunc//Save this file as TEST.4FN
    Basically this works if you comment out the data elements lotsOfData & lotsOfData2, but fails if you don't.


    Any suggestions / fixes / status updates on this?


    Thanks,

    Drew Cheeseman
    Senior Firmware Engineer
    Rad Torque
    http://www.radtorque.com/

  • #2


    Could it be that you're sending 5 args to a function with 4 arg inputs?

    I haven't tried any of this.. ever..  but it "could" be a problem.. I dunno!! ;-)



    Andy
    MicroLec Industries P/L
    www.intelligym.com.au

    Comment


    • #3


      From the documentation, the first argument is the number of subsequent arguments present. I'm pretty sure that is the correct way to call it as it works (with correct values) when you comment out the #data elements, also the array is just passed as a pointer and so the size of it should not matter.

      Thanks though


      Drew
      Senior Firmware Engineer
      Rad Torque
      http://www.radtorque.com/

      Comment


      • #4


        ha ha.. well there you go..  I should have done some reading first hey ;-)

        Goodluck with it. I am sure I will hit this issue soon myself.

        Andy
        MicroLec Industries P/L
        www.intelligym.com.au

        Comment


        • #5


          Hi,

          I have also some issues with the function file_Exec(), but my arguments values are not corrupted.
          (http://4d.websitetoolbox.com/post?id=3649991)

          My question is: where did you finc information about the command #STACK ???
          I checked and I didn't find it in the 4DLG documentation !

          I modified my sample code from my post above and I saw that I also need to use #STACK 100 to make my called function returns to the caller program....

          Any update ?

          Comment


          • #6


            I haven't seen any information about #STACK, i just found it in a few examples, so included it on the off-chance it would help

            I have just (20 mins ago) posted a contact message to 4D Systems, so hopefully will hear back shortly.

            For your issue, it looks like there may be seperate 'user' areas of RAM which aren't mapped across, I am not sure though, would be interesting to see how that works (I resorted to saving all my arguments to a file on an SD card and reloading them in the called application - but I was still having issues with larger functions)
            Senior Firmware Engineer
            Rad Torque
            http://www.radtorque.com/

            Comment


            • #7


              Thanks for your reply.

              I also think that memory spaces are separated, like one stack per program. It could explain why the static array solution does not work, but I'm surprised about the heap memory allocation which does not work also ! Maybe the allocation is done in the "stack". I hope there is a solution !
              I also thought about a file to share variables, but it is clearly the "last chance" exotic solution.

              Comment


              • #8


                We will check these issues, and if there is problem they will be rectified in the new PmmC release which should be available within 3-4 weeks. One thing to remember is that ALL resources are shared in the 12k memory space, so any programs thet are 'executed' will be loaded above the main program, sharing the memory space. Also, the parameters passed to the executed function are copied to the new preocesses stack so the calling programs stack and variables are out of scope while the sub function is executing.
                Regards,
                Dave

                Comment


                • #9


                  got problems with this also..

                  I have 4 main 4XE files, and a simple loader to monitor the return value from each of the 4xe files.  basically when I load any of the 4xe's into ram they run, when I load the loader (mini OS) into flash it tries to load one of the programs using file_Exec("Prog1.4xe",0) and all I get is a blank screen, so obviously no way to monitor the return value from there on...

                  I'm not using any "stack" calls as there's minimal documentation to support it.  INcidently, I was switching from 4XE to 4XE using file_Run(), but found out today that is a bad idea... This doesn't work however so I might have to go back to swapping between 4XE's using file run.

                  Looking for a fix as soon as you can..  I will post some sample code if need be..




                  Thanks
                  Andy
                  MicroLec Industries P/L
                  www.intelligym.com.au

                  Comment

                  Working...
                  X