Bigram builds since early november are bad.

Posted on
  • Something bad happened to setWatch() events in bigram builds sometime in november.

    Using this debug module code:

    
    exports.connect = function(pin) {
        return new DHT22(pin);
    }
    
    function DHT22(pin) {
      this.pin = pin;
      this.readfails=0;
      this.tout=0;
      this.hout=0;
      this.cks=0; 
    }
    DHT22.prototype.read = function (a) {
        this.onreadf=a;
        this.i=0;
        this.tout=0;
        this.hout=0;
        this.cks=0; 
        pinMode(this.pin);
        var dht = this;
        digitalWrite(this.pin,0);
        this.watch=setWatch(function(t) {dht.onwatch(t);},dht.pin,{repeat:true})­;
        setTimeout(function() {pinMode(dht.pin,'input_pullup');},3);
        setTimeout(function() {dht.onread(dht.endRead());},50);
    };
    DHT22.prototype.onread= function(d) {
        var dht=this;
        if (d.temp==-1) {
            dht.readfails++
            if(dht.readfails < 20) {
                dht.read(dht.onreadf);
            } else {
                dht.onreadf(d);
                dht.readfails=0;
            }
        } else {
            dht.readfails=0;
            dht.onreadf(d);
        }
    };
    DHT22.prototype.onwatch = function(t) {
        if (t.state) {
            this.pstart=t.time;
        } else {
            var tt=t.time-this.pstart;
            if (tt < 0.0002) {
                this.recbit(tt,this.i);
                this.i++;
            }
        }
    };
    DHT22.prototype.recbit = function(plen,bit) {
        if (bit==0){} else if (bit < 17) {
            this.hout=(this.hout<<1) | (plen > 0.0000382);
        } else if (bit < 33) {
            this.tout=(this.tout<<1) | (plen > 0.0000382);
        } else {
            this.cks=(this.cks<<1) | (plen > 0.0000382);
        }
        console.log("bit"+bit+" "+plen);
    }
    DHT22.prototype.endRead = function() {
        clearWatch(this.watch);
        var tcks = this.hout&0xFF;
        tcks+= (this.hout>>8)&0xFF;
        tcks+= (this.tout&0xFF);
        tcks+= (this.tout>>8)&0xFF;
        tcks=tcks&0xFF;
        if (tcks==this.cks && this.hout > 0 && this.tout > 0) {
            var rh=this.hout*0.1;
            var temp=this.tout*0.1;
            if (this.tout&0x8000) {
                temp=temp*-1;
            }
            if (rh < 100 ) {
                return {"temp":temp,"rh":rh};
            }
        }
        console.log()
        return {"temp":-1,"rh":-1};
    };
    
    
    

    Running this code:

    var d=require("DHT22").connect(A1);
    setTimeout("d.read(function(a){console.l­og(a);});",2000);
    

    On 11/11 bigram github (effectively v71), release v71, and latest github build (all wiznet):

    
    >reset();
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v72 Copyright 2014 G.Williams
    >echo(0);
    =undefined
    bit0 0.00008106231
    bit1 0.00002574920
    bit2 0.00002574920
    bit3 0.00002574920
    bit4 0.00002574920
    bit5 0.00002670288
    bit6 0.00002670288
    bit7 0.00002670288
    bit8 0.00007247924
    bit9 0.00002574920
    bit10 0.00007343292
    bit11 0.00002670288
    bit12 0.00007438659
    bit13 0.00002670288
    bit14 0.00007343292
    bit15 0.00007343292
    bit16 0.00002479553
    bit17 0.00002670288
    bit18 0.00002574920
    bit19 0.00002574920
    bit20 0.00002574920
    bit21 0.00002574920
    bit22 0.00002574920
    bit23 0.00002574920
    bit24 0.00002479553
    bit25 0.00007343292
    bit26 0.00007343292
    bit27 0.00007343292
    bit28 0.00002574920
    bit29 0.00002574920
    bit30 0.00007438659
    bit31 0.00002670288
    bit32 0.00002574920
    bit33 0.00002574920
    bit34 0.00002574920
    bit35 0.00007343292
    bit36 0.00007343292
    bit37 0.00007343292
    bit38 0.00002670288
    bit39 0.00007343292
    bit40 0.00007247924
    { "temp": 22.8, "rh": 34.2 }
    
    

    On latest bigram wiznet build based on 12/28 github sync. Similar results observed with 11/24 bigram:

    
    >reset();
    =undefined
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v72 Copyright 2014 G.Williams
    >echo(0);
    =undefined
    bit0 -223.99997234344
    bit1 0.00002765655
    bit2 -1103.99997329711
    bit3 0.00002670288
    bit4 -1119.99997329711
    bit5 -335.99992275238
    bit6 -239.99997425079
    bit7 -575.99997234344
    bit8 -1023.99997329711
    bit9 -1247.99997329711
    bit10 -975.99992275238
    bit11 -79.99992275238
    bit12 -1055.99992465972
    bit13 -1119.99997234344
    bit14 -303.99997234344
    bit15 -911.99992275238
    bit16 -191.99997425079
    >
    { "temp": -1, "rh": -1 }
    >
    
    

    Gordon - do you have any idea what might have changed here, and what I have to do to get my bigram builds working again?

    All that I do in the bigram builds is replace the board definition with one reporting 512k flash 64k ram and kick off the build - i'm really baffled as to what it could be that causes it to get confused when handling events. This happens on all three of my espruino boards (which all have run bigram with no problems until this).

  • Update - it's not just bigram.

    Even if i just sync github and build it, it does this. But official builds work....

    Let's try updating the compiler to match the version gordon uses

    Now using gcc-arm-none-eabi-4_8-2014q3 for compilation - CodeSourcery stopped being supported

    Watch me break my build environment completely....

  • Hurray! It works, I think.... Works on non-bigram. Rebuilding bigram now.

    Yup, that fixed it.

    New working bigram builds are up, and I've deleted the ones I belive to be broken.

  • Hi DrAzzy

    Thanks for your work. I use only your bigram builds.

    Sacha

  • Hi. Sorry it's taken a while to get back to you.

    It's a bit scary that the build with the old compiler now breaks. It'd be very interesting if you ever found out why it's not going... I wonder whether it could be some issue with the code size? I know that while the old compiler got smaller code with -O3, the new one does better with -Os

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

Bigram builds since early november are bad.

Posted by Avatar for DrAzzy @DrAzzy

Actions