Skip to content

Commit

Permalink
Reading coil data bits is reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir1284 committed Sep 2, 2023
1 parent e9ab05a commit d9f6a5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit d9f6a5e

Please sign in to comment.