Skip to content

Commit

Permalink
Handle partial message in ReadDeviceInformationResponse (#1738)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgunth authored Aug 16, 2023
1 parent 85890dc commit 8de66a2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pymodbus/mei_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ def calculateRtuFrameSize(cls, buffer):
size = 8 # skip the header information
count = int(buffer[7])

while count > 0:
_, object_length = struct.unpack(">BB", buffer[size : size + 2])
size += object_length + 2
count -= 1
return size + 2
try:
while count > 0:
_, object_length = struct.unpack(">BB", buffer[size : size + 2])
size += object_length + 2
count -= 1
return size + 2
except struct.error as exc:
raise IndexError from exc

def __init__(self, read_code=None, information=None, **kwargs):
"""Initialize a new instance.
Expand Down

0 comments on commit 8de66a2

Please sign in to comment.