From 0b0c446c4c9b9195718b91296d412c833865eb36 Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Mon, 28 Mar 2016 17:40:24 -0500 Subject: [PATCH 1/2] serialport: avoid assigning undefined to fd property When an error is returned the bindings pass undefined instead of null. --- serialport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serialport.js b/serialport.js index 2e201ae..4db3db3 100644 --- a/serialport.js +++ b/serialport.js @@ -211,7 +211,6 @@ function SerialPortFactory(_spfOptions) { this.readable = true; this.reading = false; factory.SerialPortBinding.open(this.path, this.options, function (err, fd) { - self.fd = fd; if (err) { if (callback) { callback(err); @@ -220,6 +219,7 @@ function SerialPortFactory(_spfOptions) { } return; } + self.fd = fd; if (process.platform !== 'win32') { self.paused = false; self.serialPoller = new factory.SerialPortBinding.SerialportPoller(self.fd, function (err) { From c526fe793e63f253348fd4640425d9b265fed38e Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Mon, 28 Mar 2016 17:41:47 -0500 Subject: [PATCH 2/2] serialport: replace outdated check for open descriptor --- serialport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serialport.js b/serialport.js index 4db3db3..5b9890a 100644 --- a/serialport.js +++ b/serialport.js @@ -345,7 +345,7 @@ function SerialPortFactory(_spfOptions) { self.pool.used -= bytesRequested - bytesRead; if (bytesRead === 0) { - if (self.fd >= 0) { + if (self.isOpen()) { self.serialPoller.start(); } } else {