-
-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update docs and type descriptions (#2424)
from writing docs I found a bunch to add
- Loading branch information
Showing
6 changed files
with
17 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
See our api docs https://node-serialport.github.io/node-serialport/CCTalkParser.html | ||
# CCTalk Parser | ||
|
||
See our api docs https://serialport.io/docs/api-parser-cctalk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,3 @@ | ||
--- | ||
title: Packet Delimiter Length Parser | ||
--- | ||
```typescript | ||
new PacketLengthParser((options?) | ||
``` | ||
A transform stream that emits data after a delimiter and number of bytes is received. The length in bytes of the packet follows the delimiter at a specified byte offset. To use the `PacketLength` parser, provide a delimiter (defaults to 0xaa), packetOverhead (defaults to 2), number of length bytes (defaults to 1) and the lengthOffset (defaults to 1). Data is emitted as a buffer. | ||
# Parser Packet Length | ||
|
||
Arguments | ||
- `options.delimiter?: UInt8` delimiter to use | ||
- `options.packetOverhead?: UInt8` overhead of packet (including length, delimiter and any checksum / packet footer) | ||
- `options.lengthBytes?: UInt8` number of bytes containing length | ||
- `options.lengthOffset?: UInt8` offset of length field | ||
- `options.maxLen?: UInt8` maximum valid length for a packet | ||
## Example | ||
```js | ||
// Parse length encoded packets received on the serial port in the form: | ||
// [delimiter][0][len 0][len 1][cargo 0]...[cargo n][footer 0] | ||
const SerialPort = require('serialport') | ||
const PacketLengthParser = require('@serialport/packet-length-parser') | ||
const port = new SerialPort('/dev/tty-usbserial1') | ||
const parser = port.pipe(new PacketLengthParser({ | ||
delimiter: 0xbc, | ||
packetOverhead: 5, | ||
lengthBytes: 2, | ||
lengthOffset: 2, | ||
})) | ||
The documentation at https://serialport.io/docs/api-parser-packet-length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,3 @@ | ||
## SerialPort Terminal | ||
```bash | ||
$ npx @serialport/terminal -p <port> [options] | ||
# or | ||
$ npm install -g @serialport/terminal | ||
$ serialport-terminal -p <port> [options] | ||
``` | ||
# SerialPort Terminal | ||
|
||
The package `@serialport/terminal` will install the `serialport-terminal` cli tool which provides a basic terminal interface for communicating over a serial port. `ctrl+c` will exit. | ||
|
||
```bash | ||
$ serialport-terminal -h | ||
|
||
Usage: serialport-terminal -p <port> [options] | ||
|
||
A basic terminal interface for communicating over a serial port. Pressing ctrl+c exits. | ||
|
||
Options: | ||
|
||
-h, --help output usage information | ||
-V, --version output the version number | ||
-l --list List available ports then exit | ||
-p, --port, --portname <port> Path or name of serial port | ||
-b, --baud <baudrate> Baud rate default: 9600 | ||
--databits <databits> Data bits default: 8 | ||
--parity <parity> Parity default: none | ||
--stopbits <bits> Stop bits default: 1 | ||
--echo --localecho Print characters as you type them | ||
|
||
$ serialport-terminal -l | ||
/dev/tty.Bluetooth-Incoming-Port | ||
/dev/tty.usbmodem1421 Arduino (www.arduino.cc) | ||
``` | ||
See the documentation at https://serialport.io/docs/bin-terminal |