Saving Issue(Maybe?).

Posted on
  • When I type save() I receive:

    =undefined
    Erasing Flash.....................
    Programming 36000 Bytes...................................­....
    Checking...
    Done!
    >ERROR: Invalid baud rate specified
    

    I am curious as to what ERROR: Invalid baud rate specified
    refers too.

    I disconnect then close the Espruino WebIDE window. Next, I open the WebIDE, connect and type dump(). dump returns:

    var phValue = "";
    function getPhValue() {
     on = !on;
     digitalWrite(LED1, on);
     Serial4.print("r\r");
    }
    var interval = 1;
    var on = false;
    setInterval(getPhValue, 15360000);
    Serial4.onData(function (e) {
      phValue+=e.data;
      if (e.data == "\r") {
        print(phValue);
        phValue="";
      }
    });
    =undefined
    

    My JS code seems to have saved correctly, but the code will not execute upon a save() or when I unplug and plug the Espruino board into the same USB port to obtain power. I also tried pressing the reset button, but that does not seem to reset the board. The only change I see when pressing the RESET button is, the WebIDE locks up causing me to have to unplug the Espruino board from the USB port, then plug the board into a different USB port in-order for the WebIDE to recognize the Espruino board again.

    Pressing the Send to Espruino button works as expected; however, as I stated above, submitting save() does not work as expected. What should I do to get the saved code to work?

  • I flashed the Espruino board down from 1v52r3 to 1v51r3. Downgrading the firmware I think fixed the >ERROR: Invalid baud rate specified I do not receive that error after submitting save(). However, I am still not able to get the code to execute upon the boards initial power-up.

  • Define function onInit(), and put the code that needs to run on startup into that.

  • DrAzzy, I added the function as you suggested. I then unplugged the board from the USB port and plugged the board back into the USB port, but the code does not seem to execute upon startup. My new code is:

    var phValue="";
    
    Serial4.setup(38400);
    //Serial1.setup(9600/*baud*/);
    
    Serial4.onData(function (e) {
      phValue+=e.data;
    
      if (e.data == "\r") {
        print(phValue);
        phValue="";
      }
    });
    
    function getPhValue() {
     on = !on;
     digitalWrite(LED1, on);
    
     Serial4.print("r\r");
    }
    
    function onInit() {
    	var interval = setInterval(getPhValue, 1500);
    }
    
  • Probably you need to call the onInit() function. Now it is defined but not called.
    Just add:
    onInit()
    at the end of the program.

    I guess there is no concept of "autoexec.bat" (in this case onInit) so it needs to be explicitely called.

  • Of course it does not explain why the save command fails, and why your original program does not work.

  • As simple as JavaScript can be, I guess there still is a little bit of a learning curve :-)

    I called onInit() at the bottom of my script and it now works as expected :-)

  • @Gordon
    Could you please comment on the save() behaviour reported in this thread?
    Thanks,

  • @BogdanG I've been away over the weekend :)

    I'll check into this. The baud rate issue is a strange one (although I guess the code you've written at the start should also have Serial4.setup(38400); in it?

    Also I notice that setInterval is reported wrong in dump, although I think I know what the bug is there...

  • Ok, found and fixed some issues. This will be fixed in 1v53, or in the build from http://www.espruino.com/binaries/git in an hour or so

  • I read through the troubleshoot section of the Espruino Website and found the answer to my locking up issues. I switch back to 1.52 of the firmware. Even though I still get the error mentioned in my original post, the code still executes as expected.

    Thanks Gordon for taking the time to fix that bug. I'm looking forward to the next updated firmware.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Saving Issue(Maybe?).

Posted by Avatar for d0773d @d0773d

Actions