reset() and save() question

Posted on
  • Yesterday my 5 pucks arrived. @gordon - superb!

    Started to play around a bit and just got stuck at a thing that happened to my pico before:

    I tried out a demo, now I want to get rid of it.
    So I connect and do this:

    Connected
    >
    >dump()
    var isOn = false;
    setWatch(function () {
      isOn = ! isOn;
        analogWrite(LED1, (isOn) ? 0.02 : 0);
    }, "D0", { repeat:true, edge:'rising', debounce : 49 });
    setBusyIndicator(D3);
    digitalWrite(D3, 1);
    pinMode(D29, "input_pulldown", true);
    =undefined
    

    Call reset() to kill it:

    >reset()
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v89 Copyright 2016 G.Williams
    

    Call save() to persist the "clean" state:

    >save()
    =undefined
    Erasing Flash.....
    Writing....
    Compressed 32000 bytes to 1372
    Checking...
    Done!
    

    Should be gone now, or not?
    But look here - still there:

    >dump()
    var isOn = false;
    setWatch(function () {
      isOn = ! isOn;
        analogWrite(LED1, (isOn) ? 0.02 : 0);
    }, "D0", { repeat:true, edge:'rising', debounce : 49 });
    setBusyIndicator(D3);
    digitalWrite(D3, 1);
    pinMode(D29, "input_pulldown", true);
    =undefined
    > 
    

    So - how can I get rid of the running code?

    Maybe I did not understand the concept of reset() and save() properly...

  • try

    reset();save();

  • Thanks. Just tried.
    Same result.
    dump() still shows the old code...

  • hmm

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v89 Copyright 2016 G.Williams
    >u32 = new Uint32Array(4);
    =new Uint32Array(4)
    >u32[0] = 32;
    =32
    >save();
    =undefined
    Erasing Flash.....
    Writing....
    Compressed 32000 bytes to 1373
    Checking...
    Done!
    >dump();
    var u32 = new Uint32Array([32, 0, 0, 0]);
    pinMode(D29, "input_pulldown", true);
    =undefined
    >reset();
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v89 Copyright 2016 G.Williams
    >save();
    =undefined
    Erasing Flash.....
    Writing....
    Compressed 32000 bytes to 1181
    Checking...
    Done!
    >dump();
    pinMode(D29, "input_pulldown", true);
    =undefined
    > 
    

    only one line for a pinMode() coming from reset();

  • Maybe it's the WebIDE?
    Chrome Version 54.0.2840.98 (64-bit) on OSX 10.11.6 here with WebIDE.

    I played around with Settings->Communications->Save on Send.
    When it is set to "Yes, even execute after 'reset()'" I can remove the code when:

    • putting on dummy line like var foo; on the right hand pane
    • click "Send to Espruino"

    Simple example:

    >dump();
    function onInit() {digitalPulse(LED1, 1, 100);}
    pinMode(D29, "input_pulldown", true);
    =undefined
    

    Not working:

    >reset();save();
    =undefined
    Running onInit()...
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v88 Copyright 2016 G.Williams
    Erasing Flash.....
    Writing....
    Compressed 32000 bytes to 1222
    Checking...
    Done!
    Running onInit()...
    >dump();
    function onInit() {digitalPulse(LED1, 1, 100);}
    pinMode(D29, "input_pulldown", true);
    =undefined
    

    Putting this into the right hand pane finally kills the code (actually it replaces the current code by some dummy code):

    var foo;
    

    Send and check:

    >Erasing Flash.....
    Writing...
    Compressed 32000 bytes to 17
    Checking...
    Done!
    Loading 17 bytes from flash...
    =undefined
    >dump();
    var foo = undefined;
    pinMode(D29, "input_pulldown", true);
    =undefined
    

    This is strange...

  • hmm - missing reset(); in your last snippets, because it is not loading but clearing.

    btw you should update your puck.js to 1v89
    goto Puck.js and section Firmware Update

  • I suppose reset(); is done by the IDE and you can see it works - somehow.
    The second puck was still 1v88 - you are right.
    But it is the same with 1v89.

  • getting worse now after playing around with HID:

    >reset();
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v89 Copyright 2016 G.Williams
    Uncaught SyntaxError: Got ?[255] expected EOF
     at line 1 col 1
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ...
    ^
    

    Question:
    How can I reset the puck's memory to factory default?
    reset() doesn't seem to work or have side effects.

  • check section "I saved some code and my Puck no longer works" on Puck.js

  • It's because of the Save on Send that was set in your IDE - obviously if you set it to Yes, even execute after 'reset()' then reset wont work :)

    To force it to be removed, just run E.setBootCode() without arguments - it's the same for all Espruino boards. I'm wondering where the best place to add that to the docs is?

  • Oops - was missing that - Thank Gordon !

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

reset() and save() question

Posted by Avatar for ChristianW @ChristianW

Actions