Skip to content
Merged
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
14 changes: 14 additions & 0 deletions pymodbus/file_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, records=None, **kwargs):
"""
ModbusRequest.__init__(self, **kwargs)
self.records = records or []
self.count = 0

def encode(self):
"""Encode the request packet.
Expand Down Expand Up @@ -137,6 +138,19 @@ def execute(self, context): # NOSONAR pylint: disable=unused-argument,no-self-u
files = []
return ReadFileRecordResponse(files)

def get_response_pdu_size(self):
"""Get response pdu size.

Func_code (1 byte) + Response Byte Count(1 byte) +
N * (File Response Byte Count (1 byte) + Reference Type (1 byte) + 2 * registers to read for file record)
where N = record sub-request count.
"""
self.count = 0
for record in self.records:
self.count += record.record_length * 2 + 2 if record.record_length else 0

return 2 + self.count


class ReadFileRecordResponse(ModbusResponse):
"""Read file record response.
Expand Down