Skip to content

Commit a99a514

Browse files
author
Cam Pedersen
committed
Merge pull request ecto#26 from trobrock/configurable-baud
Make the baud rate configurable
2 parents 5ac9eb7 + 009f338 commit a99a514

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

examples/adjustable-baud.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var arduino = require('../');
2+
3+
var board = new arduino.Board({
4+
debug: true,
5+
baudrate: 9600
6+
});
7+
8+
var led = new arduino.Led({
9+
board: board,
10+
pin: 9
11+
});
12+
13+
board.on('ready', function(){
14+
led.blink();
15+
});

lib/board.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var events = require('events'),
1212
var Board = function (options) {
1313
this.log('info', 'initializing');
1414
this.debug = options && options.debug || false;
15+
this.baudrate = options && options.baudrate || 115200;
1516
this.writeBuffer = [];
1617

1718
var self = this;
@@ -83,7 +84,7 @@ Board.prototype.detect = function (callback) {
8384
if (possible.slice(0, 2) !== 'cu') {
8485
try {
8586
temp = new serial.SerialPort('/dev/' + possible, {
86-
baudrate: 115200,
87+
baudrate: self.baudrate,
8788
parser: serial.parsers.readline('\n')
8889
});
8990
} catch (e) {

0 commit comments

Comments
 (0)