mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
Add required request & response sizes to PDU limit exception messages.
This commit is contained in:
@@ -184,10 +184,12 @@ namespace S7.Net
|
||||
private void AssertPduSizeForRead(ICollection<DataItem> dataItems)
|
||||
{
|
||||
// send request limit: 19 bytes of header data, 12 bytes of parameter data for each dataItem
|
||||
if (19 + dataItems.Count * 12 > MaxPDUSize) throw new Exception("Too many vars requested for read");
|
||||
|
||||
var requiredRequestSize = 19 + dataItems.Count * 12;
|
||||
if (requiredRequestSize > MaxPDUSize) throw new Exception($"Too many vars requested for read. Request size ({requiredRequestSize}) is larger than protocol limit ({MaxPDUSize}).");
|
||||
|
||||
// response limit: 14 bytes of header data, 4 bytes of result data for each dataItem and the actual data
|
||||
if (GetDataLength(dataItems) + dataItems.Count * 4 + 14 > MaxPDUSize) throw new Exception("Too much data requested for read");
|
||||
var requiredResponseSize = GetDataLength(dataItems) + dataItems.Count * 4 + 14;
|
||||
if (requiredResponseSize > MaxPDUSize) throw new Exception($"Too much data requested for read. Response size ({requiredResponseSize}) is larger than protocol limit ({MaxPDUSize}).");
|
||||
}
|
||||
|
||||
private void AssertPduSizeForWrite(ICollection<DataItem> dataItems)
|
||||
|
||||
Reference in New Issue
Block a user