Modbus LoWord HiWord

I read a value of 32bit splitted in two consecutive address (16bit+16bit) LoWord and HiWord in this order.
So with “count=2”, the result is not correct because HA converts not in the correct order.
E.g.
First word LoWord = “0xD516”
Second word Hi Word = “0x0099”
Standard process uses " 0xD5160099"
Instead of my required target “0x0099D516”

Notes:

  1. “structure=<I” field (python struct) can reorder all byte (0x9900615D) and it’s not correct.
  2. count=-2 returns error: count must be greater than 0.
  3. address can be readed separately as raw data then compute with a template sensor (2^16 * HiWord + LoWord).

What’s best practice to do this kind of job?
It isn’t a rare case so probably the is a simple tricks.
Thanks.

  swap: word
1 Like

Thanks @nikito7 !!!

1 Like