diff --git a/README.md b/README.md index 4e0e7621d..409cff6a6 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,10 @@ The `buffer` parameter accepts a [`Buffer` ](http://nodejs.org/api/buffer.html) Called once the write operation returns. The callback should be a function that looks like: `function (error) { ... }` _Note: The write operation is non-blocking. When it returns, data may still have not actually been written to the serial port. See `drain()`._ +### .isOpen() + +returns `true` if the port is open, otherwise false. + ### .pause () Pauses an open connection. diff --git a/serialport.js b/serialport.js index e322fdf62..c2e8e192e 100644 --- a/serialport.js +++ b/serialport.js @@ -204,6 +204,12 @@ function SerialPortFactory() { if (callback) { callback(); } }); }; + + + SerialPort.prototype.isOpen = function() { + if (this.fd) return true; + else return false; + } SerialPort.prototype.write = function (buffer, callback) { var self = this;