@serialpilot/binding-mock
v1.0.1
Published
The mock serialpilot bindings for testing
Maintainers
Readme
In-memory mock binding for SerialPilot. Drive your code without hardware — same parsers, same API, virtual port underneath.
Install
npm install --save-dev @serialpilot/binding-mockUsage
import { SerialPilotMock, ReadlineParser } from 'serialpilot'
import { MockBinding } from '@serialpilot/binding-mock'
MockBinding.createPort('/dev/ROBOT', { echo: true })
const port = new SerialPilotMock({ path: '/dev/ROBOT', baudRate: 9600 })
const lines = port.pipe(new ReadlineParser({ delimiter: '\n' }))
lines.on('data', line => console.log(line.toString()))
port.write('hello\n') // echoes back, lines emits 'hello'createPort accepts echo, record, readyData, respondTo, disconnectAfter, periodicData, and more — see the mocking guide.
