You are reading a single comment by @JumJum and its replies. Click here to read the full conversation.
  • running this prints "..." on screen, so variable startAt is corrupted

    function rtc2Date(dt){
      var t,d;
      d = dt.split(" ")[0]; t = dt.split(" ")[1];
      d = d.split("/"); t = t.split(":");
      return new Date(d[2] + 2000,d[1],d[0],t[0],t[1],t[2]);
    }
    var fs = require("fs");
    var data = JSON.parse(fs.readFile("Juergen1_ctrl.json"));
    var startAt = rtc2Date(data.options.startAt);
    //console.log(startAt);
    var entrys = fs.statSync("Juergen1_data.bin").size / 20;
    console.log(startAt);
    

    uncommented first console.log and it works fine:

    function rtc2Date(dt){
      var t,d;
      d = dt.split(" ")[0]; t = dt.split(" ")[1];
      d = d.split("/"); t = t.split(":");
      return new Date(d[2] + 2000,d[1],d[0],t[0],t[1],t[2]);
    }
    var fs = require("fs");
    var data = JSON.parse(fs.readFile("Juergen1_ctrl.json"));
    var startAt = rtc2Date(data.options.startAt);
    console.log(startAt);
    var entrys = fs.statSync("Juergen1_data.bin").size / 20;
    console.log(startAt);
    

    Also had problems sometimes by using fs.statSync from terminal window. Connection to com-port was lost, and I had to reset and restart everything.
    IMHO, this could be a problem around memory management for fs.statSync.
    Using 1v80 on Espruino Board
    Data returned from readFile is this:

    {
      "tags": {
        "MQ2": "Methane, Butane, LPG, smoke",
        "MQ4": "Methane, CNG Gas",
        "MQ7": "Carbone Monoxide",
        "temp": "Temp",
        "rh": "Humidity"
       },
      "options": { "interval": 60000, "groupLength": 10,
        "startAt": "16/06/15 22:34:23"
       }
     }
    
About

Avatar for JumJum @JumJum started