Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUERY_FIRMWARE doesn't use currentBuffer to get length #9

Merged
merged 2 commits into from Jul 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions examples/blink.js
@@ -0,0 +1,35 @@
/**
* Sample script to blink LED 13
*/


console.log('blink start ...');

var ledPin = 13;

var firmata = require('../lib/firmata');
var board = new firmata.Board('/dev/ttyACM0', function() {

console.log('connected');

console.log('Firmware: ' + board.firmware.name + '-' + board.firmware.version.major + '.' + board.firmware.version.minor);

var ledOn = true;
board.pinMode(ledPin, board.MODES.OUTPUT);

setInterval(function(){

if (ledOn) {
console.log('+');
board.digitalWrite(ledPin, board.HIGH);
}
else {
console.log('-');
board.digitalWrite(ledPin, board.LOW);
}

ledOn = !ledOn;

},500)

});
5 changes: 4 additions & 1 deletion lib/firmata.js
Expand Up @@ -120,9 +120,12 @@ SYSEX_RESPONSE[QUERY_FIRMWARE] = function(board) {
board.firmware.version = {};
board.firmware.version.major = board.currentBuffer[2];
board.firmware.version.minor = board.currentBuffer[3];
for (var i = 4, length = board.length - 3; i < length; i += 2) {
for (var i = 4, length = board.currentBuffer.length - 3; i < length; i += 2) {
firmwareBuf.push((board.currentBuffer[i] & 0x7F) | ((board.currentBuffer[i + 1] & 0x7F) << 7));

}


board.firmware.name = new Buffer(firmwareBuf).toString('utf8', 0, firmwareBuf.length);
board.emit('queryfirmware');
};
Expand Down