Skip to content

Conversation

@volkmarnissen
Copy link
Collaborator

@volkmarnissen volkmarnissen commented Oct 2, 2025

The modbus protocol supports only 16 bit values (word).
By default the byte order is Big Endian

In order to be able to support 32-bit or text, there are several different implementations in place.
In most cases, the default configuration returns correct values. However in exceptional cases, the byte order is wrong.
In this case you can swap the byte order of the modbus data before passing it to mqtt.
This will exchange the bytes within the word.
Additionally you can change the word order when dealing with 32-bit(long).
In this case, the content of the words is not changed, but the lo/high words are exchanged.
So, if you swap words and byte, you get Little Endian.
Mixtures are also possible.

fixes modbus2mqtt/server#91
fixes modbus2mqtt/server#90

Dependant Pullrequests

Repository Pull Request
specification.shared 10
specification 13
angular 17

@volkmarnissen volkmarnissen changed the title Please update me Swap Words and Swap Bytes for numbers Oct 2, 2025
@volkmarnissen volkmarnissen marked this pull request as ready for review October 2, 2025 12:16
@volkmarnissen volkmarnissen merged commit c777dc4 into modbus2mqtt:main Oct 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add possibility to convert the byte and the word order for numbers and also for texts Looks like that Unsigned Int32 and Signed Int32 is mixed

2 participants