Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isOpen() method #387

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down