Open dtex opened 7 years ago
Updated
I can reproduce with:
"use strict";
const Tessel = require("../lib/");
const board = new Tessel();
board.on("ready", () => {
const pins = ["A4","A7","B2","B4","B7"];
const values = pins.reduce((accum, pin) => (accum[pin] = 0, accum), {});
pins.forEach(p => {
board.pinMode(p, board.MODES.ANALOG);
board.analogRead(p, value => values[p] = value);
});
// 50Hz
setInterval(() => {
process.stdout.write(`\r ${Date.now()}: ${pins.map(p => padStart(values[p], 4, 0)).join("")}`);
}, 1000 / 50);
});
function padStart(v, l, c) {
v = String(v);
return Array(l - v.length + 1).join(c || " ") + v;
}
I will have a branch for you to try later today
Here's an updated test program that I've been running:
"use strict";
const Tessel = require("../lib/");
const board = new Tessel();
board.on("ready", () => {
console.log(`Started At: ${Date.now()}`);
const pins = ["A4","A7","B2","B3","B4","B5","B6","B7"];
const values = pins.reduce((accum, pin) => (accum[pin] = 0, accum), {});
pins.forEach(p => {
board.pinMode(p, board.MODES.ANALOG);
board.analogRead(p, value => values[p] = value);
});
// 50Hz
setInterval(() => {
process.stdout.write(`\r ${Date.now()}: ${pins.map(p => padStart(values[p], 4, 0)).join("")}`);
}, 1000 / 50);
});
function padStart(v, l, c) {
v = String(v);
return Array(l - v.length + 1).join(c || " ") + v;
}
This has been going steadily for over 10 minutes. I did a screen recording for about a minute of that, which shows me adjusting a potentiometer on A4: https://www.youtube.com/watch?v=3f_xcWk3DPg
I just stopped the program after it passed 20 minutes. I'm going to add some digital writing into the process and see what happens.
@dtex if you would...
npm install rwaldron/tessel-io#16
Here's the version that writes...
"use strict";
const Tessel = require("../lib/");
const board = new Tessel();
board.on("ready", () => {
console.log(`Started At: ${Date.now()}`);
const pins = ["A4","A7","B2","B3","B4","B5","B6","B7"];
const values = pins.reduce((accum, pin) => (accum[pin] = 0, accum), {});
pins.forEach(p => {
board.pinMode(p, board.MODES.ANALOG);
board.analogRead(p, value => values[p] = value);
});
const leds = ["L0", "L1", "L2", "L3"];
let state = 1;
leds.forEach(led => board.digitalWrite(led, state));
// 50Hz
setInterval(() => {
process.stdout.write(`\r ${Date.now()}: ${pins.map(p => padStart(values[p], 4, 0)).join("")}`);
state ^= 1;
leds.forEach(led => board.digitalWrite(led, state));
}, 1000 / 50);
});
function padStart(v, l, c) {
v = String(v);
return Array(l - v.length + 1).join(c || " ") + v;
}
I missed your request. Will test tonight.
Same result. No more freezing.
That's great! I will get this merged and released asap
If there is more than one Sensor instance, the Tessel 2 console output will freeze after a few seconds.
Tessel environment versions:
One sensor seems to work fine:
But two sensors will freeze up after a few seconds:
Note that I'm not doing anything with that second sensor. The fact that it exists seems to matter.
Notes:
This code seems to work fine which is what leads me to believe the problem is in tessel-io: