未验证 提交 0391f3d6 编写于 作者: S Steve Desmond 提交者: GitHub

Fixes #183: Allow reading output pins (#986)

* Allow reading output pins

* Add test to verify ability to read from output pins

* Extend test to verify pin value can be read after writing
上级 977dfeda
......@@ -116,12 +116,17 @@ namespace System.Device.Gpio.Tests
}
[Fact]
public void ThrowsIfReadingFromOutputPin()
public void CanReadFromOutputPin()
{
using (GpioController controller = new GpioController(GetTestNumberingScheme(), GetTestDriver()))
{
controller.OpenPin(OutputPin, PinMode.Output);
Assert.Throws<InvalidOperationException>(() => controller.Read(OutputPin));
controller.Write(OutputPin, PinValue.Low);
Assert.Equal(PinValue.Low, controller.Read(OutputPin));
controller.Write(OutputPin, PinValue.High);
Assert.Equal(PinValue.High, controller.Read(OutputPin));
}
}
......
......@@ -172,11 +172,6 @@ namespace System.Device.Gpio
throw new InvalidOperationException("Can not read from a pin that is not open.");
}
if (_driver.GetPinMode(logicalPinNumber) == PinMode.Output)
{
throw new InvalidOperationException("Can not read from a pin that is set to Output mode.");
}
return _driver.Read(logicalPinNumber);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册