You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define, document, and test flow control and setting port flags (#726)
We had ambiguous behavior and documentation around these settings and functions, this preserves all of the previous behavior and defines it in documentation and tests. This is a step towards separating out and cleaning up user supplied options to the constructor.
Copy file name to clipboardExpand all lines: README.md
+27-12Lines changed: 27 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -269,23 +269,18 @@ Port configuration options.
269
269
*`dataBits` Data Bits, defaults to 8. Must be one of: 8, 7, 6, or 5.
270
270
*`stopBits` Stop Bits, defaults to 1. Must be one of: 1 or 2.
271
271
*`parity` Parity, defaults to 'none'. Must be one of: 'none', 'even', 'mark', 'odd', 'space'
272
-
*`rtscts`
273
-
*`xon`
274
-
*`xoff`
275
-
*`xany`
276
-
*`flowControl`One of the following `XON`, `XOFF`, `XANY`, `RTSCTS`
277
-
*`bufferSize` Size of read buffer, defaults to 255. Must be an integer value.
272
+
*`rtscts` defaults to false
273
+
*`xon` defaults to false
274
+
*`xoff` defaults to false
275
+
*`xany` defaults to false
276
+
*`flowControl``true` for `rtscts` or an array with one or more of the following strings to enable them `xon`, `xoff`, `xany`, `rtscts`. Overwrites any individual settings.
277
+
*`bufferSize` Size of read buffer, defaults to 65536. Must be an integer value.
278
278
*`parser` The parser engine to use with read data, defaults to rawPacket strategy which just emits the raw buffer as a "data" event. Can be any function that accepts EventEmitter as first parameter and the raw buffer as the second parameter.
279
-
*`encoding`
280
-
*`dataCallback`
281
-
*`disconnectedCallback`
282
279
*`platformOptions` - sets platform specific options, see below.
283
280
284
-
**Note:** We have added support for either all lowercase OR camelcase of the options (thanks @jagautier), use whichever style you prefer.
285
-
286
281
#### Unix Platform Options
287
282
288
-
An object with the following properties:
283
+
These properties are ignored for windows. An object with the following properties:
289
284
290
285
*`vmin` (default: 1) - see [`man termios`](http://linux.die.net/man/3/termios)
291
286
*`vtime` (default: 0) - see [`man termios`](http://linux.die.net/man/3/termios)
@@ -374,6 +369,26 @@ Called once a connection is closed. The callback should be a function that looks
374
369
375
370
**Note:** Currently closing a connection will also remove all event listeners.
376
371
372
+
### .set (options, callback)
373
+
374
+
Sets 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 mac and linux.
375
+
376
+
**_options (optional)_**
377
+
378
+
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 will be used.
379
+
380
+
*`brk` optional boolean, defaults to false
381
+
*`cts` optional boolean, defaults to false
382
+
*`dsr` optional boolean, defaults to false
383
+
*`dtr` optional boolean, defaults to true
384
+
*`rts` optional boolean, defaults to true
385
+
386
+
**_callback (optional)_**
387
+
388
+
`callback: function(err, results)`
389
+
390
+
Called once the port's flags have been set. `results` are the return of the underlying system command. If `.set` is called without an callback and there is an error, an error event will be emitted.
0 commit comments