ModbusRtuService class
Low-level Modbus RTU framing primitives.
Supports FC03 (Read Holding Registers) as required by the soil sensor. All multi-byte values are big-endian on the wire; CRC is sent lo-byte first.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
buildReadRequest(
{required int slaveAddress, required int startRegister, required int registerCount}) → Uint8List - Build an FC03 Read Holding Registers request (8 bytes).
-
calculateCrc16(
Uint8List data, int length) → int -
Calculates the CRC-16/ANSI (Modbus) checksum for
lengthbytes ofdata. -
expectedResponseLength(
int registerCount) → int -
Expected total response length for FC03 with
registerCountregisters. Formula: 3 (addr + fc + byteCount) + registerCount*2 + 2 (CRC) -
parseReadResponse(
Uint8List response, int registerCount) → List< int> - Parse and validate an FC03 response.
-
scaleBasicRegisters(
List< int> raw) → Map<String, double> - Scale 3 raw register values (basic sensor: moisture, temp, conductivity).
-
scaleExtendedRegisters(
List< int> raw) → Map<String, double> - Scale 7 raw register values into physical quantities.