Announcement

Collapse
No announcement yet.

Run RunFlash.4xe from Arduino code.

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

  • Run RunFlash.4xe from Arduino code.

    I do not have the 4D programming cable, but it would seem that if I am not running anything from flash, then I don't need it. I would like to create a few gauges and control them from the arduino. I believe I can write the .gfi, .dat, and RunFlash.4xe to the SD card and then get the gauges to boot and then interface with them via serial commands. But I can't find any examples of this.

    Perhaps file_run(RunFlash.4xe) is the command that I need to call. Any advice on how to do this?

  • #2
    Hi,

    Welcome to the forum!


    Yes, you could simply copy the .gci, .dat, and the .4xe files to the SD card.

    All you need are, just run the child program (.4xe file) by utilizing the file_run(..) function as you have mentioned.
    But, you would need to mount the SD card first by utilizing the file_mount(..) function on the
    Arduino code as shown below:


    This is a snippet Arduino Sketch:
    Code:
    void setup() {                                          // run once
    
    //.........
    
    //uSD card mount routine
      Display.putstr("Mounting...\n");                         //print a string
      if(!(disk = Display.file_Mount()))
      {
        while(!(disk = Display.file_Mount()))
        {
          Display.putstr("Drive not mounted...");
          delay(200);
          Display.gfx_Cls();
          delay(200);
          
        }
      }
    Display.file_Run("RunFlash.4XE",0,0);             //will run the child program on the SD card.
    }

    If you have questions, please don't hesitate to ask.

    Best regards,
    Kayven

    Comment


    • #3
      Thanks Kayven,

      I got it working just before you posted doing pretty much what you are suggesting. Although it took me an hour to realize that I could keep the software from blacking out/restarting by adding a delay(4000) between mount() and file_Run().

      My next confusion seems to be that I need the Genie library to talk to my widgets which also needs the serial port with:

      Code:
        Serial.begin(200000);
        genie.Begin(Serial);
      So I've got SoftwareSerial writing errors, DisplaySerial on pins 10 & 11 writing Picaso functions, and now I need genie using another serial port. I'm not sure how this can work, but I'll keep plugging away at it.
      Last edited by zepperik; 20th September 2018, 11:58 PM.

      Comment


      • #4
        Wasn't as tricky as I thought:

        Code:
        #include <SoftwareSerial.h>
        SoftwareSerial DisplaySerial(10,11) ;
        
        ....
        
        Setup()
        {
          DisplaySerial.begin(9600) ;
          Display.TimeLimit4D   = 5000 ; // 5 second timeout on all commands
          genie.Begin(DisplaySerial);  //Serial0  
        }
        This is my first arduino project, kind of cool how easily the serial port can be shared, but confusing as to what is actually happening.

        Comment


        • #5
          I read that the program gets transferred to RAM off of the SD card. Yet my gauge freezes when the SD card is removed. Is there any way to allow the SD card to come out after the 4xe code is run?

          Also, I noticed I get a timeout error that must be ignored before the code runs. Don't know why. I just tried file_Exec("RunFlash.4xe") and still get the same thing. Seems to be that both functions return false and probably hang on "return WaitForAck() ;"
          Last edited by zepperik; 21st September 2018, 04:22 AM.

          Comment


          • #6
            Hi,

            Thank you for pointing out that one.

            Yes, you're right! it is recommended to use a SoftwareSerial library:
            one serial comm., for debugging between the Arduino and PC while, the other one are between the Arduino and the Display.

            Gauge widget freeze because the graphics supporting files are on the SD card.

            Unfortunately, it's not possible, from the fact that these graphics supporting files(.dat and .gci files) have a larger file size. Thus, you can't store it on the display's flashbank and in addition to that, those flashbanks have not so high write cycles.


            For your references, I've attached an Arduino Sketch and "Copy to SD card" files that are related to your concern and also you could modify it especially the pin assignment. This sample demonstrates how to run a child program(ViSi-genie program) via SPE and the Arduino controls a CoolGauge.



            Hopefully, this will help you.


            Best regards,
            Kayven
            Attached Files
            Last edited by kayven@4d; 21st September 2018, 02:17 PM.

            Comment


            • #7
              I'm trying to move over to a Raspberry Pi now, and was using the Genie library: https://github.com/4dsystems/ViSi-Genie-RaspPi-Library and the Picaso library: https://github.com/4dsystems/Picaso-...-Linux-Library. Now it would seem the hang up on file_Run("RunFlash.4xe") is impossible to circumvent. I'm now to the point of executing everything manual via a terminal with FileMount "FF03" and every combination of run/exec/load/call (000D.../0004.../00D.../0019...). The command works and my gui is loaded, but I never get an acknowledgement and no more commands are accepted (i.e. FFCD does not clear the screen anymore). Sometimes after a while I'll get spurious Nak responses of x/0015.

              Is there any special setup required for the 4XE to run? I realize that the libraries I listed will not work out of the box (I open with one and pass the file descriptor to the other). In the Begin() command (used in your arduino.zip), the C++ source shows that there are few more commands after passing the port to genie...

              Code:
              void Genie::Begin (Stream &serial) {
                  deviceSerial = &serial;
                  PushLinkState(GENIE_LINK_IDLE);
                  FlushEventQueue();
              }
              Is it possible that these commands need to be called in my c code before Genie will listen for commands?
              Last edited by zepperik; 25th September 2018, 06:14 AM.

              Comment


              • #8
                Hello zepperik,

                Using the Raspberry Pi Genie Library, the environment is set in ViSi-Genie
                so the serial commands(SPE) available for the Linux Library will not work.
                The two environments contains a different set of commands.

                Since you only need to use the "file_Run" command, you can manually send the
                bytes to the display using the serial command available for the Diablo16 processor.
                For more information you can check this document: Diablo16 Processor - Serial Command Reference Manual

                I hope this helps.
                Best regards,
                Kevin

                Comment


                • #9
                  Thanks John,

                  I understand now. The entire Picaso library is offline while Genie is running. It also makes sense that since the executable never finishes, I wouldn't get an acknowledgement. I've got it running now by commenting out the WaitForAck() in my Picaso library. I also needed to use a different GUI because I stupidly didn't realize that the Raspi example that I got off the website only worked with embedded flash code/callbacks which I can't program without the cable (I believe that is correct).

                  I really like the capabilities of this display and am hoping to use it on a product, so thanks for your help. Just for completeness, is resetting the display the only way to exit Genie Land and go back to Picaso Land, i.e. if I wanted to run a different 4XE gui, do I need to just reset the display and remount the card?

                  Comment


                  • #10
                    Hi zepperik,

                    Just for completeness, is resetting the display the only way to exit Genie Land and go back to Picaso Land
                    Unfortunately yes.

                    i.e. if I wanted to run a different 4XE gui, do I need to just reset the display and remount the card?"
                    I think it is best to create another GUI on a different form, so you will only need to call the
                    .4XE once. But if the file become too large then yes you need to reset the display and remount the card.

                    Best Regards,
                    Kevin

                    Comment


                    • #11
                      If you have the pro version of the workshop4, you can check the "ExitGenie.4DGenie"
                      file which can be located under File->Samples->ViSi Genie Magic.

                      With this file, you can exit Genie and be able to call the Genie on SPE Environment.

                      The internal function "SystemReset()" will be responsible for doing the task.
                      You can call this function through creating a magic object/magic event.

                      Best Regards,
                      Kevin

                      Comment

                      Working...
                      X