Menu

InterByteTimeout 解析器

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 receiving any bytes for the specified amount of time.

Arguments

  • options.interval: number the period of silence in milliseconds after which data is emitted.
  • options.maxBufferSize: number the maximum number of bytes after which data will be emitted. Defaults to 65536.

Example

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
上一篇 下一篇
讨论数量: 0

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
刻意练习,每日精进。
~
点赞
276
浏览
0
讨论