From e8b73c278426ec3c2d5c4f9083348e4b3ce57a74 Mon Sep 17 00:00:00 2001 From: Francis Gulotta Date: Tue, 27 Feb 2018 22:49:33 -0500 Subject: [PATCH] docs: fix missing options objects and descriptions (#1504) --- .eslintrc | 3 +- docs/BaseBinding.html | 34 +- docs/ByteLengthParser.html | 6 +- docs/CCTalkParser.html | 4 +- docs/DelimiterParser.html | 4 +- docs/Poller.html | 97 ++- docs/ReadLineParser.html | 4 +- docs/ReadyParser.html | 8 +- docs/RegexParser.html | 4 +- docs/SerialPort.html | 1171 +++++++++++++++++++++++++----- docs/bindings_base.js.html | 24 +- docs/bindings_poller.js.html | 18 +- docs/global.html | 523 ++++++++----- docs/index.html | 18 +- docs/index.js.html | 4 +- docs/parsers_byte-length.js.html | 6 +- docs/parsers_cctalk.js.html | 4 +- docs/parsers_delimiter.js.html | 4 +- docs/parsers_index.js.html | 4 +- docs/parsers_readline.js.html | 4 +- docs/parsers_ready.js.html | 8 +- docs/parsers_regex.js.html | 4 +- docs/serialport.js.html | 104 +-- lib/bindings/base.js | 20 +- lib/bindings/poller.js | 14 +- lib/parsers/byte-length.js | 2 +- lib/parsers/ready.js | 4 +- lib/serialport.js | 100 +-- 28 files changed, 1598 insertions(+), 602 deletions(-) diff --git a/.eslintrc b/.eslintrc index 3332763f9..b1290ad0a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,6 +31,7 @@ "prefer-template": 2, "semi": [2, "always", {"omitLastInOneLineBlock": true}], "space-before-function-paren": [2, "never"], - "standard/object-curly-even-spacing": 0 + "standard/object-curly-even-spacing": 0, + "valid-jsdoc": [0] } } diff --git a/docs/BaseBinding.html b/docs/BaseBinding.html index 992cb5dd1..368b50983 100644 --- a/docs/BaseBinding.html +++ b/docs/BaseBinding.html @@ -22,7 +22,7 @@
@@ -214,7 +214,7 @@
Parameters:
- +

options for the biding

@@ -1069,7 +1069,7 @@
Returns:
-

open(path, openOptions) → {Promise}

+

open(path, options) → {Promise}

@@ -1175,20 +1175,20 @@
Parameters:
- +

the path or com port to open

- openOptions + options -module:serialport~openOptions +openOptions @@ -1198,7 +1198,7 @@
Parameters:
- +

openOptions for the serialport

@@ -1276,7 +1276,7 @@
Returns:
-

read(data, offset, length) → {Promise}

+

read(buffer, offset, length) → {Promise}

@@ -1367,7 +1367,7 @@
Parameters:
- data + buffer @@ -1687,7 +1687,7 @@
Properties
- +

flag for brk

@@ -1726,7 +1726,7 @@
Properties
- +

flag for cts

@@ -1765,7 +1765,7 @@
Properties
- +

flag for dsr

@@ -1804,7 +1804,7 @@
Properties
- +

flag for dtr

@@ -1843,7 +1843,7 @@
Properties
- +

flag for rts

@@ -2185,7 +2185,7 @@
Returns:
-

write(data) → {Promise}

+

write(buffer) → {Promise}

@@ -2276,7 +2276,7 @@
Parameters:
- data + buffer @@ -2383,7 +2383,7 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/ByteLengthParser.html b/docs/ByteLengthParser.html index 6b0751206..1937ac605 100644 --- a/docs/ByteLengthParser.html +++ b/docs/ByteLengthParser.html @@ -22,7 +22,7 @@
@@ -171,7 +171,7 @@
Parameters:
- +

parser options object

Properties
@@ -285,7 +285,7 @@

Extends


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/CCTalkParser.html b/docs/CCTalkParser.html index b3e15c94b..4dc30ec6b 100644 --- a/docs/CCTalkParser.html +++ b/docs/CCTalkParser.html @@ -22,7 +22,7 @@
@@ -187,7 +187,7 @@

Extends


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/DelimiterParser.html b/docs/DelimiterParser.html index 153a16146..e7612ca14 100644 --- a/docs/DelimiterParser.html +++ b/docs/DelimiterParser.html @@ -22,7 +22,7 @@
@@ -187,7 +187,7 @@

Extends


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/Poller.html b/docs/Poller.html index c2de0c594..a71de8163 100644 --- a/docs/Poller.html +++ b/docs/Poller.html @@ -22,7 +22,7 @@
@@ -69,7 +69,7 @@

new PollerSource:
@@ -155,7 +155,7 @@

Methods

-

once(Event, callback)

+

once(event) → {Poller}

@@ -167,7 +167,7 @@

onceSource:
@@ -245,7 +245,7 @@
Parameters:
- Event + event @@ -265,31 +265,15 @@
Parameters:
+ + - - - callback - - - - -function - - - - - - - - - - @@ -297,13 +281,28 @@
Parameters:
+
Returns:
+ +
+

returns itself

+
+
+
+ Type +
+
+ +Poller +
+
+ @@ -311,7 +310,7 @@
Parameters:
-

poll(eventFlag)

+

poll(eventFlag) → {undefined}

@@ -323,7 +322,7 @@

pollSource:
@@ -363,7 +362,7 @@

poll -

Ask the bindings to listen for an event

+

Ask the bindings to listen for an event, it is recommend to use .once() for easy use

@@ -407,7 +406,7 @@
Parameters:
-EVENTS +EVENTS @@ -417,7 +416,7 @@
Parameters:
- +

polls for an event or group of events based upon a flag.

@@ -437,6 +436,24 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -444,7 +461,7 @@
Parameters:
-

stop()

+

stop() → {undefined}

@@ -456,7 +473,7 @@

stopSource:
@@ -521,6 +538,24 @@

stop +
+ Type +
+
+ +undefined + + +
+ + + @@ -541,7 +576,7 @@

stop
- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/ReadLineParser.html b/docs/ReadLineParser.html index 4e878a42f..df3b16a34 100644 --- a/docs/ReadLineParser.html +++ b/docs/ReadLineParser.html @@ -22,7 +22,7 @@
@@ -187,7 +187,7 @@

Extends


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/ReadyParser.html b/docs/ReadyParser.html index ce14eb461..6a7a0496b 100644 --- a/docs/ReadyParser.html +++ b/docs/ReadyParser.html @@ -22,7 +22,7 @@
@@ -172,7 +172,7 @@
Parameters:
- +

options for the parser

Properties
@@ -220,7 +220,7 @@
Properties
- +

data to look for before emitted "ready"

@@ -292,7 +292,7 @@

Extends


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/RegexParser.html b/docs/RegexParser.html index f4b19744a..05344f320 100644 --- a/docs/RegexParser.html +++ b/docs/RegexParser.html @@ -22,7 +22,7 @@
@@ -187,7 +187,7 @@

Extends


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/SerialPort.html b/docs/SerialPort.html index b35739ab7..fa2868c8f 100644 --- a/docs/SerialPort.html +++ b/docs/SerialPort.html @@ -22,7 +22,7 @@
@@ -303,7 +303,7 @@
Parameters:
-module:serialport~openOptions +openOptions @@ -336,7 +336,7 @@
Parameters:
-module:serialport~errorCallback +errorCallback @@ -370,13 +370,13 @@
Parameters:
Fires:
@@ -595,7 +595,7 @@

(static) listSource:
@@ -757,7 +757,7 @@
Parameters:
- +

Called with a list of available serial ports.

@@ -806,7 +806,7 @@
Returns:
-

close(callback)

+

close(callback, disconnectError) → {undefined}

@@ -818,7 +818,7 @@

closeSource:
@@ -917,6 +917,29 @@
Parameters:
+ + + + disconnectError + + + + + +Error + + + + + + + + + +

used internally to propagate a disconnect error

+ + + @@ -927,7 +950,7 @@
Parameters:
Fires:
@@ -938,6 +961,24 @@
Fires:
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -945,7 +986,7 @@
Fires:
-

drain(callbackopt)

+

drain(callbackopt) → {undefined}

@@ -957,7 +998,7 @@

drainSource:
@@ -1055,7 +1096,7 @@
Parameters:
-module:serialport~errorCallback +errorCallback @@ -1095,6 +1136,24 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -1102,7 +1161,7 @@
Parameters:
-

flush(callbackopt)

+

flush(callbackopt) → {undefined}

@@ -1114,7 +1173,7 @@

flushSource:
@@ -1200,7 +1259,7 @@
Parameters:
-module:serialport~errorCallback +errorCallback @@ -1240,6 +1299,24 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -1247,7 +1324,7 @@
Parameters:
-

get(callbackopt)

+

get(callbackopt) → {undefined}

@@ -1259,7 +1336,7 @@

getSource:
@@ -1345,7 +1422,7 @@
Parameters:
-module:serialport~modemBitsCallback +modemBitsCallback @@ -1385,6 +1462,24 @@
Parameters:
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -1392,7 +1487,7 @@
Parameters:
-

open(callbackopt)

+

open(openCallbackopt) → {undefined}

@@ -1404,7 +1499,7 @@

openSource:
@@ -1484,13 +1579,13 @@
Parameters:
- callback + openCallback -module:serialport~errorCallback +errorCallback @@ -1524,7 +1619,7 @@
Parameters:
Fires:
@@ -1535,6 +1630,24 @@
Fires:
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -1542,7 +1655,7 @@
Fires:
-

set(optionsopt, callbackopt)

+

pause()

@@ -1554,7 +1667,7 @@

setSource:
@@ -1587,6 +1700,13 @@

setSee: +
+
    +
  • resume
  • +
+
@@ -1597,7 +1717,7 @@

set -

Set control flags on an open port. Uses SetCommMask.aspx) for Windows and ioctl for OS X and Linux.

+

The pause() method causes a stream in flowing mode to stop emitting 'data' events, switching out of flowing mode. Any data that becomes available remains in the internal buffer.

@@ -1610,62 +1730,105 @@

set - - - - Name - - Type - - Attributes - + + + + + + + + + +
Returns:
+
+

this

+
+ - Description - - - - - - options - - + - -object + - - +

read(sizeopt) → {string|Buffer|null}

- - - - <optional>
- + - - - - - -

All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. If options isn't provided default options is used.

-
Properties
- +
+ + +
Source:
+
+ + + + + +
Since:
+
  • 5.0.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Request a number of bytes from the SerialPort. The read() method pulls some data out of the internal buffer and returns it. If no data is available to be read, null is returned. By default, the data is returned as a Buffer object unless an encoding has been specified using the .setEncoding() method.

+
+ + + + + + + + + + + +
Parameters:
+ @@ -1681,8 +1844,6 @@
Properties
- - @@ -1693,13 +1854,13 @@
Properties
- + - - + + +
DefaultDescription
brksize -Boolean +number @@ -1718,105 +1879,689 @@
Properties
-
- - false - -

Specify how many bytes of data to return, if available

- - - cts - - - - -Boolean - - - - - - <optional>
+ + + + + + + + + +
Returns:
+ + +
+

The data from internal buffers

+
+ + + +
+
+ Type +
+
+ +string +| + +Buffer +| + +null + + +
+
+ + + + + + + + + +

resume()

+ + + + + + +
+ + +
Source:
+
+ + + + + +
Since:
+
  • 5.0.0
+ + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+
    +
  • pause
  • +
+
+ + + +
+ + + + + +
+

The resume() method causes an explicitly paused, Readable stream to resume emitting 'data' events, switching the stream into flowing mode.

+
+ + + + + + + + + + + + + + + + + + + + + + + +
Returns:
+ + +
+

this

+
+ + + + + + + + + + + +

set(optionsopt, callbackopt) → {undefined}

+ + + + + + +
+ + +
Source:
+
+ + + + + +
Since:
+
  • 5.0.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Set control flags on an open port. Uses SetCommMask.aspx) for Windows and ioctl for OS X and Linux.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
options + + +object + + + + + + <optional>
+ + + + + +

All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. If options isn't provided default options is used.

+
Properties
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDefaultDescription
brk + + +Boolean + + + + + + <optional>
+ + + + + +
+ + false + +

sets the brk flag

cts + + +Boolean + + + + + + <optional>
+ + + + + +
+ + false + +

sets the cts flag

dsr + + +Boolean + + + + + + <optional>
+ + + + + +
+ + false + +

sets the dsr flag

dtr + + +Boolean + + + + + + <optional>
+ + + + + +
+ + true + +

sets the dtr flag

rts + + +Boolean + + + + + + <optional>
+ + + + + +
+ + true + +

sets the rts flag

+ +
callback + + +errorCallback + + + + + + <optional>
+ + + + +

Called once the port's flags have been set.

+ + + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +undefined - - - - +
+
- - - - false - - + + + + - - + + +

update(optionsopt, callbackopt) → {undefined}

- - - dsr - - - - -Boolean - - +
- - - - <optional>
- + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Changes the baud rate for an open port. Throws if you provide a bad argument. Emits an error or calls the callback if the baud rate isn't supported.

+
- - - - - - - - false - - - - - + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + - + - - - +
NameTypeAttributesDescription
dtroptions -Boolean +object @@ -1835,27 +2580,42 @@
Properties
-
- - true + +

Only supports baudRate.

+
Properties
-
+ + + + + + + + + + + + + + + + + + - + - - + @@ -1901,7 +2655,7 @@
Properties
+ @@ -1941,6 +2695,24 @@
Properties
+
Returns:
+ + + + +
+
+ Type +
+
+ +undefined + + +
+
+ + @@ -1948,7 +2720,7 @@
Properties
-

update(optionsopt, callbackopt)

+

write(data, encodingopt, callbackopt) → {boolean}

@@ -1960,13 +2732,16 @@

updateSource:
+
Since:
+
  • 5.0.0
+ @@ -2000,7 +2775,15 @@

update -

Changes the baud rate for an open port. Throws if you provide a bad argument. Emits an error or calls the callback if the baud rate isn't supported.

+

Writes data to the given serial port. Buffers written data if the port is not open.

+

The write operation is non-blocking. When it returns, data might still not have been written to the serial port. See drain().

+

Some devices, like the Arduino, reset when you open a connection to them. In such cases, immediately writing to the device will cause lost data as they wont be ready to receive the data. This is often worked around by having the Arduino send a "ready" byte that your Node program waits for before writing. You can also often get away with waiting around 400ms.

+

If a port is disconnected during a write, the write will error in addition to the close event.

+

From the stream docs write errors don't always provide the error in the callback, sometimes they use the error event.

+
+

If an error occurs, the callback may or may not be called with the error as its first argument. To reliably detect write errors, add a listener for the 'error' event.

+
+

In addition to the usual stream.write arguments (String and Buffer), write() can accept arrays of bytes (positive numbers under 256) which is passed to Buffer.from([]) for conversion. This extra functionality is pretty sweet.

@@ -2040,13 +2823,19 @@
Parameters:

- + + @@ -2140,7 +2899,7 @@
Properties
+ @@ -2180,6 +2939,28 @@
Properties
+
Returns:
+ + +
+

false if the stream wishes for the calling code to wait for the 'drain' event to be emitted before continuing to write additional data; otherwise true.

+
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + @@ -2200,7 +2981,7 @@
Properties

- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/bindings_base.js.html b/docs/bindings_base.js.html index f59aa45b7..a59a6e376 100644 --- a/docs/bindings_base.js.html +++ b/docs/bindings_base.js.html @@ -22,7 +22,7 @@
@@ -55,7 +55,7 @@

bindings/base.js

/** * You never have to use `Binding` objects directly. SerialPort uses them to access the underlying hardware. This documentation is geared towards people who are making bindings for different platforms. This class can be inherited from to get type checking for each method. * @class BaseBinding - * @param {object} options + * @param {object} options options for the biding * @property {boolean} isOpen Required property. `true` if the port is open, `false` otherwise. Should be read-only. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. * @since 5.0.0 @@ -78,8 +78,8 @@

bindings/base.js

/** * Opens a connection to the serial port referenced by the path. - * @param {string} path - * @param {module:serialport~openOptions} openOptions + * @param {string} path the path or com port to open + * @param {openOptions} options openOptions for the serialport * @returns {Promise} Resolves after the port is opened and configured. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. */ @@ -117,7 +117,7 @@

bindings/base.js

The in progress reads must error when the port is closed with an error object that has the property `canceled` equal to `true`. Any other error will cause a disconnection. - * @param {buffer} data Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. + * @param {buffer} buffer Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. * @param {integer} offset The offset in the buffer to start writing at. * @param {integer} length Specifies the maximum number of bytes to read. * @returns {Promise} Resolves with the number of bytes read after a read operation. @@ -152,7 +152,7 @@

bindings/base.js

The in progress writes must error when the port is closed with an error object that has the property `canceled` equal to `true`. Any other error will cause a disconnection. - * @param {buffer} data - Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. + * @param {buffer} buffer - Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. * @returns {Promise} Resolves after the data is passed to the operating system for writing. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. */ @@ -194,11 +194,11 @@

bindings/base.js

/** * Set control flags on an open port. * @param {object=} options All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. All options are always provided. - * @param {Boolean} [options.brk=false] - * @param {Boolean} [options.cts=false] - * @param {Boolean} [options.dsr=false] - * @param {Boolean} [options.dtr=true] - * @param {Boolean} [options.rts=true] + * @param {Boolean} [options.brk=false] flag for brk + * @param {Boolean} [options.cts=false] flag for cts + * @param {Boolean} [options.dsr=false] flag for dsr + * @param {Boolean} [options.dtr=true] flag for dtr + * @param {Boolean} [options.rts=true] flag for rts * @returns {Promise} Resolves once the port's flags are set. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. */ @@ -280,7 +280,7 @@

bindings/base.js


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/bindings_poller.js.html b/docs/bindings_poller.js.html index e5880016b..81a5505de 100644 --- a/docs/bindings_poller.js.html +++ b/docs/bindings_poller.js.html @@ -22,7 +22,7 @@
@@ -43,10 +43,6 @@

bindings/poller.js

const EventEmitter = require('events'); const FDPoller = require('bindings')('serialport.node').Poller; -/** - * Enum of event values - * @enum {int} - */ const EVENTS = { UV_READABLE: 1, UV_WRITABLE: 2, @@ -86,8 +82,8 @@

bindings/poller.js

} /** * Wait for the next event to occur - * @param {string} Event ('readable'|'writable'|'disconnect') - * @param {function} callback + * @param {string} event ('readable'|'writable'|'disconnect') + * @returns {Poller} returns itself */ once(event) { switch (event) { @@ -105,8 +101,9 @@

bindings/poller.js

} /** - * Ask the bindings to listen for an event - * @param {EVENTS} eventFlag + * Ask the bindings to listen for an event, it is recommend to use `.once()` for easy use + * @param {EVENTS} eventFlag polls for an event or group of events based upon a flag. + * @returns {undefined} */ poll(eventFlag) { eventFlag = eventFlag || 0; @@ -126,6 +123,7 @@

bindings/poller.js

/** * Stop listening for events and cancel all outstanding listening with an error + * @returns {undefined} */ stop() { logger('Stopping poller'); @@ -153,7 +151,7 @@

bindings/poller.js


- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/global.html b/docs/global.html index dd977957f..a83adcf3e 100644 --- a/docs/global.html +++ b/docs/global.html @@ -22,7 +22,7 @@
@@ -106,181 +106,6 @@

-

Members

- - - -

(constant) EVENTS :int

- - - - - -
- - -
Source:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
Properties:
- - - -
NameTypeAttributesDescription
rtsbaudRate -Boolean +number @@ -1874,14 +2634,8 @@
Properties
-
- - true - -

The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200. Custom rates are supported best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate.

-module:serialport~errorCallback +errorCallback @@ -1921,7 +2675,7 @@
Properties
-

Called once the port's flags have been set.

Called once the port's baud rate changes. If .update is called without a callback, and there is an error, an error event is emitted.

optionsdata -object +string +| + +array +| + +buffer @@ -2055,8 +2844,6 @@
Parameters:
- <optional>
- @@ -2066,41 +2853,20 @@
Parameters:
-

Only supports baudRate.

-
Properties
- - - - - - - - - - - - - - - - - - - - + + - - + - - - - -
NameTypeAttributesDescription

Accepts a Buffer object, or a type that is accepted by the Buffer constructor (e.g. an array of bytes or a string).

baudRateencoding -number +string @@ -2120,14 +2886,7 @@
Properties
-

The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200. Custom rates are supported best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate.

- -

The encoding, if chunk is a string. Defaults to 'utf8'. Also accepts 'ascii', 'base64', 'binary', and 'hex' See Buffers and Character Encodings for all available options.

-module:serialport~errorCallback +function @@ -2160,7 +2919,7 @@
Properties
-

Called once the port's baud rate changes. If .update is called without a callback, and there is an error, an error event is emitted.

Called once the write operation finishes. Data may not yet be flushed to the underlying port. No arguments.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
UV_READABLE - - -int - - - -
UV_WRITABLE - - -int - - - -
UV_DISCONNECT - - -int - - - -
- - - - - - -
-

Enum of event values

-
- - - -
Type:
-
    -
  • - -int - - -
  • -
- - - - - - - - @@ -449,7 +274,7 @@

listCallb
Source:
@@ -1461,7 +1286,7 @@

Properties:
-module:serialport~Binding +Binding @@ -1849,6 +1674,346 @@
Example
+ +

Events

+ + + + + + +

close

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

The close event's callback is called with no arguments when the port is closed. In the case of a disconnect it will be called with a Disconnect Error object (err.disconnected == true). In the event of a close error (unlikely), an error event is triggered.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

data

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Listening for the data event puts the port in flowing mode. Data is emitted as soon as it's received. Data is a Buffer object with a varying amount of data in it. The readLine parser converts the data into string lines. See the parsers section for more information on parsers, and the Node.js stream documentation for more information on the data event.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

error

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

The error event's callback is called with an error object whenever there is an error.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

open

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

The open event's callback is called with no arguments when the port is opened and ready for writing. This happens if you have the constructor open immediately (which opens in the next tick) or if you open the port manually with open(). See Useage/Opening a Port for more information.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1862,7 +2027,7 @@
Example

- Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
diff --git a/docs/index.html b/docs/index.html index 8f1f421dc..dd26ff110 100644 --- a/docs/index.html +++ b/docs/index.html @@ -22,7 +22,7 @@
@@ -47,19 +47,19 @@

Home

Classes

  • Node Serialport

    npm
    Gitter chat
    Known Vulnerabilities
    codecov
    Build Status
    Build status
    Greenkeeper badge

    -

    Intro to Node-Serialport

    Imagine a world in which you can write JavaScript to control blenders, lights, security systems, or even robots. That's right—robots! Thanks to Node Serialport, that world is here.

    -

    Node-Serialport provides a stream interface for the low-level serial port code necessary to controll Arduino chipsets, X10 interfaces, Zigbee radios, highway signs, lcd screens, cash drawers, motor controllers, sensor packages, fork lifts, modems, drones, CNC machines, plotters, vending machines, ccTalk coin accecptors, SMS Gateways, RFID scanners and much more. If if you have a hardware device with an UART we can speak to it. The physical world is your oyster with this goodie.

    +

    Intro to Node-Serialport

    Imagine a world where you can write JavaScript to control blenders, lights, security systems, or even robots. That's right—robots! Thanks to Node Serialport, that world is here.

    +

    Node-Serialport provides a stream interface for the low-level serial port code necessary to controll Arduino chipsets, X10 interfaces, Zigbee radios, highway signs, lcd screens, cash drawers, motor controllers, sensor packages, fork lifts, modems, drones, CNC machines, plotters, vending machines, ccTalk coin accecptors, SMS Gateways, RFID scanners and much more. If you have a hardware device with a UART we can speak to it. The physical world is your oyster with this goodie.

    For a full breakdown of why we made Node-Serialport, please read NodeBots - The Rise of JS Robotics. It explains why one would want to program robots in JS in the first place.

    We're not against firmware but we're better than it.

    Quick Answers to Important Questions


    -

    API Documentation

    Can be found at https://doclets.io/node-serialport/node-serialport/

    +

    API Documentation

    Can be found at https://node-serialport.github.io/node-serialport/

    See our changelog for what's new, and our upgrade guide for a walk-through on differences between major versions.

    Older versions are no longer supported but their docs can be found by looking through release tags.

    You can generate the docs by running

    @@ -278,7 +278,8 @@

    sudo / root

    If you're going to use sudo or root to insta make: *** No rule to make target '../.node-gyp/6.9.1/include/node/common.gypi', needed by 'Makefile'. Stop. make: Leaving directory '/usr/lib/node_modules/serialport/build' gyp ERR! build error -gyp ERR! stack Error: `make` failed with exit code: 2

    Ubuntu/Debian Linux

    The best way to install any version of Node.js is to use the NodeSource Node.js binary distributions. Older versions of Ubuntu install Node.js with the wrong version and binary name. If your Node binary is nodejs instead of node, or if your Node version is v0.10.29, then you should follow these instructions.

    +gyp ERR! stack Error: `make` failed with exit code: 2 +

    Ubuntu/Debian Linux

    The best way to install any version of Node.js is to use the NodeSource Node.js binary distributions. Older versions of Ubuntu install Node.js with the wrong version and binary name. If your Node binary is nodejs instead of node, or if your Node version is v0.10.29, then you should follow these instructions.

    You'll need the package build-essential to compile serialport. If there's a binary for your platform, you won't need it. Keep rocking!

    # Using Ubuntu and Node 6
     curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
    @@ -329,7 +330,8 @@ 

    Usage

    Opening a Port

    When disabling the autoOpen option you'll need to open the port on your own.

    +}); +

    When disabling the autoOpen option you'll need to open the port on your own.

    var SerialPort = require('serialport');
     var port = new SerialPort('/dev/tty-usbserial1', { autoOpen: false });
     
    @@ -463,7 +465,7 @@ 

    Serial Port List

    serialport-list will list all available

    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/index.js.html b/docs/index.js.html index 04bef39c0..02b58dc00 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -22,7 +22,7 @@
    @@ -65,7 +65,7 @@

    index.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_byte-length.js.html b/docs/parsers_byte-length.js.html index 8b99c7d0b..9a680ea2e 100644 --- a/docs/parsers_byte-length.js.html +++ b/docs/parsers_byte-length.js.html @@ -22,7 +22,7 @@
    @@ -44,7 +44,7 @@

    parsers/byte-length.js

    /** * A transform stream that emits data as a buffer after a specific number of bytes are received. * @extends Transform - * @param {Object} options + * @param {Object} options parser options object * @param {Number} options.length the number of bytes on each data event * @example To use the `ByteLength` parser: @@ -109,7 +109,7 @@

    parsers/byte-length.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_cctalk.js.html b/docs/parsers_cctalk.js.html index 4f725f9e6..10fcb1cb6 100644 --- a/docs/parsers_cctalk.js.html +++ b/docs/parsers_cctalk.js.html @@ -22,7 +22,7 @@
    @@ -94,7 +94,7 @@

    parsers/cctalk.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_delimiter.js.html b/docs/parsers_delimiter.js.html index b5d1c3482..b2ba81205 100644 --- a/docs/parsers_delimiter.js.html +++ b/docs/parsers_delimiter.js.html @@ -22,7 +22,7 @@
    @@ -102,7 +102,7 @@

    parsers/delimiter.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_index.js.html b/docs/parsers_index.js.html index 6e89298cb..3bf95e112 100644 --- a/docs/parsers_index.js.html +++ b/docs/parsers_index.js.html @@ -22,7 +22,7 @@
    @@ -86,7 +86,7 @@

    parsers/index.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_readline.js.html b/docs/parsers_readline.js.html index fd0b39339..696741178 100644 --- a/docs/parsers_readline.js.html +++ b/docs/parsers_readline.js.html @@ -22,7 +22,7 @@
    @@ -81,7 +81,7 @@

    parsers/readline.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_ready.js.html b/docs/parsers_ready.js.html index 5f0eadc92..0af3d556c 100644 --- a/docs/parsers_ready.js.html +++ b/docs/parsers_ready.js.html @@ -22,7 +22,7 @@
    @@ -57,8 +57,8 @@

    parsers/ready.js

    class ReadyParser extends Transform { /** * - * @param {object} options - * @param {string|Buffer|array} options.delimiter + * @param {object} options options for the parser + * @param {string|Buffer|array} options.delimiter data to look for before emitted "ready" */ constructor(options) { options = options || {}; @@ -116,7 +116,7 @@

    parsers/ready.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/parsers_regex.js.html b/docs/parsers_regex.js.html index 41a8b2435..a3391f78c 100644 --- a/docs/parsers_regex.js.html +++ b/docs/parsers_regex.js.html @@ -22,7 +22,7 @@
    @@ -103,7 +103,7 @@

    parsers/regex.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/docs/serialport.js.html b/docs/serialport.js.html index e57c837c0..008d66518 100644 --- a/docs/serialport.js.html +++ b/docs/serialport.js.html @@ -22,7 +22,7 @@
    @@ -108,7 +108,7 @@

    serialport.js

    * @property {boolean} [xoff=false] flow control setting * @property {boolean} [xany=false] flow control setting * @property {object=} bindingOptions sets binding-specific options - * @property {module:serialport~Binding=} Binding The hardware access binding. `Bindings` are how Node-Serialport talks to the underlying system. By default we auto detect Windows (`WindowsBinding`), Linux (`LinuxBinding`) and OS X (`DarwinBinding`) and load the appropriate module for your system. + * @property {Binding=} Binding The hardware access binding. `Bindings` are how Node-Serialport talks to the underlying system. By default we auto detect Windows (`WindowsBinding`), Linux (`LinuxBinding`) and OS X (`DarwinBinding`) and load the appropriate module for your system. * @property {number} [bindingOptions.vmin=1] see [`man termios`](http://linux.die.net/man/3/termios) LinuxBinding and DarwinBinding * @property {number} [bindingOptions.vtime=0] see [`man termios`](http://linux.die.net/man/3/termios) LinuxBinding and DarwinBinding */ @@ -117,26 +117,26 @@

    serialport.js

    * Create a new serial port object for the `path`. In the case of invalid arguments or invalid options, when constructing a new SerialPort it will throw an error. The port will open automatically by default, which is the equivalent of calling `port.open(openCallback)` in the next tick. You can disable this by setting the option `autoOpen` to `false`. * @class SerialPort * @param {string} path - The system path of the serial port you want to open. For example, `/dev/tty.XXX` on Mac/Linux, or `COM1` on Windows. - * @param {module:serialport~openOptions=} options - Port configuration options - * @param {module:serialport~errorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. The callback will NOT be called if `autoOpen` is set to `false` in the `openOptions` as the open will not be performed. + * @param {openOptions=} options - Port configuration options + * @param {errorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. The callback will NOT be called if `autoOpen` is set to `false` in the `openOptions` as the open will not be performed. * @property {number} baudRate The port's baudRate. Use `.update` to change it. Read-only. * @property {object} binding The binding object backing the port. Read-only. * @property {boolean} isOpen `true` if the port is open, `false` otherwise. Read-only. (`since 5.0.0`) * @property {string} path The system path or name of the serial port. Read-only. * @throws {TypeError} When given invalid arguments, a `TypeError` will be thrown. - * @emits module:serialport#open - * @emits module:serialport#data - * @emits module:serialport#close - * @emits module:serialport#error + * @emits open + * @emits data + * @emits close + * @emits error * @alias module:serialport */ -function SerialPort(path, options, callback) { +function SerialPort(path, options, openCallback) { if (!(this instanceof SerialPort)) { - return new SerialPort(path, options, callback); + return new SerialPort(path, options, openCallback); } if (options instanceof Function) { - callback = options; + openCallback = options; options = {}; } @@ -207,7 +207,7 @@

    serialport.js

    this._kMinPoolSpace = 128; if (this.settings.autoOpen) { - this.open(callback); + this.open(openCallback); } } @@ -230,7 +230,7 @@

    serialport.js

    /** * The `error` event's callback is called with an error object whenever there is an error. - * @event module:serialport#error + * @event error */ SerialPort.prototype._error = function(error, callback) { @@ -247,21 +247,22 @@

    serialport.js

    /** * The `open` event's callback is called with no arguments when the port is opened and ready for writing. This happens if you have the constructor open immediately (which opens in the next tick) or if you open the port manually with `open()`. See [Useage/Opening a Port](#opening-a-port) for more information. - * @event module:serialport#open + * @event open */ /** * Opens a connection to the given serial port. - * @param {module:serialport~errorCallback=} callback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. - * @emits module:serialport#open + * @param {errorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. + * @emits open + * @returns {undefined} */ -SerialPort.prototype.open = function(callback) { +SerialPort.prototype.open = function(openCallback) { if (this.isOpen) { - return this._asyncError(new Error('Port is already open'), callback); + return this._asyncError(new Error('Port is already open'), openCallback); } if (this.opening) { - return this._asyncError(new Error('Port is opening'), callback); + return this._asyncError(new Error('Port is opening'), openCallback); } this.opening = true; @@ -270,11 +271,11 @@

    serialport.js

    debug('opened', `path: ${this.path}`); this.opening = false; this.emit('open'); - if (callback) { callback.call(this, null) } + if (openCallback) { openCallback.call(this, null) } }, (err) => { this.opening = false; debug('Binding #open had an error', err); - this._error(err, callback); + this._error(err, openCallback); }); }; @@ -282,7 +283,8 @@

    serialport.js

    * Changes the baud rate for an open port. Throws if you provide a bad argument. Emits an error or calls the callback if the baud rate isn't supported. * @param {object=} options Only supports `baudRate`. * @param {number=} [options.baudRate] The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200. Custom rates are supported best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate. - * @param {module:serialport~errorCallback=} [callback] Called once the port's baud rate changes. If `.update` is called without a callback, and there is an error, an error event is emitted. + * @param {errorCallback=} [callback] Called once the port's baud rate changes. If `.update` is called without a callback, and there is an error, an error event is emitted. + * @returns {undefined} */ SerialPort.prototype.update = function(options, callback) { if (typeof options !== 'object') { @@ -320,7 +322,7 @@

    serialport.js

    > If an error occurs, the callback may or may not be called with the error as its first argument. To reliably detect write errors, add a listener for the 'error' event. In addition to the usual `stream.write` arguments (`String` and `Buffer`), `write()` can accept arrays of bytes (positive numbers under 256) which is passed to `Buffer.from([])` for conversion. This extra functionality is pretty sweet. - * @method module:serialport#write + * @method SerialPort.prototype.write * @param {(string|array|buffer)} data Accepts a [`Buffer` ](http://nodejs.org/api/buffer.html) object, or a type that is accepted by the `Buffer` constructor (e.g. an array of bytes or a string). * @param {string=} encoding The encoding, if chunk is a string. Defaults to `'utf8'`. Also accepts `'ascii'`, `'base64'`, `'binary'`, and `'hex'` See [Buffers and Character Encodings](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) for all available options. * @param {function=} callback Called once the write operation finishes. Data may not yet be flushed to the underlying port. No arguments. @@ -364,15 +366,15 @@

    serialport.js

    /** * Request a number of bytes from the SerialPort. The `read()` method pulls some data out of the internal buffer and returns it. If no data is available to be read, null is returned. By default, the data is returned as a `Buffer` object unless an encoding has been specified using the `.setEncoding()` method. - * @method module:serialport#read + * @method SerialPort.prototype.read * @param {number=} size Specify how many bytes of data to return, if available * @returns {(string|Buffer|null)} The data from internal buffers * @since 5.0.0 */ /** - * The `data` event puts the port in flowing mode. Data is emitted as soon as it's received. Data is a `Buffer` object with a varying amount of data in it. The `readLine` parser converts the data into string lines. See the [parsers](#module_serialport--SerialPort.parsers) section for more information on parsers, and the [Node.js stream documentation](https://nodejs.org/api/stream.html#stream_event_data) for more information on the data event. - * @event module:serialport#data + * Listening for the `data` event puts the port in flowing mode. Data is emitted as soon as it's received. Data is a `Buffer` object with a varying amount of data in it. The `readLine` parser converts the data into string lines. See the [parsers](#module_serialport--SerialPort.parsers) section for more information on parsers, and the [Node.js stream documentation](https://nodejs.org/api/stream.html#stream_event_data) for more information on the data event. + * @event data */ SerialPort.prototype._read = function(bytesToRead) { @@ -430,15 +432,17 @@

    serialport.js

    /** * The `close` event's callback is called with no arguments when the port is closed. In the case of a disconnect it will be called with a Disconnect Error object (`err.disconnected == true`). In the event of a close error (unlikely), an error event is triggered. - * @event module:serialport#close + * @event close */ /** * Closes an open connection. * * If there are in progress writes when the port is closed the writes will error. - * @param {errorCallback} callback Called once a connection is closed. - * @emits module:serialport#close + * @param {errorCallback} callback Called once a connection is closed. + * @param {Error} disconnectError used internally to propagate a disconnect error + * @emits close + * @returns {undefined} */ SerialPort.prototype.close = function(callback, disconnectError) { disconnectError = disconnectError || null; @@ -465,13 +469,14 @@

    serialport.js

    /** * Set control flags on an open port. Uses [`SetCommMask`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363257(v=vs.85).aspx) for Windows and [`ioctl`](http://linux.die.net/man/4/tty_ioctl) for OS X and Linux. * @param {object=} options All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. If options isn't provided default options is used. - * @param {Boolean} [options.brk=false] - * @param {Boolean} [options.cts=false] - * @param {Boolean} [options.dsr=false] - * @param {Boolean} [options.dtr=true] - * @param {Boolean} [options.rts=true] - * @param {module:serialport~errorCallback=} callback Called once the port's flags have been set. + * @param {Boolean} [options.brk=false] sets the brk flag + * @param {Boolean} [options.cts=false] sets the cts flag + * @param {Boolean} [options.dsr=false] sets the dsr flag + * @param {Boolean} [options.dtr=true] sets the dtr flag + * @param {Boolean} [options.rts=true] sets the rts flag + * @param {errorCallback=} callback Called once the port's flags have been set. * @since 5.0.0 + * @returns {undefined} */ SerialPort.prototype.set = function(options, callback) { if (typeof options !== 'object') { @@ -497,7 +502,8 @@

    serialport.js

    /** * Returns the control flags (CTS, DSR, DCD) on the open port. * Uses [`GetCommModemStatus`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363258(v=vs.85).aspx) for Windows and [`ioctl`](http://linux.die.net/man/4/tty_ioctl) for mac and linux. - * @param {module:serialport~modemBitsCallback=} callback Called once the modem bits are retrieved. + * @param {modemBitsCallback=} callback Called once the modem bits are retrieved. + * @returns {undefined} */ SerialPort.prototype.get = function(callback) { if (!this.isOpen) { @@ -517,7 +523,8 @@

    serialport.js

    /** * Flush discards data received but not read, and written but not transmitted by the operating system. For more technical details, see [`tcflush(fd, TCIOFLUSH)`](http://linux.die.net/man/3/tcflush) for Mac/Linux and [`FlushFileBuffers`](http://msdn.microsoft.com/en-us/library/windows/desktop/aa364439) for Windows. - * @param {module:serialport~errorCallback=} callback Called once the flush operation finishes. + * @param {errorCallback=} callback Called once the flush operation finishes. + * @returns {undefined} */ SerialPort.prototype.flush = function(callback) { if (!this.isOpen) { @@ -537,7 +544,8 @@

    serialport.js

    /** * Waits until all output data is transmitted to the serial port. After any pending write has completed it calls [`tcdrain()`](http://linux.die.net/man/3/tcdrain) or [FlushFileBuffers()](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364439(v=vs.85).aspx) to ensure it has been written to the device. - * @param {module:serialport~errorCallback=} callback Called once the drain operation returns. + * @param {errorCallback=} callback Called once the drain operation returns. + * @returns {undefined} * @example Write the `data` and wait until it has finished transmitting to the target serial port before calling the callback. This will queue until the port is open and writes are finished. @@ -567,16 +575,16 @@

    serialport.js

    /** * The `pause()` method causes a stream in flowing mode to stop emitting 'data' events, switching out of flowing mode. Any data that becomes available remains in the internal buffer. - * @method module:serialport#pause - * @see module:serialport#resume + * @method SerialPort.prototype.pause + * @see resume * @since 5.0.0 * @returns `this` */ /** * The `resume()` method causes an explicitly paused, `Readable` stream to resume emitting 'data' events, switching the stream into flowing mode. - * @method module:serialport#resume - * @see module:serialport#pause + * @method SerialPort.prototype.resume + * @see pause * @since 5.0.0 * @returns `this` */ @@ -593,7 +601,7 @@

    serialport.js

    * * We make an effort to identify the hardware attached and have consistent results between systems. Linux and OS X are mostly consistent. Windows relies on 3rd party device drivers for the information and is unable to guarantee the information. On windows If you have a USB connected device can we provide a serial number otherwise it will be `undefined`. The `pnpId` and `locationId` are not the same or present on all systems. The examples below were run with the same Arduino Uno. * @type {function} - * @param {listCallback=} callback + * @param {listCallback=} callback Called with a list of available serial ports. * @returns {Promise} Resolves with the list of available serial ports. * @example ```js @@ -648,16 +656,16 @@

    serialport.js

    .catch(err) {...}); ``` */ -SerialPort.list = function(cb) { +SerialPort.list = function(callback) { if (!SerialPort.Binding) { throw new TypeError('No Binding set on `SerialPort.Binding`'); } debug('.list'); const promise = SerialPort.Binding.list(); - if (typeof cb === 'function') { + if (typeof callback === 'function') { promise.then( - ports => cb(null, ports), - err => cb(err) + ports => callback(null, ports), + err => callback(err) ); } return promise; @@ -676,7 +684,7 @@

    serialport.js


    - Documentation generated by JSDoc 3.5.5 on Thu Feb 15 2018 16:36:25 GMT-0500 (EST) using the docdash theme. + Documentation generated by JSDoc 3.5.5 on Tue Feb 27 2018 22:46:41 GMT-0500 (EST) using the docdash theme.
    diff --git a/lib/bindings/base.js b/lib/bindings/base.js index 39fa81a74..60419e923 100644 --- a/lib/bindings/base.js +++ b/lib/bindings/base.js @@ -16,7 +16,7 @@ const debug = require('debug')('serialport:bindings'); /** * You never have to use `Binding` objects directly. SerialPort uses them to access the underlying hardware. This documentation is geared towards people who are making bindings for different platforms. This class can be inherited from to get type checking for each method. * @class BaseBinding - * @param {object} options + * @param {object} options options for the biding * @property {boolean} isOpen Required property. `true` if the port is open, `false` otherwise. Should be read-only. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. * @since 5.0.0 @@ -39,8 +39,8 @@ class BaseBinding { /** * Opens a connection to the serial port referenced by the path. - * @param {string} path - * @param {module:serialport~openOptions} openOptions + * @param {string} path the path or com port to open + * @param {openOptions} options openOptions for the serialport * @returns {Promise} Resolves after the port is opened and configured. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. */ @@ -78,7 +78,7 @@ class BaseBinding { The in progress reads must error when the port is closed with an error object that has the property `canceled` equal to `true`. Any other error will cause a disconnection. - * @param {buffer} data Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. + * @param {buffer} buffer Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. * @param {integer} offset The offset in the buffer to start writing at. * @param {integer} length Specifies the maximum number of bytes to read. * @returns {Promise} Resolves with the number of bytes read after a read operation. @@ -113,7 +113,7 @@ The in progress reads must error when the port is closed with an error object th The in progress writes must error when the port is closed with an error object that has the property `canceled` equal to `true`. Any other error will cause a disconnection. - * @param {buffer} data - Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. + * @param {buffer} buffer - Accepts a [`Buffer`](http://nodejs.org/api/buffer.html) object. * @returns {Promise} Resolves after the data is passed to the operating system for writing. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. */ @@ -155,11 +155,11 @@ The in progress writes must error when the port is closed with an error object t /** * Set control flags on an open port. * @param {object=} options All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. All options are always provided. - * @param {Boolean} [options.brk=false] - * @param {Boolean} [options.cts=false] - * @param {Boolean} [options.dsr=false] - * @param {Boolean} [options.dtr=true] - * @param {Boolean} [options.rts=true] + * @param {Boolean} [options.brk=false] flag for brk + * @param {Boolean} [options.cts=false] flag for cts + * @param {Boolean} [options.dsr=false] flag for dsr + * @param {Boolean} [options.dtr=true] flag for dtr + * @param {Boolean} [options.rts=true] flag for rts * @returns {Promise} Resolves once the port's flags are set. * @throws {TypeError} When given invalid arguments, a `TypeError` is thrown. */ diff --git a/lib/bindings/poller.js b/lib/bindings/poller.js index 5ea8bf918..9bba0c2df 100644 --- a/lib/bindings/poller.js +++ b/lib/bindings/poller.js @@ -4,10 +4,6 @@ const logger = debug('serialport:poller'); const EventEmitter = require('events'); const FDPoller = require('bindings')('serialport.node').Poller; -/** - * Enum of event values - * @enum {int} - */ const EVENTS = { UV_READABLE: 1, UV_WRITABLE: 2, @@ -47,8 +43,8 @@ class Poller extends EventEmitter { } /** * Wait for the next event to occur - * @param {string} Event ('readable'|'writable'|'disconnect') - * @param {function} callback + * @param {string} event ('readable'|'writable'|'disconnect') + * @returns {Poller} returns itself */ once(event) { switch (event) { @@ -66,8 +62,9 @@ class Poller extends EventEmitter { } /** - * Ask the bindings to listen for an event - * @param {EVENTS} eventFlag + * Ask the bindings to listen for an event, it is recommend to use `.once()` for easy use + * @param {EVENTS} eventFlag polls for an event or group of events based upon a flag. + * @returns {undefined} */ poll(eventFlag) { eventFlag = eventFlag || 0; @@ -87,6 +84,7 @@ class Poller extends EventEmitter { /** * Stop listening for events and cancel all outstanding listening with an error + * @returns {undefined} */ stop() { logger('Stopping poller'); diff --git a/lib/parsers/byte-length.js b/lib/parsers/byte-length.js index 4cd0ced21..cd7cb5017 100644 --- a/lib/parsers/byte-length.js +++ b/lib/parsers/byte-length.js @@ -5,7 +5,7 @@ const Transform = require('stream').Transform; /** * A transform stream that emits data as a buffer after a specific number of bytes are received. * @extends Transform - * @param {Object} options + * @param {Object} options parser options object * @param {Number} options.length the number of bytes on each data event * @example To use the `ByteLength` parser: diff --git a/lib/parsers/ready.js b/lib/parsers/ready.js index b0a6f32b4..c953ba7b5 100644 --- a/lib/parsers/ready.js +++ b/lib/parsers/ready.js @@ -18,8 +18,8 @@ parser.on('data', console.log); // all data after READY is received class ReadyParser extends Transform { /** * - * @param {object} options - * @param {string|Buffer|array} options.delimiter + * @param {object} options options for the parser + * @param {string|Buffer|array} options.delimiter data to look for before emitted "ready" */ constructor(options) { options = options || {}; diff --git a/lib/serialport.js b/lib/serialport.js index 695e80462..acffaa9ee 100644 --- a/lib/serialport.js +++ b/lib/serialport.js @@ -69,7 +69,7 @@ function allocNewReadPool(poolSize) { * @property {boolean} [xoff=false] flow control setting * @property {boolean} [xany=false] flow control setting * @property {object=} bindingOptions sets binding-specific options - * @property {module:serialport~Binding=} Binding The hardware access binding. `Bindings` are how Node-Serialport talks to the underlying system. By default we auto detect Windows (`WindowsBinding`), Linux (`LinuxBinding`) and OS X (`DarwinBinding`) and load the appropriate module for your system. + * @property {Binding=} Binding The hardware access binding. `Bindings` are how Node-Serialport talks to the underlying system. By default we auto detect Windows (`WindowsBinding`), Linux (`LinuxBinding`) and OS X (`DarwinBinding`) and load the appropriate module for your system. * @property {number} [bindingOptions.vmin=1] see [`man termios`](http://linux.die.net/man/3/termios) LinuxBinding and DarwinBinding * @property {number} [bindingOptions.vtime=0] see [`man termios`](http://linux.die.net/man/3/termios) LinuxBinding and DarwinBinding */ @@ -78,26 +78,26 @@ function allocNewReadPool(poolSize) { * Create a new serial port object for the `path`. In the case of invalid arguments or invalid options, when constructing a new SerialPort it will throw an error. The port will open automatically by default, which is the equivalent of calling `port.open(openCallback)` in the next tick. You can disable this by setting the option `autoOpen` to `false`. * @class SerialPort * @param {string} path - The system path of the serial port you want to open. For example, `/dev/tty.XXX` on Mac/Linux, or `COM1` on Windows. - * @param {module:serialport~openOptions=} options - Port configuration options - * @param {module:serialport~errorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. The callback will NOT be called if `autoOpen` is set to `false` in the `openOptions` as the open will not be performed. + * @param {openOptions=} options - Port configuration options + * @param {errorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. The callback will NOT be called if `autoOpen` is set to `false` in the `openOptions` as the open will not be performed. * @property {number} baudRate The port's baudRate. Use `.update` to change it. Read-only. * @property {object} binding The binding object backing the port. Read-only. * @property {boolean} isOpen `true` if the port is open, `false` otherwise. Read-only. (`since 5.0.0`) * @property {string} path The system path or name of the serial port. Read-only. * @throws {TypeError} When given invalid arguments, a `TypeError` will be thrown. - * @emits module:serialport#open - * @emits module:serialport#data - * @emits module:serialport#close - * @emits module:serialport#error + * @emits open + * @emits data + * @emits close + * @emits error * @alias module:serialport */ -function SerialPort(path, options, callback) { +function SerialPort(path, options, openCallback) { if (!(this instanceof SerialPort)) { - return new SerialPort(path, options, callback); + return new SerialPort(path, options, openCallback); } if (options instanceof Function) { - callback = options; + openCallback = options; options = {}; } @@ -168,7 +168,7 @@ function SerialPort(path, options, callback) { this._kMinPoolSpace = 128; if (this.settings.autoOpen) { - this.open(callback); + this.open(openCallback); } } @@ -191,7 +191,7 @@ Object.defineProperties(SerialPort.prototype, { /** * The `error` event's callback is called with an error object whenever there is an error. - * @event module:serialport#error + * @event error */ SerialPort.prototype._error = function(error, callback) { @@ -208,21 +208,22 @@ SerialPort.prototype._asyncError = function(error, callback) { /** * The `open` event's callback is called with no arguments when the port is opened and ready for writing. This happens if you have the constructor open immediately (which opens in the next tick) or if you open the port manually with `open()`. See [Useage/Opening a Port](#opening-a-port) for more information. - * @event module:serialport#open + * @event open */ /** * Opens a connection to the given serial port. - * @param {module:serialport~errorCallback=} callback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. - * @emits module:serialport#open + * @param {errorCallback=} openCallback - Called after a connection is opened. If this is not provided and an error occurs, it will be emitted on the port's `error` event. + * @emits open + * @returns {undefined} */ -SerialPort.prototype.open = function(callback) { +SerialPort.prototype.open = function(openCallback) { if (this.isOpen) { - return this._asyncError(new Error('Port is already open'), callback); + return this._asyncError(new Error('Port is already open'), openCallback); } if (this.opening) { - return this._asyncError(new Error('Port is opening'), callback); + return this._asyncError(new Error('Port is opening'), openCallback); } this.opening = true; @@ -231,11 +232,11 @@ SerialPort.prototype.open = function(callback) { debug('opened', `path: ${this.path}`); this.opening = false; this.emit('open'); - if (callback) { callback.call(this, null) } + if (openCallback) { openCallback.call(this, null) } }, (err) => { this.opening = false; debug('Binding #open had an error', err); - this._error(err, callback); + this._error(err, openCallback); }); }; @@ -243,7 +244,8 @@ SerialPort.prototype.open = function(callback) { * Changes the baud rate for an open port. Throws if you provide a bad argument. Emits an error or calls the callback if the baud rate isn't supported. * @param {object=} options Only supports `baudRate`. * @param {number=} [options.baudRate] The baud rate of the port to be opened. This should match one of the commonly available baud rates, such as 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, or 115200. Custom rates are supported best effort per platform. The device connected to the serial port is not guaranteed to support the requested baud rate, even if the port itself supports that baud rate. - * @param {module:serialport~errorCallback=} [callback] Called once the port's baud rate changes. If `.update` is called without a callback, and there is an error, an error event is emitted. + * @param {errorCallback=} [callback] Called once the port's baud rate changes. If `.update` is called without a callback, and there is an error, an error event is emitted. + * @returns {undefined} */ SerialPort.prototype.update = function(options, callback) { if (typeof options !== 'object') { @@ -281,7 +283,7 @@ From the [stream docs](https://nodejs.org/api/stream.html#stream_writable_write_ > If an error occurs, the callback may or may not be called with the error as its first argument. To reliably detect write errors, add a listener for the 'error' event. In addition to the usual `stream.write` arguments (`String` and `Buffer`), `write()` can accept arrays of bytes (positive numbers under 256) which is passed to `Buffer.from([])` for conversion. This extra functionality is pretty sweet. - * @method module:serialport#write + * @method SerialPort.prototype.write * @param {(string|array|buffer)} data Accepts a [`Buffer` ](http://nodejs.org/api/buffer.html) object, or a type that is accepted by the `Buffer` constructor (e.g. an array of bytes or a string). * @param {string=} encoding The encoding, if chunk is a string. Defaults to `'utf8'`. Also accepts `'ascii'`, `'base64'`, `'binary'`, and `'hex'` See [Buffers and Character Encodings](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) for all available options. * @param {function=} callback Called once the write operation finishes. Data may not yet be flushed to the underlying port. No arguments. @@ -325,15 +327,15 @@ SerialPort.prototype._writev = function(data, callback) { /** * Request a number of bytes from the SerialPort. The `read()` method pulls some data out of the internal buffer and returns it. If no data is available to be read, null is returned. By default, the data is returned as a `Buffer` object unless an encoding has been specified using the `.setEncoding()` method. - * @method module:serialport#read + * @method SerialPort.prototype.read * @param {number=} size Specify how many bytes of data to return, if available * @returns {(string|Buffer|null)} The data from internal buffers * @since 5.0.0 */ /** - * The `data` event puts the port in flowing mode. Data is emitted as soon as it's received. Data is a `Buffer` object with a varying amount of data in it. The `readLine` parser converts the data into string lines. See the [parsers](#module_serialport--SerialPort.parsers) section for more information on parsers, and the [Node.js stream documentation](https://nodejs.org/api/stream.html#stream_event_data) for more information on the data event. - * @event module:serialport#data + * Listening for the `data` event puts the port in flowing mode. Data is emitted as soon as it's received. Data is a `Buffer` object with a varying amount of data in it. The `readLine` parser converts the data into string lines. See the [parsers](#module_serialport--SerialPort.parsers) section for more information on parsers, and the [Node.js stream documentation](https://nodejs.org/api/stream.html#stream_event_data) for more information on the data event. + * @event data */ SerialPort.prototype._read = function(bytesToRead) { @@ -391,15 +393,17 @@ SerialPort.prototype._disconnected = function(err) { /** * The `close` event's callback is called with no arguments when the port is closed. In the case of a disconnect it will be called with a Disconnect Error object (`err.disconnected == true`). In the event of a close error (unlikely), an error event is triggered. - * @event module:serialport#close + * @event close */ /** * Closes an open connection. * * If there are in progress writes when the port is closed the writes will error. - * @param {errorCallback} callback Called once a connection is closed. - * @emits module:serialport#close + * @param {errorCallback} callback Called once a connection is closed. + * @param {Error} disconnectError used internally to propagate a disconnect error + * @emits close + * @returns {undefined} */ SerialPort.prototype.close = function(callback, disconnectError) { disconnectError = disconnectError || null; @@ -426,13 +430,14 @@ SerialPort.prototype.close = function(callback, disconnectError) { /** * Set control flags on an open port. Uses [`SetCommMask`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363257(v=vs.85).aspx) for Windows and [`ioctl`](http://linux.die.net/man/4/tty_ioctl) for OS X and Linux. * @param {object=} options All options are operating system default when the port is opened. Every flag is set on each call to the provided or default values. If options isn't provided default options is used. - * @param {Boolean} [options.brk=false] - * @param {Boolean} [options.cts=false] - * @param {Boolean} [options.dsr=false] - * @param {Boolean} [options.dtr=true] - * @param {Boolean} [options.rts=true] - * @param {module:serialport~errorCallback=} callback Called once the port's flags have been set. + * @param {Boolean} [options.brk=false] sets the brk flag + * @param {Boolean} [options.cts=false] sets the cts flag + * @param {Boolean} [options.dsr=false] sets the dsr flag + * @param {Boolean} [options.dtr=true] sets the dtr flag + * @param {Boolean} [options.rts=true] sets the rts flag + * @param {errorCallback=} callback Called once the port's flags have been set. * @since 5.0.0 + * @returns {undefined} */ SerialPort.prototype.set = function(options, callback) { if (typeof options !== 'object') { @@ -458,7 +463,8 @@ SerialPort.prototype.set = function(options, callback) { /** * Returns the control flags (CTS, DSR, DCD) on the open port. * Uses [`GetCommModemStatus`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363258(v=vs.85).aspx) for Windows and [`ioctl`](http://linux.die.net/man/4/tty_ioctl) for mac and linux. - * @param {module:serialport~modemBitsCallback=} callback Called once the modem bits are retrieved. + * @param {modemBitsCallback=} callback Called once the modem bits are retrieved. + * @returns {undefined} */ SerialPort.prototype.get = function(callback) { if (!this.isOpen) { @@ -478,7 +484,8 @@ SerialPort.prototype.get = function(callback) { /** * Flush discards data received but not read, and written but not transmitted by the operating system. For more technical details, see [`tcflush(fd, TCIOFLUSH)`](http://linux.die.net/man/3/tcflush) for Mac/Linux and [`FlushFileBuffers`](http://msdn.microsoft.com/en-us/library/windows/desktop/aa364439) for Windows. - * @param {module:serialport~errorCallback=} callback Called once the flush operation finishes. + * @param {errorCallback=} callback Called once the flush operation finishes. + * @returns {undefined} */ SerialPort.prototype.flush = function(callback) { if (!this.isOpen) { @@ -498,7 +505,8 @@ SerialPort.prototype.flush = function(callback) { /** * Waits until all output data is transmitted to the serial port. After any pending write has completed it calls [`tcdrain()`](http://linux.die.net/man/3/tcdrain) or [FlushFileBuffers()](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364439(v=vs.85).aspx) to ensure it has been written to the device. - * @param {module:serialport~errorCallback=} callback Called once the drain operation returns. + * @param {errorCallback=} callback Called once the drain operation returns. + * @returns {undefined} * @example Write the `data` and wait until it has finished transmitting to the target serial port before calling the callback. This will queue until the port is open and writes are finished. @@ -528,16 +536,16 @@ SerialPort.prototype.drain = function(callback) { /** * The `pause()` method causes a stream in flowing mode to stop emitting 'data' events, switching out of flowing mode. Any data that becomes available remains in the internal buffer. - * @method module:serialport#pause - * @see module:serialport#resume + * @method SerialPort.prototype.pause + * @see resume * @since 5.0.0 * @returns `this` */ /** * The `resume()` method causes an explicitly paused, `Readable` stream to resume emitting 'data' events, switching the stream into flowing mode. - * @method module:serialport#resume - * @see module:serialport#pause + * @method SerialPort.prototype.resume + * @see pause * @since 5.0.0 * @returns `this` */ @@ -554,7 +562,7 @@ SerialPort.prototype.drain = function(callback) { * * We make an effort to identify the hardware attached and have consistent results between systems. Linux and OS X are mostly consistent. Windows relies on 3rd party device drivers for the information and is unable to guarantee the information. On windows If you have a USB connected device can we provide a serial number otherwise it will be `undefined`. The `pnpId` and `locationId` are not the same or present on all systems. The examples below were run with the same Arduino Uno. * @type {function} - * @param {listCallback=} callback + * @param {listCallback=} callback Called with a list of available serial ports. * @returns {Promise} Resolves with the list of available serial ports. * @example ```js @@ -609,16 +617,16 @@ SerialPort.list() .catch(err) {...}); ``` */ -SerialPort.list = function(cb) { +SerialPort.list = function(callback) { if (!SerialPort.Binding) { throw new TypeError('No Binding set on `SerialPort.Binding`'); } debug('.list'); const promise = SerialPort.Binding.list(); - if (typeof cb === 'function') { + if (typeof callback === 'function') { promise.then( - ports => cb(null, ports), - err => cb(err) + ports => callback(null, ports), + err => callback(err) ); } return promise;