diff --git a/pymodbus/pdu/file_message.py b/pymodbus/pdu/file_message.py index f6d7e045f..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) * 2 + 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.""" 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 # -----------------------------------------------------------------------#