From dd3d7e0d5bc4cb7db53254602ddccb094ebf341c Mon Sep 17 00:00:00 2001 From: brambo123 <52667932+brambo123@users.noreply.github.com> Date: Wed, 25 Feb 2026 20:31:00 +0100 Subject: [PATCH 1/3] Fix ReadFifoQueueResponse RTU Frame Size --- pymodbus/pdu/file_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymodbus/pdu/file_message.py b/pymodbus/pdu/file_message.py index f6d7e045f..c6c8a6f49 100644 --- a/pymodbus/pdu/file_message.py +++ b/pymodbus/pdu/file_message.py @@ -260,7 +260,7 @@ def calculateRtuFrameSize(cls, data: bytes) -> int: """Calculate the size of the message.""" hi_byte = int(data[2]) lo_byte = int(data[3]) - return ((hi_byte << 16) + lo_byte) * 2 + 6 + return ((hi_byte << 16) + lo_byte) + 6 def __init__(self, values: list[int] | None = None, dev_id: int = 1, transaction_id:int = 0) -> None: """Initialize a new instance.""" From 69417a719a5862b68e10eee7c1110397e7a201d2 Mon Sep 17 00:00:00 2001 From: brambo123 <52667932+brambo123@users.noreply.github.com> Date: Wed, 25 Feb 2026 20:33:39 +0100 Subject: [PATCH 2/3] Fix ReadFifoQueueResponse RTU Frame Size --- pymodbus/pdu/file_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymodbus/pdu/file_message.py b/pymodbus/pdu/file_message.py index c6c8a6f49..4576aae24 100644 --- a/pymodbus/pdu/file_message.py +++ b/pymodbus/pdu/file_message.py @@ -260,7 +260,7 @@ def calculateRtuFrameSize(cls, data: bytes) -> int: """Calculate the size of the message.""" hi_byte = int(data[2]) lo_byte = int(data[3]) - return ((hi_byte << 16) + lo_byte) + 6 + return ((hi_byte << 16) + lo_byte) + 4 def __init__(self, values: list[int] | None = None, dev_id: int = 1, transaction_id:int = 0) -> None: """Initialize a new instance.""" From e1eab92f8484d8ae3d4e5a8f712a7dcf940fd162 Mon Sep 17 00:00:00 2001 From: brambo123 <52667932+brambo123@users.noreply.github.com> Date: Thu, 26 Feb 2026 18:29:13 +0100 Subject: [PATCH 3/3] Try to fix test_frame_size for ReadFifoQueue Quick dirty test to fix test_frame_size --- test/pdu/test_file_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pdu/test_file_message.py b/test/pdu/test_file_message.py index 4b50dfd71..63307ebc3 100644 --- a/test/pdu/test_file_message.py +++ b/test/pdu/test_file_message.py @@ -61,7 +61,7 @@ def test_read_fifo_queue_response_decode(self): def test_frame_size(self): """Test that the read fifo queue response can decode.""" message = TEST_MESSAGE - result = ReadFifoQueueResponse.calculateRtuFrameSize(message) + result = ReadFifoQueueResponse.calculateRtuFrameSize(b"\x00\x18" + message) assert result == 14 # -----------------------------------------------------------------------#