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

Reading coil data bits is reversed #1

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,4 @@ dmypy.json

# Cython debug symbols
cython_debug/
.vscode/settings.json
8 changes: 8 additions & 0 deletions umodbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Modbus(object):
:param addr_list: List of addresses
:type addr_list: List[int]
"""

def __init__(self, itf, addr_list: List[int]) -> None:
self._itf = itf
self._addr_list = addr_list
Expand Down Expand Up @@ -167,6 +168,13 @@ def _create_response(self,
# 05 0000 0101
#
# 1011 0011 1101 0110 1010 0000
# Fixing issue #38 from @robertonaranjo
n = len(data)
fp = data[:8]
lp = data[8:n]
fp.reverse()
lp.reverse()
data = fp + lp

return data

Expand Down