• Failed real fast on v56 - was setting it up before I went out, and it failed before I got out the door (didn't have a chance to study the results yet, since I'm on my way out the door)

    http://drazzy.com/espruino/v56failure.txt

    
    var d;
    var e;
    var inits=new Uint8Array([0,0,0,0]);
    var curdht=false;
    var t=-1;
    var rh=-1;
    var t2=-1;
    var rh2=-1;
    var fs;
    var havetraced=false;
    
    
    
    function onInit() {
        digitalWrite(A14,1);
        digitalWrite(A13,1);
        setTimeout("doInit();",2000);
    }
    
    function doInit() {
        fs=require("fs");
        fs.appendFile("timetemp5.log","Espruino restarted")
        digitalWrite(A13,0);
        d=require("DHT11dev").connect(C10);
        d.read(function(a){ t=a.temp; rh=a.rh; inits[1]=1;endInit();});
        e=require("DHT22dev").connect(C11);
        setTimeout(function(){ e.read(function(a){ t2=a.temp; rh2=a.rh; inits[2]=1;endInit();});},2000);
    
    }
    
    function endInit() {
        if (inits[1]==1 && inits[2]==1 && inits [3]==0) 
        {
            inits[3]=1;
            digitalWrite(A14,0);
            setInterval(function() {var mf=process.memory().free;console.log(mf.toString()+" "+getTime().toFixed().toString()); if (mf < 1100) traceit();curdht=!curdht;if(curdht){doMeasure();}else{doMeasure2();}},5000);
            setInterval(function(){dologs();},30000);
            setBusyIndicator(A13);
        }
    }
    
    function traceit() {
        if (!havetraced) {
            havetraced=true;
            trace();
        }
    }
    
    function doMeasure() {
        d.read(function(a) {
            if (a.rh!=-1 && a.temp < 50) {
            	rh=a.rh;
            	t=a.temp;
            }
        });
    }
    
    function dologs() {
        console.log("trying to log...");
        fs.appendFile("timetemp5.log","DHT11,"+t.toString()+","+rh.toString()+",DHT22,"+t2.toString()+","+rh2.toString()+",Time,"+getTime().toFixed()+"\n");
    }
    
    function doMeasure2() {
        e.read(function(a) {
            if (a.rh!=-1 && a.temp < 50) {
                rh2=a.rh;
                t2=a.temp;
            } 
        });
    }
    
    save();
    
    
About

Avatar for DrAzzy @DrAzzy started