Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endianness now used in packing bytes #71

Merged
merged 1 commit into from
Feb 18, 2015

Conversation

patrickfuller
Copy link
Contributor

I've been chasing down a weird bug with some Modbus TCP devices. The holding registers read:

40001: 0000, 40002: 3fc0, 40003: 0000, 40004: 4040

or [0, 16320, 0, 16448]. This should decode to two 32-bit floats: 1.5 and 3.0. This code:

from pymodbus.payload import BinaryPayloadDecoder
decoder = BinaryPayloadDecoder.fromRegisters([0, 16320, 0, 16448])
print(decoder.decode_32bit_float())
print(decoder.decode_32bit_float())

prints -2.984375 and 3.0. I found that this was due to a hardcoded bigendian in BinaryPayloadDecoder.fromRegisters. With that replaced with the endian variable, everything decodes properly.

bashwork added a commit that referenced this pull request Feb 18, 2015
Endianness now used in packing bytes
@bashwork bashwork merged commit e61b799 into pymodbus-dev:master Feb 18, 2015
dhoomakethu pushed a commit that referenced this pull request May 16, 2017
Endianness now used in packing bytes
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants