From 22a369112e100faa14ff8bbac12166b4792b2226 Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Fri, 21 Oct 2016 17:34:09 -0400 Subject: [PATCH] put the dataCallback back for windows reads (#976) --- lib/serialport.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/serialport.js b/lib/serialport.js index 9ddc2e9..81e3a62 100644 --- a/lib/serialport.js +++ b/lib/serialport.js @@ -164,6 +164,8 @@ function SerialPort(path, options, callback) { this.bufferSize = settings.bufferSize; this.readable = true; this.reading = false; + } else { + settings.dataCallback = this._emitData.bind(this); } this.options = settings; @@ -293,6 +295,11 @@ SerialPort.prototype.write = function(data, callback) { }.bind(this)); }; +SerialPort.prototype._emitData = function(data) { + this.emit('data', data); +}; + + if (process.platform !== 'win32') { SerialPort.prototype._read = function() { if (!this.readable || this.paused || this.reading || this.closing) { @@ -370,11 +377,6 @@ if (process.platform !== 'win32') { this.pool.used += toRead; }; - SerialPort.prototype._emitData = function(data) { - this.emit('data', data); - }; - - /** * Pauses an open connection (unix only) */