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) */