A Node.js Duplex stream connected to the RS-485 bus (e.g. a SerialPort).
Modbus unit/slave address of the Vallox unit (default 1).
Maximum time (ms) to wait for a response (default 1000 ms).
Builds a Modbus FC03 (Read Holding Registers) request frame.
Starting register address, as listed in the Vallox Modbus manual.
Number of registers to read.
Builds a Modbus FC16 (Write Multiple Registers, function code 0x10) request frame.
Builds a Modbus FC06 (Write Single Register) request frame.
Reads a single holding register using FC03.
Reads count consecutive holding registers using FC03.
The response structure is:
[unitAddr, 0x03, byteCount, dataHi0, dataLo0, ..., crcLo, crcHi]
Expected response length = 5 + count * 2.
Sends a request frame over the stream and collects exactly expectedBytes of response.
Rejects if the response does not arrive within timeoutMs.
Writes a single register using FC06. The unit echoes the full request as its response (8 bytes).
Writes multiple registers. Uses FC06 for a single register, FC16 for multiple registers.
Standard Modbus RTU transport over any Node.js Duplex stream (e.g. a serial port).
Implements the Transport interface using: