Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ stages:
markdownlint -c $(System.DefaultWorkingDirectory)/.markdownlint.json $(System.DefaultWorkingDirectory)
displayName: 'Execute Markdownlint'
condition: eq(variables['build.reason'], 'PullRequest')
continueOnError: true

# Hint: Add /maxCpuCount:1 to disable parellelization in build. Ensures all tests results are printed to the console
- script: build.cmd -ci
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!-- Packaging related properties -->
<PropertyGroup>
<MajorVersion>4</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>1</PatchVersion>
<MinorVersion>2</MinorVersion>
<PatchVersion>0</PatchVersion>
<Description>This package contains the BitmapImage adapter using SkiaSharp. This library is an optional package to provide imaging functionality for Iot.Device.Bidnings.dll</Description>
<PackageTags>.NET Core IoT Device Bindings SkiaSharp Adapter</PackageTags>
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>3.1.0</PackageValidationBaselineVersion>
<PackageValidationBaselineVersion>4.0.1</PackageValidationBaselineVersion>
</PropertyGroup>

<Import Project="../../Directory.Build.props" />
Expand Down
44 changes: 39 additions & 5 deletions src/Iot.Device.Bindings/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
<Target>.NETStandard,Version=v2.0</Target>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Iot.Device.Usb.BatteryObject.get_MaximalVoltage</Target>
<Left>lib/net8.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net8.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
<Target>net6.0</Target>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Iot.Device.Usb.BatteryObject.get_MinimalVoltage</Target>
<Left>lib/net8.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net8.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Iot.Device.Usb.FixedSupplyObject.get_Voltage</Target>
<Left>lib/net8.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net8.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Iot.Device.Usb.StUsb4500.get_RequestedVoltage</Target>
<Left>lib/net8.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net8.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Iot.Device.Usb.VariableSupplyObject.get_MaximalVoltage</Target>
<Left>lib/net8.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net8.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Iot.Device.Usb.VariableSupplyObject.get_MinimalVoltage</Target>
<Left>lib/net8.0/Iot.Device.Bindings.dll</Left>
<Right>lib/net8.0/Iot.Device.Bindings.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
</Suppressions>
6 changes: 3 additions & 3 deletions src/Iot.Device.Bindings/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!-- Packaging related properties -->
<PropertyGroup>
<MajorVersion>4</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>1</PatchVersion>
<MinorVersion>2</MinorVersion>
<PatchVersion>0</PatchVersion>
<Description>This package provides a set of Device Bindings ("Device drivers") that use System.Device.Gpio package to communicate with sensors and microcontrollers.</Description>
<PackageTags>.NET GPIO Pins SPI I2C PWM RPi IoT Device Bindings</PackageTags>
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>3.1.0</PackageValidationBaselineVersion>
<PackageValidationBaselineVersion>4.0.1</PackageValidationBaselineVersion>
</PropertyGroup>

<Import Project="../../Directory.Build.props" />
Expand Down
61 changes: 0 additions & 61 deletions src/System.Device.Gpio.Tests/GpioControllerSoftwareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,6 @@ public void GetPinMode()
Assert.Equal(PinMode.Output, ctrl.GetPinMode(1));
}

[Fact]
[Obsolete("Tests an obsolete feature")]
public void UsingBoardNumberingWorks()
{
// Our mock driver maps physical pin 2 to logical pin 1
_mockedGpioDriver.Setup(x => x.ConvertPinNumberToLogicalNumberingSchemeEx(2)).Returns(1);
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
_mockedGpioDriver.Setup(x => x.SetPinModeEx(1, PinMode.Output));
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Output)).Returns(true);
_mockedGpioDriver.Setup(x => x.GetPinModeEx(1)).Returns(PinMode.Output);
_mockedGpioDriver.Setup(x => x.WriteEx(1, PinValue.High));
_mockedGpioDriver.Setup(x => x.ReadEx(1)).Returns(PinValue.High);
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
var ctrl = new GpioController(PinNumberingScheme.Board, _mockedGpioDriver.Object);
ctrl.OpenPin(2, PinMode.Output);
ctrl.Write(2, PinValue.High);
Assert.Equal(PinValue.High, ctrl.Read(2));
ctrl.ClosePin(2);
ctrl.Dispose();
}

[Fact]
public void UsingLogicalNumberingDisposesTheRightPin()
{
Expand All @@ -130,22 +109,6 @@ public void UsingLogicalNumberingDisposesTheRightPin()
ctrl.Dispose();
}

[Fact]
[Obsolete("Tests obsolete features")]
public void UsingBoardNumberingDisposesTheRightPin()
{
// Our mock driver maps physical pin 2 to logical pin 1
_mockedGpioDriver.Setup(x => x.ConvertPinNumberToLogicalNumberingSchemeEx(2)).Returns(1);
_mockedGpioDriver.Setup(x => x.OpenPinEx(1));
_mockedGpioDriver.Setup(x => x.SetPinModeEx(1, PinMode.Output));
_mockedGpioDriver.Setup(x => x.ClosePinEx(1));
_mockedGpioDriver.Setup(x => x.IsPinModeSupportedEx(1, PinMode.Output)).Returns(true);
var ctrl = new GpioController(PinNumberingScheme.Board, _mockedGpioDriver.Object);
ctrl.OpenPin(2, PinMode.Output);
// No close on the pin here, we want to check that the Controller's Dispose works correctly
ctrl.Dispose();
}

[Fact]
public void CallbackOnEventWorks()
{
Expand Down Expand Up @@ -279,28 +242,4 @@ public void WaitForEventSuccess()
Assert.Equal(PinEventTypes.Falling, result.EventTypes);
}

// TODO: This is still broken. See #974
////[Fact]
////public void UsingBoardNumberingForCallbackWorks()
////{
//// // Our mock driver maps physical pin 2 to logical pin 1
//// _mockedGpioDriver.Setup(x => x.ConvertPinNumberToLogicalNumberingSchemeEx(2)).Returns(1);
//// _mockedGpioDriver.Setup(x => x.OpenPinEx(1));
//// _mockedGpioDriver.Setup(x => x.AddCallbackForPinValueChangedEventEx(1,
//// PinEventTypes.Rising, It.IsAny<PinChangeEventHandler>()));
//// var ctrl = new GpioController(PinNumberingScheme.Board, _mockedGpioDriver.Object);
//// ctrl.OpenPin(2); // logical pin 1 on our test board
//// bool callbackSeen = false;
//// ctrl.RegisterCallbackForPinValueChangedEvent(2, PinEventTypes.Rising, (sender, args) =>
//// {
//// callbackSeen = true;
//// Assert.Equal(2, args.PinNumber);
//// Assert.Equal(PinEventTypes.Falling, args.ChangeType);
//// });

//// _mockedGpioDriver.Object.FireEventHandler(1, PinEventTypes.Falling);

//// Assert.True(callbackSeen);
////}

}
30 changes: 23 additions & 7 deletions src/System.Device.Gpio/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
<Target>.NETStandard,Version=v2.0</Target>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Device.Gpio.PinNumberingScheme</Target>
<Left>lib/net8.0/System.Device.Gpio.dll</Left>
<Right>lib/net8.0/System.Device.Gpio.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
<Target>net6.0</Target>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:System.Device.Gpio.GpioController.#ctor(System.Device.Gpio.PinNumberingScheme,System.Device.Gpio.GpioDriver)</Target>
<Left>lib/net8.0/System.Device.Gpio.dll</Left>
<Right>lib/net8.0/System.Device.Gpio.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>PKV006</DiagnosticId>
<Target>net6.0-windows10.0.17763</Target>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:System.Device.Gpio.GpioController.#ctor(System.Device.Gpio.PinNumberingScheme)</Target>
<Left>lib/net8.0/System.Device.Gpio.dll</Left>
<Right>lib/net8.0/System.Device.Gpio.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:System.Device.Gpio.GpioController.get_NumberingScheme</Target>
<Left>lib/net8.0/System.Device.Gpio.dll</Left>
<Right>lib/net8.0/System.Device.Gpio.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
</Suppressions>
6 changes: 3 additions & 3 deletions src/System.Device.Gpio/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!-- Packaging related properties -->
<PropertyGroup>
<MajorVersion>4</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>1</PatchVersion>
<MinorVersion>2</MinorVersion>
<PatchVersion>0</PatchVersion>
<Description>The System.Device.Gpio package supports general-purpose I/O (GPIO) pins, PWM, I2C, SPI and related interfaces for interacting with low level hardware pins to control hardware sensors, displays and input devices on single-board-computers; Raspberry Pi, BeagleBoard, ODROID, and other single-board-computers that are supported by Linux or Windows and can run .NET. Depending on the OS and hardware, various low-level drivers are available. Additionally, hardware interfaces connected trough Serial ports or USB are also supported.
</Description>
<PackageTags>.NET GPIO Pins SPI I2C PWM RPi IoT</PackageTags>
<PackageValidationBaselineVersion>3.1.0</PackageValidationBaselineVersion>
<PackageValidationBaselineVersion>4.0.1</PackageValidationBaselineVersion>
<EnablePackageValidation>true</EnablePackageValidation>
</PropertyGroup>

Expand Down
45 changes: 3 additions & 42 deletions src/System.Device.Gpio/System/Device/Gpio/GpioController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,59 +37,22 @@ public class GpioController : IDisposable
/// Initializes a new instance of the <see cref="GpioController"/> class that will use the logical pin numbering scheme as default.
/// </summary>
public GpioController()
#pragma warning disable CS0612 // PinNumberingScheme is obsolete
: this(PinNumberingScheme.Logical)
#pragma warning restore CS0612
: this(GetBestDriverForBoard())
{
}

/// <summary>
/// Initializes a new instance of the <see cref="GpioController"/> class that will use the specified numbering scheme and driver.
/// Initializes a new instance of the <see cref="GpioController"/> class that will use the specified driver.
/// </summary>
/// <param name="driver">The driver that manages all of the pin operations for the controller.</param>
public GpioController(GpioDriver driver)
{
_driver = driver;

#pragma warning disable CS0612 // PinNumberingScheme is obsolete
NumberingScheme = PinNumberingScheme.Logical;
#pragma warning restore CS0612

_openPins = new ConcurrentDictionary<int, PinValue?>();
_gpioPins = new ConcurrentDictionary<int, GpioPin>();
}

/// <summary>
/// Initializes a new instance of the <see cref="GpioController"/> class that will use the specified numbering scheme and driver.
/// </summary>
/// <param name="numberingScheme">The numbering scheme used to represent pins provided by the controller.</param>
/// <param name="driver">The driver that manages all of the pin operations for the controller.</param>
[Obsolete]
public GpioController(PinNumberingScheme numberingScheme, GpioDriver driver)
{
_driver = driver;
NumberingScheme = numberingScheme;
_openPins = new ConcurrentDictionary<int, PinValue?>();
_gpioPins = new ConcurrentDictionary<int, GpioPin>();
}

/// <summary>
/// Initializes a new instance of the <see cref="GpioController"/> class that will use the specified numbering scheme.
/// The controller will default to use the driver that best applies given the platform the program is executing on.
/// </summary>
/// <param name="numberingScheme">The numbering scheme used to represent pins provided by the controller.</param>
[Obsolete]
public GpioController(PinNumberingScheme numberingScheme)
: this(numberingScheme, GetBestDriverForBoard())
{
}

/// <summary>
/// The numbering scheme used to represent pins provided by the controller.
/// </summary>
[Obsolete]
public PinNumberingScheme NumberingScheme { get; }

/// <summary>
/// The number of pins provided by the controller.
/// </summary>
Expand Down Expand Up @@ -120,9 +83,7 @@ private IEnumerable<GpioPin> OpenPins
/// <returns>The logical pin number in the controller's numbering scheme.</returns>
protected virtual int GetLogicalPinNumber(int pinNumber)
{
#pragma warning disable CS0612 // PinNumberingScheme is obsolete
return (NumberingScheme == PinNumberingScheme.Logical) ? pinNumber : _driver.ConvertPinNumberToLogicalNumberingScheme(pinNumber);
#pragma warning restore CS0612
return pinNumber;
}

/// <summary>
Expand Down
22 changes: 0 additions & 22 deletions src/System.Device.Gpio/System/Device/Gpio/PinNumberingScheme.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Loop()

public static void RunBlink(int pin, int delay)
{
var gpioController = new GpioController(PinNumberingScheme.Logical, new ArduinoNativeGpioDriver());
var gpioController = new GpioController(new ArduinoNativeGpioDriver());
SimpleLedBinding blink = new SimpleLedBinding(gpioController, pin, delay);
blink.Loop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ccs811/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ To create a device using an external chipset like FT4222 to offer GPIO and I2C s

```csharp
var ftdiI2C = new Ft4222I2c(new I2cConnectionSettings(0, Ccs811Sensor.I2cFirstAddress));
var gpioController = new GpioController(PinNumberingScheme.Board, new Ft4222Gpio());
var gpioController = new GpioController(new Ft4222Gpio());
ccs811 = new Ccs811Sensor(ftdiI2C, gpioController, 3, 2, -1, false);
```

Expand Down
2 changes: 1 addition & 1 deletion src/devices/Dhtxx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ See this [issue 1145](https://github.com/dotnet/iot/issues/1145). We're actively

```csharp
GpioDriver driver = new RaspberryPi3Driver();
var controller = new GpioController(PinNumberingScheme.Logical, driver);
var controller = new GpioController(driver);
// This uses pin 4 in the logical schema so pin 7 in the physical schema
var dht = new Dht11(4, gpioController: controller);
```
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ft232H/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Let's assume your device is the first one, you'll be able to create a GPIO Contr
```csharp
var ft232h = new Ft232HDevice(devices[0]);
var gpio = ft232h.CreateGpioDriver();
GpioController controller = new(PinNumberingScheme.Board, gpio);
GpioController controller = new(gpio);
```

> Important notes:
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ft4222/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The example below shows how to blink a led on GPIO2 and then read the value. It'

```csharp
const int Gpio2 = 2;
var gpioController = new GpioController(PinNumberingScheme.Board, new Ft4222Gpio());
var gpioController = new GpioController(new Ft4222Gpio());

// Opening GPIO2
gpioController.OpenPin(Gpio2);
Expand Down
Loading
Loading