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.
Add text (
TXT
) support.This is tricky and different from the other datatypes because two 8-bit addresses are packed into a single 16-bit register. For some strange reason it's little-endian.
For example, consider the following state:
In memory, or using a "naive" Modbus client, this will appear as
BADC
.To read
TXT1
, the whole 16-bit holding register[4]36865
must be read and the first 8 bits (MSB) discarded.To read
TXT2
, the whole 16-bit holding register[4]36865
must be read and the last 8 bits (LSB) discarded.To write
TXT1
:TXT2
and save its 8 bit valueTXT2
into the MSB of a 16-bit value, and the 8 bits ofTXT1
into the LSB[4]36865
To write
TXT2
:TXT1
and save its 8 bit valueTXT2
into the MSB of a 16-bit value, and the 8 bits ofTXT1
into the LSB[4]36865