Enhance modbus-write for 32-bit values and byte order support#14
Merged
Conversation
modbus-write only did single register/coil, so 32-bit setpoints (write_multiple_registers in PLC mappings) could not be expressed. Add function options `float32` and `uint32` that encode the numeric payload into two registers per `byte_order` (big_big / big_little) and write them with write_multiple_registers. Expose the options + byte_order in the catalog. Unit-test the register split and float round-trip.
big_big alone was not enough: byte_order is <bytes-in-register>_<word-order>, so little_big / little_little also swap the two bytes inside each register. Handle all four in split_u32 (and document them), expand the catalog options, and round-trip-test every order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request extends the Modbus write node to support writing 32-bit floating point and unsigned integer values (over two registers) with configurable byte and word order. It also improves payload handling and adds comprehensive tests for the new functionality.
Modbus Write Node Enhancements:
float32) and unsigned integer (uint32) values, with configurable byte and word order, in addition to the existing single register/coil writes. [1] [2]catalog()to include newfunctionoptions (float32,uint32) and abyte_ordersetting, which is shown only for 32-bit writes.Payload Handling Improvements:
Testing and Documentation: