-
Notifications
You must be signed in to change notification settings - Fork 605
Description
Is your feature request related to a problem? Please describe.
One of the advantages of libgpiod over the sysfs gpio interface is the ability to read and write to multiple pins simultaneously.
The current implementation does not take advantage of this.
The GpioController just loops through the collection of pins.
iot/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs
Lines 331 to 354 in 00f9da1
| /// <summary> | |
| /// Write the given pins with the given values. | |
| /// </summary> | |
| /// <param name="pinValuePairs">The pin/value pairs to write.</param> | |
| public void Write(ReadOnlySpan<PinValuePair> pinValuePairs) | |
| { | |
| for (int i = 0; i < pinValuePairs.Length; i++) | |
| { | |
| Write(pinValuePairs[i].PinNumber, pinValuePairs[i].PinValue); | |
| } | |
| } | |
| /// <summary> | |
| /// Read the given pins with the given pin numbers. | |
| /// </summary> | |
| /// <param name="pinValuePairs">The pin/value pairs to read.</param> | |
| public void Read(Span<PinValuePair> pinValuePairs) | |
| { | |
| for (int i = 0; i < pinValuePairs.Length; i++) | |
| { | |
| int pin = pinValuePairs[i].PinNumber; | |
| pinValuePairs[i] = new PinValuePair(pin, Read(pin)); | |
| } | |
| } |
Describe the ideal solution
Add two new virtual methods to GpioDriver for read/write multiple and move the logic from GpioController into them. e.g.
internal virtual void Write(ReadOnlySpan<PinValuePair> pinValuePairs)
{
//...
}
internal virtual void Read(Span<PinValuePair> pinValuePairs)
{
//...
}Then LibGpiodDriver can override these methods with calls to the appropriate functions.
This allows the vast majority of drivers to continue functioning as they do today, while allowing us to take advantage of the simultaneous read/writes of libgpiod.
I believe this is a backward compatible change.