You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do i catch the Address out of range or object does not exist exception in this Sample?
i need the lasterrorcode but threre is none anymore. The dokumentation is not uptodate.
private async Task ReadDataBlock(SymbolInfo sym, CancellationToken stoppingToken)
{
try
{
sym.ActValue = await _plc.ReadSingleVariableAsync(sym.BitOffset, sym.TypeBitLength,
sym.DataBlockNumber, sym.eType, sym.eArea, stoppingToken);
await CheckData(sym, stoppingToken);
}
catch (Exception ex)
{
var offset = sym.BitOffset;
_logger.LogCritical($"PLC{_fileSuffix}: DB: {sym.DataBlockNumber}. ByteOffset: {(int)(offset / 8)}.{(int)(offset % 8)}");
_logger.LogCritical($"PLC{_fileSuffix}: {ex.Message}");
if (false)//Address out of range or object does not exist
{
_logger.LogCritical($"PLC{_fileSuffix}: Couldn't find the Variable.");
SymbolList.First().Item1.Remove(sym);
}
}
}
internal static void ValidateResponseCode(ReadWriteErrorCode statusCode)
{
switch (statusCode)
{
case ReadWriteErrorCode.ObjectDoesNotExist:
throw new Exception("Received error from PLC: Object does not exist.");
case ReadWriteErrorCode.DataTypeInconsistent:
throw new Exception("Received error from PLC: Data type inconsistent.");
case ReadWriteErrorCode.DataTypeNotSupported:
throw new Exception("Received error from PLC: Data type not supported.");
case ReadWriteErrorCode.AccessingObjectNotAllowed:
throw new Exception("Received error from PLC: Accessing object not allowed.");
case ReadWriteErrorCode.AddressOutOfRange:
throw new ArgumentOutOfRangeException("Received error from PLC: Address out of range.");
case ReadWriteErrorCode.HardwareFault:
throw new Exception("Received error from PLC: Hardware fault.");
case ReadWriteErrorCode.Success:
break;
default:
throw new Exception($"Invalid response from PLC: statusCode={(byte)statusCode}.");
}
}
The text was updated successfully, but these errors were encountered:
How do i catch the Address out of range or object does not exist exception in this Sample?
i need the lasterrorcode but threre is none anymore. The dokumentation is not uptodate.
ReadSingleVariableAsync calls this
The Exception is thrown here in S7.net
The text was updated successfully, but these errors were encountered: