namespace ZB.MOM.WW.OtOpcUa.Driver.Modbus; /// /// Abstraction over the Modbus TCP socket. Takes a PDU (function code + data, excluding /// the 7-byte MBAP header) and returns the response PDU — the transport owns transaction-id /// pairing, framing, and socket I/O. Tests supply in-memory fakes. /// public interface IModbusTransport : IAsyncDisposable { Task ConnectAsync(CancellationToken ct); /// /// Send a Modbus PDU (function code + function-specific data) and read the response PDU. /// Throws when the server returns an exception PDU /// (function code + 0x80 + exception code). /// Task SendAsync(byte unitId, byte[] pdu, CancellationToken ct); } public sealed class ModbusException(byte functionCode, byte exceptionCode, string message) : Exception(message) { public byte FunctionCode { get; } = functionCode; public byte ExceptionCode { get; } = exceptionCode; }