• While running the following (example) code to read IR signals

    digitalWrite(D2,0);
    pinMode(D1,"input_pullup");
    var d = [];
    setWatch(function(e) {
       d.push(1000*(e.time-e.lastTime));
    }, D1, {edge:"both",repeat:true});
    
    
    var lastLen = 0;
    setInterval(function() {
      if (d.length && d.length==lastLen) {
        d.shift(); // remove first element
        console.log(d.map(a=>a.toFixed(1)).toStr­ing());
        d=[];
      }
      lastLen = d.length;
    },200);
    
    
    

    I get this after a few reads:

    .1,4.6,0.6,0.6,0.6,1.7,0.6,1.7,0.6,1.7,0­.5,0.6,0.6,1.7,0.6,1.7,0.6,1.7,0.6,1.7,0­.6,1.7,0.6,1.7,0.5,0.6,0.6,0.6,0.6,0.6,0­.6,0.5,0.6,1.7,0.6,1.7,0.6,0.6,0.6,1.7,0­.6,0.6,0.6,0.6,0.6,0.5,0.6,0.6,0.6,0.5,0­.6,0.6,0.6,0.6,0.6,1.7,0.6,1.7,0.6,0.5,0­.6,0.6,0.6,0.5,0.6,1.7,0.6,40.0,9.1,2.2,­0.6,97.2,9.1,2.2,0.6
    4.0,3.9,0.6,0.9,0.6,0.8,0.6,0.8,0.6,0.8,­0.6,0.9,0.6,0.9,0.6,0.9,0.6,0.8,0.6,0.9,­0.6,0.8,0.6,0.9,0.6,0.8,0.6,0.8,0.6,0.9,­0.6,0.9,0.6,0.9,0.6,0.8,0.6,0.8,0.6,0.9,­0.6,0.9,0.6,0.8,0.6,0.8,0.6,1.9,0.6,0.9,­0.6
    ERROR: Ctrl-C while processing watch - removing it. Execution
    Interrupted during event processing. New interpreter error:
    CALLBACK,MEMORY ERROR: Ctrl-C while processing interval - removing it.
    Execution Interrupted during event processing.

    What seems to be the issue?

    How do I go about to debug this?

    Thanks!

  • Sun 2019.11.10

    Hello @user104751

    While I don't have a definitive response just yet, I did notice in L#13 that variable 'a' doesn't appear to be defined. What is that line supposed to do? (EDIT: see edit pp below)

    ref: https://www.w3schools.com/jsref/jsref_ma­p.asp
    'Note: map() does not execute the function for array elements without values.'

    https://developer.mozilla.org/en-US/docs­/Web/JavaScript/Reference/Functions/Arro­w_functions
    https://codeburst.io/javascript-arrow-fu­nctions-for-beginners-926947fc0cdc

    Is it possible that 'a' is defined in a separate module?

    EDIT:
    After re-reading the definition for map() it's argument *is* the arrow function defined there. So it isn't necessary to define 'a' using the 'var' keyword
    but, . . . if the contents passed to the map() function are undefined or null still might be throwing an error as indicated in the note above just below the ref link

    If 'a' becomes undefined might be a possible reason. One could wrap the guts of the setInterval function with a try/catch block to see if any errors could be trapped that are just bubbling up and missed.

    Is L#17 setInterval() intended to execute five times a second?

    Has process.memory() been run and how much free memory does remain. Is it possible the above snippet is using and not freeing all available memory?



    Just found this-Another user had the same error recently using setWatch(). See end of post:

    http://forum.espruino.com/comments/14882­864/

    Let's start with the basics, what is the result of process.env? Please post for flashed version verification.

  • The example comes from here: http://www.espruino.com/Puck.js+Infrared­.

    Here's the output of process.memory() before and after loading the code.

    process.env follows.

    process.memory()
    ={ free: 2217, usage: 33, total: 2250, history: 12,
    gc: 0, gctime: 3.23486328125, "stackEndAddress": 536924008, flash_start: 0, "flash_binary_end": 419924,
    "flash_code_start": 442368, flash_length: 524288 }


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    |_| || |_|||_|_|

        |_| espruino.com
    

    2v04 (c) 2019 G.Williams

    process.memory()
    ={ free: 2180, usage: 70, total: 2250, history: 46,
    gc: 0, gctime: 3.2958984375, "stackEndAddress": 536924008, flash_start: 0, "flash_binary_end": 419924,
    "flash_code_start": 442368, flash_length: 524288 }

    process.env
    ={
    VERSION: "2v04",
    GIT_COMMIT: "3956264e",
    BOARD: "PUCKJS",
    FLASH: 524288, RAM: 65536,
    SERIAL: "f4801353-1c650745",
    CONSOLE: "Bluetooth",
    MODULES: "Flash,Storage,hea" ... "S,crypto,neopixel",
    EXPTR: 536882364 }

    It is possible that the IR signals are not properly formulated i.e. more than a few transitions.
    But I doubt the stream of data would overflow d[].

  • @user104751, I think you get some noise and may be additional signals that makes your interrupt buffer to overflow...

    If your receiver is just sticked into puck's thru holes and the leads do not make good contact, lightest vibration - even from loud sound / music - give you additional signals and buffer overruns.

    With additional signals may come from other sources or reflections.

    Also, if you keep sending the buffer may overflow.

  • I did just stick the IR pins without soldering!

    Just curious how I could look into the size of the interrupt buffer? What would be the function call?

    Thanks.

  • You can check the error flags - https://www.espruino.com/Reference#l_E_g­etErrorFlags - but more details you would have to access with peek... where though is not known to me... may be it can be figured out looking at the firmware / source code...

    You can bend / spread the leads a bit to get better contact.

    Check also the battery of your puck...

    Some architectural detail:

    Espruino has mainly two interrupt driven activities:

    • Low level hardware activities that pick up pin changes and when watched it puts details it into an interrupt/event queue (similar do timeouts and intervals and completions of some low level functions, like receiving or sending data). This has highest priority and interrupts the other level of activities.

    • High level javascript activities that pick up what is in the event/interrupt queue and executes the piece of javascript that is tied to it. When done with one piece, it checks for the next one and executes it until all is done and then it goes to sleep / idle.

    Since hardware events can happen much quicker than javascript can act on it, the events are put in the event queue. To not miss any events in JavaScript, JavaScript pieces should be as short/small as possible... after all, you have only one processor...

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

Puck.js Execution Interrupted during event processing. New interpreter error: CALLBACK,MEMORY

Posted by Avatar for user104751 @user104751

Actions