diff --git a/Sharp7.Rx/Interfaces/IS7Connector.cs b/Sharp7.Rx/Interfaces/IS7Connector.cs index 612dd82..309f750 100644 --- a/Sharp7.Rx/Interfaces/IS7Connector.cs +++ b/Sharp7.Rx/Interfaces/IS7Connector.cs @@ -14,7 +14,6 @@ namespace Sharp7.Rx.Interfaces Task Connect(); Task Disconnect(); - Task ReadBit(Operand operand, ushort byteAddress, byte bitAdress, ushort dbNr, CancellationToken token); Task ReadBytes(Operand operand, ushort startByteAddress, ushort bytesToRead, ushort dBNr, CancellationToken token); Task WriteBit(Operand operand, ushort startByteAddress, byte bitAdress, bool value, ushort dbNr, CancellationToken token); diff --git a/Sharp7.Rx/Sharp7Connector.cs b/Sharp7.Rx/Sharp7Connector.cs index 484118f..99c6644 100644 --- a/Sharp7.Rx/Sharp7Connector.cs +++ b/Sharp7.Rx/Sharp7Connector.cs @@ -270,21 +270,6 @@ namespace Sharp7.Rx } return (ushort)(data.Length); } - - - public async Task ReadBit(Operand operand, ushort byteAddress, byte bitAdress, ushort dbNr, CancellationToken token) - { - EnsureConnectionValid(); - - var byteValue = await ReadBytes(operand, byteAddress, 1, dbNr, token); - token.ThrowIfCancellationRequested(); - - if (byteValue.Length != 1) - throw new InvalidOperationException("Read bytes does not have length 1"); - - return Convert.ToBoolean(byteValue[0] & (1 << bitAdress)); - } - public async Task WriteBit(Operand operand, ushort startByteAddress, byte bitAdress, bool value, ushort dbNr, CancellationToken token) { EnsureConnectionValid(); diff --git a/Sharp7.Rx/Sharp7Plc.cs b/Sharp7.Rx/Sharp7Plc.cs index 3f733cb..95b690c 100644 --- a/Sharp7.Rx/Sharp7Plc.cs +++ b/Sharp7.Rx/Sharp7Plc.cs @@ -144,9 +144,8 @@ namespace Sharp7.Rx if (typeof(TValue) == typeof(bool)) { - var b = await s7Connector.ReadBit(address.Operand, address.Start, address.Bit, address.DbNr, token); - token.ThrowIfCancellationRequested(); - return (TValue)(object)b; + var b = await s7Connector.ReadBytes(address.Operand, address.Start, address.Length, address.DbNr, token); + return ConvertToType(b, address); } if (typeof(TValue) == typeof(int))