Skip to content

Commit

Permalink
Merge pull request #75 from noopkat/greenkeeper-serialport-4.0.1
Browse files Browse the repository at this point in the history
Update serialport to version 4.0.1 🚀
  • Loading branch information
noopkat authored Jul 12, 2016
2 parents 91faaa8 + 960efcc commit 61a5aa6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 33 deletions.
5 changes: 3 additions & 2 deletions lib/avr109.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ Avr109.prototype._reset = function(callback) {
var conn;

// creating a temporary connection for resetting only
var tempSerialPort = new Serialport.SerialPort(_this.connection.options.port, {
var tempSerialPort = new Serialport(_this.connection.options.port, {
baudRate: 1200,
}, false);
autoOpen: false
});

_this.connection.serialPort = tempSerialPort;
conn = _this.connection;
Expand Down
5 changes: 3 additions & 2 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ Connection.prototype._init = function(callback) {
* Create new serialport instance for the Arduino board, but do not immediately connect.
*/
Connection.prototype._setUpSerial = function(callback) {
this.serialPort = new Serialport.SerialPort(this.options.port, {
this.serialPort = new Serialport(this.options.port, {
baudRate: this.board.baud,
}, false);
autoOpen: false
});
return callback(null);
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"graceful-fs": "^4.1.2",
"intel-hex": "^0.1.1",
"minimist": "^1.2.0",
"serialport": "^3.1.2",
"serialport": "^4.0.1",
"stk500": "git://github.com/noopkat/js-stk500v1#avrgirl",
"stk500-v2": "^1.0.1"
},
Expand Down
72 changes: 44 additions & 28 deletions tests/connection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ test('[ Connection ] ::_listPorts (UNIX)', function(t) {
SerialPort: require('./helpers/mockSerial').SerialPort
} });

var c = new ConnectionTest(DEF_OPTS1);
c._listPorts(function(error, ports) {
t.ok(ports.length, 'got a list of ports');
t.ok(ports[2]._standardPid, 'added _standardPid property');
t.error(error, 'no error on listing');
});
// nodejs 0.10.x race condition needs this
setTimeout(function() {
var c = new ConnectionTest(DEF_OPTS1);
c._listPorts(function(error, ports) {
t.ok(ports.length, 'got a list of ports');
t.ok(ports[2]._standardPid, 'added _standardPid property');
t.error(error, 'no error on listing');
});
}, 200);
});

test('[ Connection ] ::_listPorts (WINDOWS)', function(t) {
Expand All @@ -61,12 +64,15 @@ test('[ Connection ] ::_listPorts (WINDOWS)', function(t) {
SerialPort: require('./helpers/mockSerial').SerialPort
} });

var c = new ConnectionTest(DEF_OPTS1);
c._listPorts(function(error, ports) {
t.ok(ports.length, 'got a list of ports');
t.ok(ports[0]._standardPid, 'added _standardPid property');
t.error(error, 'no error on listing');
});
// nodejs 0.10.x race condition needs this
setTimeout(function() {
var c = new ConnectionTest(DEF_OPTS1);
c._listPorts(function(error, ports) {
t.ok(ports.length, 'got a list of ports');
t.ok(ports[0]._standardPid, 'added _standardPid property');
t.error(error, 'no error on listing');
});
}, 200);
});

test('[ Connection ] ::_sniffPort (UNIX)', function(t) {
Expand All @@ -88,12 +94,15 @@ test('[ Connection ] ::_sniffPort (UNIX)', function(t) {
SerialPort: require('./helpers/mockSerial').SerialPort
} });

var c = new ConnectionTest(DEF_OPTS1);
c._sniffPort(function(error, match) {
t.ok(match.length, 'board was detected');
t.equal(match[0].comName, '/dev/cu.usbmodem1421', 'correct comName to match against');
t.error(error, 'no error on return');
});
// nodejs 0.10.x race condition needs this
setTimeout(function() {
var c = new ConnectionTest(DEF_OPTS1);
c._sniffPort(function(error, match) {
t.ok(match.length, 'board was detected');
t.equal(match[0].comName, '/dev/cu.usbmodem1421', 'correct comName to match against');
t.error(error, 'no error on return');
});
}, 200);
});

test('[ Connection ] ::_sniffPort (WINDOWS)', function(t) {
Expand All @@ -110,12 +119,15 @@ test('[ Connection ] ::_sniffPort (WINDOWS)', function(t) {
SerialPort: require('./helpers/mockSerial').SerialPort
} });

var c = new ConnectionTest(DEF_OPTS1);
c._sniffPort(function(error, match) {
t.ok(match.length, 'board was detected');
t.equal(match[0].comName, 'COM3', 'correct comName to match against');
t.error(error, 'no error on return');
});
// nodejs 0.10.x race condition needs this
setTimeout(function() {
var c = new ConnectionTest(DEF_OPTS1);
c._sniffPort(function(error, match) {
t.ok(match.length, 'board was detected');
t.equal(match[0].comName, 'COM3', 'correct comName to match against');
t.error(error, 'no error on return');
});
}, 200);
});

test('[ Connection ] ::_cycleDTR', function(t) {
Expand Down Expand Up @@ -161,8 +173,12 @@ test('[ Connection ] ::_pollForPort', function(t) {
port: '/dev/cu.usbmodem1421'
};

var c = new ConnectionTest(options);
c._pollForPort(function(error) {
t.error(error, 'no error on polling result');
});
// nodejs 0.10.x race condition needs this
setTimeout(function() {
var c = new ConnectionTest(options);
c._pollForPort(function(error) {
t.error(error, 'no error on polling result');
});
}, 200);

});

0 comments on commit 61a5aa6

Please sign in to comment.