Skip to content

Commit 61a5aa6

Browse files
authored
Merge pull request #75 from noopkat/greenkeeper-serialport-4.0.1
Update serialport to version 4.0.1 🚀
2 parents 91faaa8 + 960efcc commit 61a5aa6

File tree

4 files changed

+51
-33
lines changed

4 files changed

+51
-33
lines changed

lib/avr109.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ Avr109.prototype._reset = function(callback) {
100100
var conn;
101101

102102
// creating a temporary connection for resetting only
103-
var tempSerialPort = new Serialport.SerialPort(_this.connection.options.port, {
103+
var tempSerialPort = new Serialport(_this.connection.options.port, {
104104
baudRate: 1200,
105-
}, false);
105+
autoOpen: false
106+
});
106107

107108
_this.connection.serialPort = tempSerialPort;
108109
conn = _this.connection;

lib/connection.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ Connection.prototype._init = function(callback) {
4545
* Create new serialport instance for the Arduino board, but do not immediately connect.
4646
*/
4747
Connection.prototype._setUpSerial = function(callback) {
48-
this.serialPort = new Serialport.SerialPort(this.options.port, {
48+
this.serialPort = new Serialport(this.options.port, {
4949
baudRate: this.board.baud,
50-
}, false);
50+
autoOpen: false
51+
});
5152
return callback(null);
5253
};
5354

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"graceful-fs": "^4.1.2",
3636
"intel-hex": "^0.1.1",
3737
"minimist": "^1.2.0",
38-
"serialport": "^3.1.2",
38+
"serialport": "^4.0.1",
3939
"stk500": "git://github.com/noopkat/js-stk500v1#avrgirl",
4040
"stk500-v2": "^1.0.1"
4141
},

tests/connection.spec.js

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ test('[ Connection ] ::_listPorts (UNIX)', function(t) {
3939
SerialPort: require('./helpers/mockSerial').SerialPort
4040
} });
4141

42-
var c = new ConnectionTest(DEF_OPTS1);
43-
c._listPorts(function(error, ports) {
44-
t.ok(ports.length, 'got a list of ports');
45-
t.ok(ports[2]._standardPid, 'added _standardPid property');
46-
t.error(error, 'no error on listing');
47-
});
42+
// nodejs 0.10.x race condition needs this
43+
setTimeout(function() {
44+
var c = new ConnectionTest(DEF_OPTS1);
45+
c._listPorts(function(error, ports) {
46+
t.ok(ports.length, 'got a list of ports');
47+
t.ok(ports[2]._standardPid, 'added _standardPid property');
48+
t.error(error, 'no error on listing');
49+
});
50+
}, 200);
4851
});
4952

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

64-
var c = new ConnectionTest(DEF_OPTS1);
65-
c._listPorts(function(error, ports) {
66-
t.ok(ports.length, 'got a list of ports');
67-
t.ok(ports[0]._standardPid, 'added _standardPid property');
68-
t.error(error, 'no error on listing');
69-
});
67+
// nodejs 0.10.x race condition needs this
68+
setTimeout(function() {
69+
var c = new ConnectionTest(DEF_OPTS1);
70+
c._listPorts(function(error, ports) {
71+
t.ok(ports.length, 'got a list of ports');
72+
t.ok(ports[0]._standardPid, 'added _standardPid property');
73+
t.error(error, 'no error on listing');
74+
});
75+
}, 200);
7076
});
7177

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

91-
var c = new ConnectionTest(DEF_OPTS1);
92-
c._sniffPort(function(error, match) {
93-
t.ok(match.length, 'board was detected');
94-
t.equal(match[0].comName, '/dev/cu.usbmodem1421', 'correct comName to match against');
95-
t.error(error, 'no error on return');
96-
});
97+
// nodejs 0.10.x race condition needs this
98+
setTimeout(function() {
99+
var c = new ConnectionTest(DEF_OPTS1);
100+
c._sniffPort(function(error, match) {
101+
t.ok(match.length, 'board was detected');
102+
t.equal(match[0].comName, '/dev/cu.usbmodem1421', 'correct comName to match against');
103+
t.error(error, 'no error on return');
104+
});
105+
}, 200);
97106
});
98107

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

113-
var c = new ConnectionTest(DEF_OPTS1);
114-
c._sniffPort(function(error, match) {
115-
t.ok(match.length, 'board was detected');
116-
t.equal(match[0].comName, 'COM3', 'correct comName to match against');
117-
t.error(error, 'no error on return');
118-
});
122+
// nodejs 0.10.x race condition needs this
123+
setTimeout(function() {
124+
var c = new ConnectionTest(DEF_OPTS1);
125+
c._sniffPort(function(error, match) {
126+
t.ok(match.length, 'board was detected');
127+
t.equal(match[0].comName, 'COM3', 'correct comName to match against');
128+
t.error(error, 'no error on return');
129+
});
130+
}, 200);
119131
});
120132

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

164-
var c = new ConnectionTest(options);
165-
c._pollForPort(function(error) {
166-
t.error(error, 'no error on polling result');
167-
});
176+
// nodejs 0.10.x race condition needs this
177+
setTimeout(function() {
178+
var c = new ConnectionTest(options);
179+
c._pollForPort(function(error) {
180+
t.error(error, 'no error on polling result');
181+
});
182+
}, 200);
183+
168184
});

0 commit comments

Comments
 (0)