Skip to content

Commit 37291f6

Browse files
krwqjoperezrpgrawehr
authored
Obsolete PinNumberingScheme (#2358)
* Obsolete PinNumberingScheme Let's see what breaks * Fixing using statement * share progress from triage meeting * Remove various usages of PinNumberingScheme * Remove all occurences of PinNumberingScheme from bindings * Fix some test errors * Checkout compatible version * There's a strange build error now * Add compat suppressions * Suppression update for Windows * Small review finding * Obsolete test instead of removing it --------- Co-authored-by: Jose Perez Rodriguez <[email protected]> Co-authored-by: Patrick Grawehr <[email protected]> Co-authored-by: Patrick Grawehr <[email protected]>
1 parent ddb69e5 commit 37291f6

File tree

65 files changed

+594
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+594
-352
lines changed

eng/ArduinoCsCI.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ REM Second argument is either "Debug" or "Release"
55
if %1!==! goto :usage
66

77
REM Defines the revision to check out in the ExtendedConfigurableFirmata repo
8-
set FIRMATA_SIMULATOR_CHECKOUT_REVISION=66b1863f3a4b0999f2c1cb7133332cbd25730252
8+
set FIRMATA_SIMULATOR_CHECKOUT_REVISION=18ef6b3a890b34904904663fb2cece9141600849
99
set RUN_COMPILER_TESTS=FALSE
1010

1111
choco install -y --no-progress arduino-cli
@@ -22,7 +22,7 @@ powershell -ExecutionPolicy ByPass -command "%~dp0common\Build.ps1" -restore -bu
2222
set ArduinoRootDir=%1\Documents\Arduino
2323
set acspath=%~dp0\..\artifacts\bin\Frontend\%2\net6.0\acs.exe
2424

25-
git clone https://github.com/firmata/ConfigurableFirmata %ArduinoRootDir%\libraries\ConfigurableFirmata
25+
git clone https://github.com/firmata/ConfigurableFirmata %ArduinoRootDir%\libraries\ConfigurableFirmata --branch BuildIssueEsp
2626
git clone https://github.com/pgrawehr/ExtendedConfigurableFirmata %ArduinoRootDir%\ExtendedConfigurableFirmata
2727
arduino-cli core install esp32:esp32
2828

samples/M5StackRemoteDisplay/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static int Main(string[] args)
185185

186186
private static GpioController GetGpioControllerFromFt4222()
187187
{
188-
return new GpioController(PinNumberingScheme.Logical, new Ft4222Gpio());
188+
return new GpioController(new Ft4222Gpio());
189189
}
190190

191191
private static SpiDevice GetSpiFromFt4222()

samples/led-more-blinking-lights/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
volume = Volume.EnableVolume();
2424

2525
Console.WriteLine($"Let's blink some LEDs!");
26-
using GpioController controller = new GpioController(PinNumberingScheme.Logical);
26+
using GpioController controller = new GpioController();
2727
controller.OpenPin(ledOne, PinMode.Output);
2828
controller.OpenPin(ledTwo, PinMode.Output);
2929
controller.OpenPin(ledThree, PinMode.Output);

src/Iot.Device.Bindings/CompatibilitySuppressions.xml

Lines changed: 243 additions & 111 deletions
Large diffs are not rendered by default.

src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public void Dispose()
2626
[Fact]
2727
public void PinCountReportedCorrectly()
2828
{
29-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
29+
var ctrl = new GpioController(_mockedGpioDriver.Object);
3030
Assert.Equal(28, ctrl.PinCount);
3131
}
3232

3333
[Fact]
3434
public void OpenTwiceGpioPinAndClosedTwiceThrows()
3535
{
36-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
36+
var ctrl = new GpioController(_mockedGpioDriver.Object);
3737
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
3838
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
3939
GpioPin gpioPin1 = ctrl.OpenPin(1);
@@ -50,7 +50,7 @@ public void WriteInputPinDoesNotThrow()
5050
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, It.IsAny<PinMode>())).Returns(true);
5151
_mockedGpioDriver.Setup(x => x.SetPinModeEx(1, It.IsAny<PinMode>()));
5252
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Input);
53-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
53+
var ctrl = new GpioController(_mockedGpioDriver.Object);
5454

5555
ctrl.OpenPin(1, PinMode.Input);
5656
ctrl.Write(1, PinValue.High);
@@ -64,7 +64,7 @@ public void GpioControllerCreateOpenClosePin()
6464
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
6565
_mockedGpioDriver.Setup(x => x.WriteEx(1, PinValue.High));
6666
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
67-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
67+
var ctrl = new GpioController(_mockedGpioDriver.Object);
6868
Assert.NotNull(ctrl);
6969
ctrl.OpenPin(1, PinMode.Output);
7070
Assert.True(ctrl.IsPinOpen(1));
@@ -77,7 +77,7 @@ public void GpioControllerCreateOpenClosePin()
7777
public void IsPinModeSupported()
7878
{
7979
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true);
80-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
80+
var ctrl = new GpioController(_mockedGpioDriver.Object);
8181
Assert.NotNull(ctrl);
8282
Assert.True(ctrl.IsPinModeSupported(1, PinMode.Input));
8383
}
@@ -87,7 +87,7 @@ public void GetPinMode()
8787
{
8888
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
8989
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
90-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
90+
var ctrl = new GpioController(_mockedGpioDriver.Object);
9191
Assert.NotNull(ctrl);
9292
// Not open
9393
Assert.Throws<InvalidOperationException>(() => ctrl.GetPinMode(1));
@@ -96,6 +96,7 @@ public void GetPinMode()
9696
}
9797

9898
[Fact]
99+
[Obsolete("Tests an obsolete feature")]
99100
public void UsingBoardNumberingWorks()
100101
{
101102
// Our mock driver maps physical pin 2 to logical pin 1
@@ -122,14 +123,15 @@ public void UsingLogicalNumberingDisposesTheRightPin()
122123
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
123124
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Output)).Returns(true);
124125
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
125-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
126+
var ctrl = new GpioController(_mockedGpioDriver.Object);
126127
ctrl.OpenPin(1, PinMode.Output);
127128
ctrl.Write(1, PinValue.High);
128129
// No close on the pin here, we want to check that the Controller's Dispose works correctly
129130
ctrl.Dispose();
130131
}
131132

132133
[Fact]
134+
[Obsolete("Tests obsolete features")]
133135
public void UsingBoardNumberingDisposesTheRightPin()
134136
{
135137
// Our mock driver maps physical pin 2 to logical pin 1
@@ -151,7 +153,7 @@ public void CallbackOnEventWorks()
151153
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
152154
_mockedGpioDriver.Setup(x => x.AddCallbackForPinValueChangedEventEx(1,
153155
PinEventTypes.Rising, It.IsAny<PinChangeEventHandler>()));
154-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
156+
var ctrl = new GpioController(_mockedGpioDriver.Object);
155157
ctrl.OpenPin(1); // logical pin 1 on our test board
156158
bool callbackSeen = false;
157159
PinChangeEventHandler eventHandler = (sender, args) =>
@@ -183,7 +185,7 @@ public void WriteSpan()
183185
_mockedGpioDriver.Setup(x => x.WriteEx(2, PinValue.Low));
184186
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
185187
_mockedGpioDriver.Setup(x => x.ClosePinEx(2));
186-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
188+
var ctrl = new GpioController(_mockedGpioDriver.Object);
187189
Assert.NotNull(ctrl);
188190
ctrl.OpenPin(1, PinMode.Output);
189191
ctrl.OpenPin(2, PinMode.Output);
@@ -208,7 +210,7 @@ public void ReadSpan()
208210
_mockedGpioDriver.Setup(x => x.ReadEx(2)).Returns(PinValue.High);
209211
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
210212
_mockedGpioDriver.Setup(x => x.ClosePinEx(2));
211-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
213+
var ctrl = new GpioController(_mockedGpioDriver.Object);
212214
Assert.NotNull(ctrl);
213215
ctrl.OpenPin(1, PinMode.Input);
214216
ctrl.OpenPin(2, PinMode.Input);
@@ -238,7 +240,7 @@ public void ReadSpan()
238240
[Fact]
239241
public async Task WaitForEventAsyncFail()
240242
{
241-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
243+
var ctrl = new GpioController(_mockedGpioDriver.Object);
242244
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
243245
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true);
244246
_mockedGpioDriver.Setup(x => x.WaitForEventEx(1, PinEventTypes.Rising | PinEventTypes.Falling, It.IsAny<CancellationToken>()))
@@ -260,7 +262,7 @@ public async Task WaitForEventAsyncFail()
260262
[Fact]
261263
public void WaitForEventSuccess()
262264
{
263-
var ctrl = new GpioController(PinNumberingScheme.Logical, _mockedGpioDriver.Object);
265+
var ctrl = new GpioController(_mockedGpioDriver.Object);
264266
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
265267
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Input)).Returns(true);
266268
_mockedGpioDriver.Setup(x => x.WaitForEventEx(1, PinEventTypes.Rising | PinEventTypes.Falling, It.IsAny<CancellationToken>()))

0 commit comments

Comments
 (0)