var fs;
var interv;
var t=-1;
var rh=-1;
function onInit() {
setTimeout("doInit();",2000);
}
function doInit() {
fs=require("fs");
fs.appendFile("timetemp.log","Espruino restarted")
interv=setInterval(function(){dologs();},5000);
setBusyIndicator(A13);
}
function dologs() {
console.log("trying to log..."+getTime().toFixed());
var ti = getTime();
if (!fs.appendFile("diskerrator.log","DHT11,"+t.toString()+","+rh.toString()+",Time,"+getTime().toFixed()+"\n")){
console.log("FAIL before "+ti+" after "+getTime());
}
}
save();
Ran it overnight, and woke up to it broken. Manually cleared the interval, and typed getTime() a few times. These were typed a couple of seconds apart at most:
ERROR: Unable to write file : DISK_ERR
FAIL before 45778185.87560272216796 after 45778190.38722991943359
trying to log...45778199
ERROR: Unable to write file : DISK_ERR
FAIL before 45778211.53864669799804 after 45778216.05158138275146
trying to log...45778225
ERROR: Unable to write file : DISK_ERR
FAIL before 45778237.20124530792236 after 45778241.71224975585937
trying to log...45778250
ERROR: Unable to write file : DISK_ERR
FAIL before 45778262.85095405578613 after 45778267.36160087585449
trying to log...45778276
ERROR: Unable to write file : DISK_ERR
FAIL before 45778288.36543083190917 after 45778292.84815883636474
trying to log...45778302
ERROR: Unable to write file : DISK_ERR
FAIL before 45778314.20237731933593 after 45778316.91917991638183
trying to log...45778319
ERROR: Unable to write file : DISK_ERR
FAIL before 45778324.45648479461669 after 45778326.43975925445556
trying to log...45778329
ERROR: Unable to write file : DISK_ERR
FAIL before 45778333.97615909576416 after 45778336.01252174377441
clearInterval(inter);
=undefined
getTime();
=45802702.42679214477539
getTime();
=45814433.28411769866943
getTime();
=45828450.28250503540039
reset();
=undefined
_____ _
| __|___ ___ ___ _ _|_|___ ___
| __|_ -| . | _| | | | | . |
|_____|___| _|_| |___|_|_|_|___|
|_| http://espruino.com
1v58 Copyright 2014 G.Williams
=undefined
>getTime();
=46298892.14406204223632
>getTime();
=46307856.84639739990234
(in above, I had to remove the > prompt, otherwise the forum mangled it)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The timer bug can be reproduced with this code:
Ran it overnight, and woke up to it broken. Manually cleared the interval, and typed getTime() a few times. These were typed a couple of seconds apart at most:
(in above, I had to remove the > prompt, otherwise the forum mangled it)
Last entries in the log: