Skip to content

Commit

Permalink
Encode WriteMultipleRegistersRequest using values length (#102)
Browse files Browse the repository at this point in the history
Encode the "Byte Count" field of a WriteMultipleRegistersRequest using the length of the `values` bytes rather than multiplying `quantity` by 2.

This allows the request to be used with non-standard Modbus implementations e.g. those that use 32-bit registers instead of the standard 16-bit registers.
  • Loading branch information
kevinherron authored Jan 20, 2025
1 parent ffbba2d commit 94eab4d
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public static void encode(WriteMultipleRegistersRequest request, ByteBuffer buff
buffer.putShort((short) request.address);
buffer.putShort((short) request.quantity);

int byteCount = request.quantity * 2;
buffer.put((byte) byteCount);
buffer.put((byte) request.values.length);
buffer.put(request.values);
}

Expand Down

0 comments on commit 94eab4d

Please sign in to comment.