@modbus-ts/subscription
v0.0.5
Published
The subscription package for modbus-ts.
Maintainers
Readme
@modbus-ts/subscription
Polling subscription engine with range merge and change detection.
Installation
pnpm add @modbus-ts/subscriptionCore Exports
- SubscriptionGroup
- MergedRange
- PollGroup
- SubscriptionEngine
Minimal Example
import { SubscriptionEngine } from '@modbus-ts/subscription'
const engine = new SubscriptionEngine({
readRegisters: async ({ start, length }) => new Array(length).fill(start),
})
const unsubscribe = engine.subscribe({
unitId: 1,
start: 0,
length: 4,
interval: 500,
callback: (registers) => console.log(registers),
})
engine.start()
unsubscribe()
engine.stop()Behavior
- Groups subscriptions by interval
- Merges overlapping ranges per unitId
- Calls callback only when values changed
Packages
- high-level Modbus client
- shared contracts, types, and errors
- FC1/FC2/FC3/FC4/FC5/FC6/FC15/FC16 frame encode/decode for TCP/RTU/ASCII
- serial request queue with priority
- polling engine and range merge
- Node TCP transport with reconnect
- Node UDP transport
- browser WebSocket transport with reconnect
- typed Electron main/renderer bridge
- Electron IPC transport adapter
- WebSocket to TCP binary relay gateway
- register-value codec helpers
- shared async and comparison utilities
