"CALLBACK" error?

Posted on
  • I keep getting an error message in red that says "CALLBACK" und the bottom of the screen.
    If that happens, all watches, timeouts and intervals seem to stop, but the watch still responds to bluetooth and button presses. It seems to happen only when connected to gadgetbridge.

  • Update: The error seems to occur more often, the more timeouts/intervals an app uses. My clock that updates once a minute sometimes works for days, but this ususally fails after a few minutes:

    Bangle.setBarometerPower(true, "tinyVario");
    Bangle.setGPSPower(true, "tinyVario");
    
    require("Font8x16").add(Graphics);
    
    var intTime=10,pressureInterval=100;
    var altH = [];
    var fAlt=0;
    var roc=0,rocAvg=0;
    var gs;
    var lastPressure = Date.now();
    var flying=false;
    var takeoffTime, flyingTime;
    
    
    Bangle.on('pressure', function(e) {
      if ((fAlt)==0) fAlt=e.altitude;
      fAlt=fAlt+(e.altitude-fAlt)*0.1;
    });
    
    Bangle.on('GPS', function(fix) {
      gs=fix.speed;
    });
              
    /*setWatch(function() {
      
    }, BTN1);*/
    
    setInterval(function () { 
      altH.push(fAlt);
      while (altH.length>intTime*1000/pressureInterv­al) altH.shift();
    }, pressureInterval);
    
    setInterval(function() {
      var y=0;
      //gs=100;
      //fAlt=7777;
      if ((!flying) && ((rocAvg>1) || (rocAvg<-1) || (gs>10))) { //take-off detected
        takeoffTime=Date().getTime();
        flying=true;
        flyingTime=0;
      } 
      if (flying) {
        flyingTime=Date().getTime()-takeoffTime;­
        ftString=(flyingTime / 3600000).toFixed(0)+":"+(flyingTime / 60000 % 60).toFixed(0).padStart(2,'0');
      }
      
      if (altH.length==intTime*1000/pressureInter­val) {
        rocAvg=(altH[altH.length-1]-altH[0])/int­Time;
        roc=(altH[altH.length-1]-altH[altH.lengt­h-(1000/pressureInterval)]);
      }
    
      var timeStr = require("locale").time(Date(),1);
      
      g.reset();
      g.clear();
      //draw altitude
      g.setFont("8x16",3).setFontAlign(1,-1).d­rawString((fAlt).toFixed(0)+"m", g.getWidth(), y); 
      //-------------
      y+=16*3;
      g.drawLine(24,y-2,g.getWidth(),y-2);
      //draw rate of climb
      if (roc>0.1) g.setColor(0,1,0);
      if (roc<-1) g.setColor(1,0,0);
      g.setFont("8x16",3).setFontAlign(1,-1).d­rawString(rocAvg.toFixed(1), g.getWidth()-20, y);
      g.setColor(1,1,1);
      g.setFont("8x16",2).setFontAlign(-1,-1).­drawString("m", g.getWidth()-20, y);
      g.setFont("8x16",2).setFontAlign(-1,-1).­drawString("s", g.getWidth()-20, y+20);
      g.drawLine(g.getWidth()-20,y+26,g.getWid­th()-8,y+26);
      //-------------
      y+=16*3;
      g.drawLine(24,y-2,g.getWidth(),y-2);
      //draw groundspeed
      if (!isNaN(gs)) {
        g.setFont("8x16",3).setFontAlign(1,-1).d­rawString(gs.toFixed(0), g.getWidth()-20, y);
        g.setFont("8x16",1).setFontAlign(-1,-1).­drawString("km", g.getWidth()-20, y+4);
        g.setFont("8x16",1).setFontAlign(-1,-1).­drawString("h", g.getWidth()-20, y+24);
        g.drawLine(g.getWidth()-20,y+21,g.getWid­th()-8,y+21);
      }  
      //-------------
      y+=16*3;
      g.drawLine(0,y-2,g.getWidth(),y-2);
      g.drawLine(24,0,24,y-2);
      g.drawLine(g.getWidth()/2,y-2,g.getWidth­()/2,g.getHeight()-1);
      g.setColor(1,1,1);
      //draw flight time
      if (flying) {
        g.setFont("8x16",2).setFontAlign(0,-1).d­rawString(ftString, g.getWidth()*0.75, 14*10+4);
      }
      //draw time
      g.setFont("8x16",2).setFontAlign(0,-1).d­rawString(timeStr, g.getWidth()/4, 14*10+4);
      //draw bar graph
      if (roc>0.1) g.setColor(0,1,0);
      if (roc<-1) g.setColor(1,0,0);
      g.fillRect(0,(y-2)/2,23,Math.clip((y-2)/­2-roc*20,0,y-2));
    }, 250);
    
  • My best guess is that callback (on time intervals) overrun happens... Did you ever time the anonymous functions in your intervals?

    I see sensor driven events - on(...) - which capture data that you then process in 100 and 250 ms intervals. What are the average intervals of you sensor - GPS and pressure - events?

  • This can happen if there's a ctrl-c character sent to the watch, which should only happen when Gadgetbridge connects to the watch (it uses the character to clear the input line) and not afterwards. Do you think that's the case, or does it happen during connection as well?

    Ctrl-C doesn't itself break out of the interval if it finished executing reasonably quickly, but if it takes more than ~1/2 a second then it will break execution - so it could be the clock face takes longer than that to draw?

  • When i use ContourClock it happens at seemingly random intervals. Sometimes it runs good for days, sometimes it hangs several times a day. The code in my post above usually hangs after a few minutes. It does not seem to matter whether the code uses intervals or timeouts.
    The error can be reproduced by repeatedly connecting/disconnecting via the gadgetbridge app.

  • I just played around with the blob clock, because it uses seconds and thus according to my theory is more likely to break. I connected to the watch using WebIDE and sent Ctrl-C via the console. After a few attempts, i always get this:

     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v13.138 (c) 2021 G.Williams
            let time=new Date();let hours=time.getHours();let mins=time.getMinutes()...
                        ^
    debug> 
    

    The watch can be reset via button (1s) , and i get this:

    ERROR: Ctrl-C while processing interval - removing it.
    Execution Interrupted during event processing.
    Interpreter error: [
      "CALLBACK"
     ]
    New interpreter error: CALLBACK
    > 
    
  • Thanks - then ok, that's what I expected.

    However I just checked with:

    setInterval(function() {}, 10);
    

    and Ctrl-C and it breaks. That's not the intended behaviour, so I'll have a look in the firmware and see if I can make some tweaks. It should only remove the interval if there was a Ctrl-C and the interval didn't return in ~0.5 sec.

  • Ok, I have now pushed a change that'll fix this (Ctrl-C now won't break out of short-running tasks)

  • Perfect, thanks!

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

"CALLBACK" error?

Posted by Avatar for RaoulDuke @RaoulDuke

Actions