Skip to content

Commit 81eec32

Browse files
committed
Mark new stuff experimental for now
1 parent f570cd2 commit 81eec32

File tree

7 files changed

+44
-9
lines changed

7 files changed

+44
-9
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Xunit;
77
using Xunit.Abstractions;
88

9+
#pragma warning disable SDGPIO0001
910
namespace System.Device.Gpio.Tests;
1011

1112
[Trait("requirement", "root")]
@@ -47,7 +48,7 @@ public void CheckAllChipsCanBeConstructed()
4748

4849
foreach (var chip in chips)
4950
{
50-
var driver = new SysFsDriver(chip.Id);
51+
var driver = new SysFsDriver(chip);
5152
var ctrl = new GpioController(driver);
5253
Assert.NotNull(ctrl);
5354
var driverInfo = driver.GetChipInfo();

src/System.Device.Gpio/System/Device/Gpio/Drivers/LibGpiodDriver.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using System.Device.Gpio.Libgpiod.V1;
99
using System.Diagnostics;
1010
using System.Linq;
11+
using System.Diagnostics.CodeAnalysis;
12+
1113
using LibgpiodV1 = Interop.LibgpiodV1;
1214

1315
namespace System.Device.Gpio.Drivers;
@@ -93,10 +95,21 @@ public LibGpiodDriver(int gpioChip = 0)
9395
}
9496
}
9597

98+
/// <summary>
99+
/// Construct an instance of this driver with the provided chip.
100+
/// </summary>
101+
/// <param name="chip">The chip to use. Should be one of the elements returned by <see cref="GetAvailableChips"/></param>
102+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
103+
public LibGpiodDriver(GpioChipInfo chip)
104+
: this(chip.Id)
105+
{
106+
}
107+
96108
/// <summary>
97109
/// Returns the set of available chips for this driver
98110
/// </summary>
99111
/// <returns>A list of <see cref="GpioChipInfo"/> instances</returns>
112+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
100113
public static IList<GpioChipInfo> GetAvailableChips()
101114
{
102115
List<GpioChipInfo> result = new List<GpioChipInfo>();
@@ -448,6 +461,7 @@ public override ComponentInformation QueryComponentInformation()
448461
}
449462

450463
/// <inheritdoc />
464+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
451465
public override GpioChipInfo GetChipInfo()
452466
{
453467
return GetAvailableChips().First(x => x.Id == _chipNumber);

src/System.Device.Gpio/System/Device/Gpio/Drivers/LibGpiodV2Driver.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,20 @@ public sealed class LibGpiodV2Driver : UnixDriver
3636
/// Creates a driver instance for the specified GPIO chip.
3737
/// </summary>
3838
/// <param name="chipNumber">Chip number to use.</param>
39-
/// <param name="waitEdgeEventsTimeout">Timeout to wait for edge events. Primarily used for testing.</param>
40-
public LibGpiodV2Driver(int chipNumber, TimeSpan? waitEdgeEventsTimeout = null)
39+
public LibGpiodV2Driver(int chipNumber)
4140
{
4241
_chip = LibGpiodProxyFactory.CreateChip(chipNumber);
43-
_eventObserver = new LibGpiodV2EventObserver { WaitEdgeEventsTimeout = waitEdgeEventsTimeout ?? TimeSpan.FromMilliseconds(100) };
42+
_eventObserver = new LibGpiodV2EventObserver { WaitEdgeEventsTimeout = TimeSpan.FromMilliseconds(100) };
43+
}
44+
45+
/// <summary>
46+
/// Construct an instance of this driver with the provided chip.
47+
/// </summary>
48+
/// <param name="chip">The chip to use. Should be one of the elements returned by <see cref="GetAvailableChips"/></param>
49+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
50+
public LibGpiodV2Driver(GpioChipInfo chip)
51+
: this(chip.Id)
52+
{
4453
}
4554

4655
/// <inheritdoc/>

src/System.Device.Gpio/System/Device/Gpio/Drivers/SysFsDriver.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Generic;
5+
using System.Diagnostics.CodeAnalysis;
56
using System.Globalization;
67
using System.IO;
78
using System.Linq;
@@ -86,18 +87,19 @@ public SysFsDriver()
8687
/// <summary>
8788
/// Creates a SysFsDriver instance for the provided chip number
8889
/// </summary>
89-
/// <param name="chip">The chip number to select (use <see cref="GetAvailableChips"/> to query the list of available values)</param>
90+
/// <param name="chip">The chip to select (use <see cref="GetAvailableChips"/> to query the list of available values)</param>
9091
/// <exception cref="PlatformNotSupportedException"></exception>
91-
public SysFsDriver(int chip)
92+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
93+
public SysFsDriver(GpioChipInfo chip)
9294
{
9395
if (Environment.OSVersion.Platform != PlatformID.Unix)
9496
{
9597
throw new PlatformNotSupportedException($"{GetType().Name} is only supported on Linux/Unix.");
9698
}
9799

98100
_isDisposed = false;
99-
_chipNumber = chip;
100-
_pinOffset = ReadOffset(chip);
101+
_chipNumber = chip.Id;
102+
_pinOffset = ReadOffset(chip.Id);
101103
}
102104

103105
/// <summary>
@@ -120,6 +122,7 @@ internal TimeSpan StatusUpdateSleepTime
120122
/// This can be used to determine the correct gpio chip for constructor calls to <see cref="LibGpiodDriver"/>
121123
/// </summary>
122124
/// <returns>A list of chips detected</returns>
125+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
123126
public static IList<GpioChipInfo> GetAvailableChips()
124127
{
125128
string[] fileNames = Directory.GetFileSystemEntries(GpioBasePath, $"{GpioChip}*", SearchOption.TopDirectoryOnly);
@@ -167,6 +170,7 @@ public static IList<GpioChipInfo> GetAvailableChips()
167170
return list;
168171
}
169172

173+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
170174
private static GpioChipInfo GetChipInfoForName(string name)
171175
{
172176
int idx = name.IndexOf(GpioChip, StringComparison.Ordinal);
@@ -701,6 +705,7 @@ protected override void Dispose(bool disposing)
701705
}
702706

703707
/// <inheritdoc />
708+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
704709
public override GpioChipInfo GetChipInfo()
705710
{
706711
return GetAvailableChips().First(x => x.Id == _chipNumber);

src/System.Device.Gpio/System/Device/Gpio/GpioChipInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace System.Device.Gpio
57
{
68
/// <summary>
79
/// Provides information about a GPIO chip
810
/// </summary>
11+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
912
public record GpioChipInfo(int Id, string Name, string Label, int NumLines)
1013
{
1114
/// <summary>

src/System.Device.Gpio/System/Device/Gpio/GpioController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,15 @@ private static GpioDriver GetBestDriverForBoardOnLinux()
534534
// For now, for Raspberry Pi 5, we'll use the LibGpiodDriver.
535535
// We need to create a new driver for the Raspberry Pi 5,
536536
// because the Raspberry Pi 5 uses an entirely different GPIO controller (RP1)
537+
#pragma warning disable SDGPIO0001
537538
var chips = LibGpiodDriver.GetAvailableChips();
538539
// The RP1 chip reports 54 lines
539540
GpioChipInfo? selectedChip = chips.FirstOrDefault(x => x.NumLines == 54);
540541
if (selectedChip is null)
541542
{
542543
throw new NotSupportedException("Couldn't find the default GPIO chip. You might need to create the LibGpiodDriver explicitly");
543544
}
544-
545+
#pragma warning restore SDGPIO0001
545546
return new LibGpiodDriver(selectedChip.Id);
546547

547548
default:

src/System.Device.Gpio/System/Device/Gpio/GpioDriver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using System.Threading;
56
using System.Threading.Tasks;
67

@@ -176,6 +177,7 @@ public virtual ComponentInformation QueryComponentInformation()
176177
/// </summary>
177178
/// <returns>An instance of the <see cref="GpioChipInfo"/> record</returns>
178179
/// <exception cref="NotSupportedException">The current driver does not support this data</exception>
180+
[Experimental(DiagnosticIds.SDGPIO0001, UrlFormat = DiagnosticIds.UrlFormat)]
179181
public virtual GpioChipInfo GetChipInfo()
180182
{
181183
throw new NotSupportedException();

0 commit comments

Comments
 (0)