Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen committed Nov 8, 2024
1 parent 03a3dcf commit 4c92c48
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pymodbus/pdu/mei_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ class ReadDeviceInformationResponse(ModbusPDU):
def calculateRtuFrameSize(cls, buffer: bytes) -> int:
"""Calculate the size of the message."""
size = 8 # skip the header information
if (data_len := len(buffer)) < size:
return 999
count = int(buffer[7])

try:
while count > 0:
if data_len < size+2:
return 998
_, object_length = struct.unpack(">BB", buffer[size : size + 2])
size += object_length + 2
count -= 1
Expand Down

0 comments on commit 4c92c48

Please sign in to comment.