@modbus-ts/codec
v0.0.5
Published
The codec package for modbus-ts.
Maintainers
Readme
@modbus-ts/codec
Industrial register codec helpers with byte and word swap support.
Installation
pnpm add @modbus-ts/codecCore Exports
- SwapOptions
- decodeUint16 / decodeInt16
- decodeUint32 / decodeInt32
- decodeFloat32 / decodeFloat64
- encodeFloat32 / encodeFloat64
- encodeAsciiString / decodeAsciiString
Minimal Example
import {
decodeAsciiString,
decodeFloat32,
encodeAsciiString,
encodeFloat32,
} from '@modbus-ts/codec'
const regs = encodeFloat32(12.5, { wordSwap: true })
const value = decodeFloat32(regs, { wordSwap: true })
const textRegs = encodeAsciiString('HELLO', { padByte: 0x20 })
const text = decodeAsciiString(textRegs)Notes
- Use byteSwap and wordSwap to match PLC memory layout
- Helpers operate directly on Modbus register arrays
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
