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

Fix decoder bug #2045

Merged
merged 2 commits into from
Feb 22, 2024
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
10 changes: 5 additions & 5 deletions examples/package_test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ async def client_calls(client):

async def server_calls(transport: ModbusProtocol):
"""Test client API."""
Log.debug("--> Client calls starting.")
_resp = transport.transport_send(b'\x00\x01\x00\x00\x00\x06\x01\x03\x00\x00\x00\x01')
Log.debug("--> Server calls starting.")
_resp = transport.transport_send(b'\x00\x02\x00\x00\x00\x06\x01\x03\x00\x00\x00\x01' +
b'\x07\x00\x03\x00\x00\x06\x01\x03\x00\x00\x00\x01')
await asyncio.sleep(1)
print("--> JIX done")

print("---> all done")

def handle_client_data(transport: ModbusProtocol, data: bytes):
"""Respond to request at transport level."""
Expand All @@ -212,7 +212,7 @@ def handle_client_data(transport: ModbusProtocol, data: bytes):

def handle_server_data(_transport: ModbusProtocol, data: bytes):
"""Respond to request at transport level."""
Log.debug("--> stub called with request {}.", data, ":hex")
Log.debug("--> stub called with response {}.", data, ":hex")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/framer/socket_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def getFrame(self):

:returns: The next full frame buffer
"""
length = self._hsize + self._header["len"]
length = self._hsize + self._header["len"] -1
return self._buffer[self._hsize : length]

# ----------------------------------------------------------------------- #
Expand Down
2 changes: 1 addition & 1 deletion test/test_framers.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _handle_response(_reply):
nonlocal response_ok
response_ok = True

message = bytearray(b"\x00\x02\x00\x00\x00\x02\x01\x84\x02")
message = bytearray(b"\x00\x02\x00\x00\x00\x03\x01\x84\x02")
response_ok = False
framer = ModbusSocketFramer(ClientDecoder())
framer.processIncomingPacket(message, _handle_response, slave=0)
Expand Down