Menu

Ready 解析器

注释:程序先收到自定义字符串,如“READY”后才开始接收数据

new Ready(options)

A transform stream that waits for a sequence of "ready" bytes before emitting a ready event and emitting data events

To use the Ready parser provide a byte start sequence. After the bytes have been received, a ready event is fired and data events are passed through.

Arguments

  • options.delimiter?: string delimiter to use to detect the input is ready

Example

const SerialPort = require('serialport')
const Ready = require('@serialport/parser-ready')
const port = new SerialPort('/dev/tty-usbserial1')

const parser = port.pipe(new Ready({ delimiter: 'READY' }))
parser.on('ready', () => console.log('the ready byte sequence has been received'))
parser.on('data', console.log) // all data after READY is received
上一篇 下一篇
讨论数量: 0

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