Replies: 5 comments 6 replies
-
?? it is quite normal to use from_registers I am not sure what your problem is. Modbus specifies the byte order, but not the word (registers) order, for that reason to/from registers offer the option to swap the word order. |
Beta Was this translation helpful? Give feedback.
-
Your library works perfectly, but before (I'll check tomorrow) I had access to byte_order decoder = BinaryPayloadDecoder.fromRegisters(registers, byteorder=Endian.BIG, wordorder=Endian.BIG My device works in little endian, but now I have to manipulate the bytes before using “convert_from_registers.” Thank you |
Beta Was this translation helpful? Give feedback.
-
I'm a little confused. def inverser_octets(liste):
return [((val & 0xFF) << 8) | ((val >> 8) & 0xFF) for val in liste]
rr = client.read_holding_registers(52014, count=2, slave=1)
resultat = inverser_octets(rr.registers)
value_test = client.convert_from_registers(resultat, data_type=client.DATATYPE.UINT32, word_order="little")
print(f"MainBoardHW register 52014: {value_test}")
rr = client.read_holding_registers(52016, count=1, slave=1)
resultat = inverser_octets(rr.registers)
value_test = client.convert_from_registers(resultat, data_type=client.DATATYPE.UINT16, word_order="little")
print(f"MainBoardHWRev 52016: {value_test}") If I had to use this before, (3.7.2) resp = BinaryPayloadDecoder.fromRegisters(response.registers, byteorder=Endian.LITTLE,wordorder=Endian.LITTLE) Is my device not compliant with the standard ? thank you |
Beta Was this translation helpful? Give feedback.
-
I think you are yourself, you have now presented to very different examples. The text of the issue states you get the correct result by using from_registers with word_order little. This is a perfectly valid modbus device. In your latest example, you introduce (some weird byte swapping, why not use the builtin python methods), which makes your device non complaint. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry, I'm not being very clear. There are four of us testing, and we all use the minimalmodbus library. I'm the only one who switched to pymodbus I know the expected result is 24.85 rr = client.read_holding_registers(1000, count=2, slave=1)
value_test = client.convert_from_registers(rr.registers, data_type=client.DATATYPE.FLOAT32, word_order="little") value_test = -12396.6533203125 def inverser_octets(liste):
return [((val & 0xFF) << 8) | ((val >> 8) & 0xFF) for val in liste]
rr = client.read_holding_registers1000, count=2, slave=1)
resultat = inverser_octets(rr.registers)
value_test = client.convert_from_registers(resultat, data_type=client.DATATYPE.FLOAT32, word_order="little") value_test = 24.85 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I'm using Pymodbus 3.11.2. I've seen this question before but would like to get your opinion on it.
I'm receiving the following:
To get the correct floating-point value, I had to use
I had to reverse the order of my registers. My device is a standard industrial Modbus device. I have been told that the Modbus standard does not specify the byte order for values greater than 16 bits.
Is there another way to do this ?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions