mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
22 lines
882 B
Markdown
22 lines
882 B
Markdown
---
|
|
id: api-parser-inter-byte-timeout
|
|
title: InterByteTimeout Parser
|
|
---
|
|
```typescript
|
|
new InterByteTimeout(options)
|
|
```
|
|
Emits data if there is a pause between packets for the specified amount of time.
|
|
|
|
A transform stream that emits data as a buffer after not recieving any bytes for the specified amount of time.
|
|
|
|
Arguments
|
|
- `options.interval: number` the period of silence in milliseconds after which data is emited
|
|
- `options.maxBufferSize: number` the maximum number of bytes after which data will be emited. Defaults to 65536.
|
|
|
|
## Example
|
|
```js
|
|
const SerialPort = require('serialport')
|
|
const InterByteTimeout = require('@serialport/parser-inter-byte-timeout')
|
|
const port = new SerialPort('/dev/tty-usbserial1')
|
|
const parser = port.pipe(new InterByteTimeout({interval: 30}))
|
|
parser.on('data', console.log) // will emit data if there is a pause between packets of at least 30ms
|