@serialpilot/parser-start-end
v1.0.1
Published
A transform stream that frames data on configurable start/end byte sequences.
Maintainers
Readme
A Transform stream that emits data only when bracketed by configured start and end byte sequences. Useful for protocols whose frames begin with a header marker and finish with a trailer (NMEA, custom binary frames).
npm install @serialpilot/parser-start-endUsage
const { SerialPilot, StartEndParser } = require('serialpilot')
const port = new SerialPilot({ path: '/dev/ttyUSB0', baudRate: 9600 })
const parser = port.pipe(new StartEndParser({
startDelimiter: Buffer.from([0xa5]),
endDelimiter: Buffer.from([0x5a]),
}))
parser.on('data', frame => console.log(frame))API
new StartEndParser({ startDelimiter, endDelimiter, includeDelimiter })
| Option | Type | Default | Description |
| ------------------ | ------------------- | ------- | -------------------------------------------------------- |
| startDelimiter | Buffer \| string | — | Required. Byte sequence that opens a frame. |
| endDelimiter | Buffer \| string | — | Required. Byte sequence that closes a frame. |
| includeDelimiter | boolean | false | Whether emitted chunks include the start/end markers. |
See the SerialPilot README for the full set of parsers.
