"Execution Interrupted" in interpreter

Posted on
  • I have uploaded an app called 'Bee' that sometimes has to process a large dictionary file. I noticed that executing a JS function that does not return within ~1 or 2 seconds causes the interpreter to interrupt it, logging "Execution Interrupted" to the console window (when using the IDE). Calling the same function interactively via the REPL in the IDE does not trigger this behavior. For a simple example, run the following snippet by uploading to RAM in the IDE:

    function crunch() {
      for (i=0; i<10000; ++i) {
        var x = Math.sin(Math.random()*Math.PI);
        if (i%50 == 0) console.log(i);
      }
    }
    crunch();
    

    Execution gets interrupted before the function finishes; calling 'crunch()' interactively from the console window however lets it finish.
    I can see the purpose of this behavior to avoid lock ups in an event-loop driven system like espruino, but is there a way to (temporarily) disable it? I played around with E.kickWatchdog(), but that does not quite seem to do the trick.
    Thanks.

  • I noticed that executing a JS function that does not return within ~1 or 2 seconds causes the interpreter to interrupt it, logging "Execution Interrupted" to the console window (when using the IDE)

    Yes, that's expected. It's because you're uploading to 'RAM' with the IDE, so it executes the code as it goes - a bit more info is at https://www.espruino.com/Saving.

    The issue is if you had much code in your file after the code that takes a while to run, it could really mess up your upload.

    There are some easy fixes:

    • Run your crunch function with setTimeout(crunch,1000) - so it runs 1 sec after the upload completes
    • Switch to saving your app to a file in Bangle.js storage. That way the program text all gets uploaded in one go, and it's then executed afterwards

  • Aha, thanks. I only every tried executing it from RAM, never tried to upload to storage and run from there. This answers my question and solves my problem.
    Thanks.

  • Potentially stupid question: is the flash storage on the Bangle memory-mapped in one flat chunk? Is it somehow possible
    to then get the physical address of, say, a Storage file that could then be directly accessed via compiled C?

    I know, this sounds like a recipe for bricking a watch, if I break it I promise to keep both pieces without complaining...

  • is the flash storage on the Bangle memory-mapped in one flat chunk?

    Sadly no... The interpreter makes the flash appear memory-mapped in most cases (eg accessing a file in Storage doesn't load it into RAM), but that's all done in software - so Inline C won't be able to access it directly.

    If you're really into doing low-level stuff then right now there's a few 100k of unused internal flash in Bangle.js 2 before address 0xf6000. So you could use the Flash module to access that directly.

    On Bangle.js 2 there is actually the potential for memory-mapping the external flash too using hardware, but that isn't done at the moment.

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

"Execution Interrupted" in interpreter

Posted by Avatar for user113695 @user113695

Actions