dotnet / iot

This repo includes .NET Core implementations for various IoT boards, chips, displays and PCBs.
MIT License
2.12k stars 574 forks source link

Unable to set pin mode on pi5 #2300

Closed IamRewt closed 2 months ago

IamRewt commented 3 months ago

Describe the bug

After updating to version 3.1.0, I am unable to read or set modes on gpio pins on the raspberry pi 5. The library works properly when reverting to 3.0.0.   Error Message: Unhandled exception. System.IO.IOException: Error setting pin mode, for pin: 4, error: 16. Steps to reproduce

 var gpio = new GpioController();
 gpio.OpenPin(4);
 gpio.SetPinMode(4, PinMode.Input); <-- Throws error.
 Console.WriteLine(gpio.Read(4));

Expected behavior

The pin should set and be readable.

Actual behavior

The pin does not get set and the error message is thrown.

Versions used

pgrawehr commented 3 months ago

That's kind of expected, since we do not have full support for the pi 5 yet. You need to manually select the driver (either libgpiod or sysfs)

IamRewt commented 3 months ago

There may have been a regression, related to the pi 5, with version 3.1.0 as the gpio seems to function normally in 3.0.0. The above code runs without error and properly reads the pins. I haven't tested all of the gpio pins but have tried several of them without issue.

Given the 5 is still fairly new, I can go back to testing with a 4 for now.

pgrawehr commented 3 months ago

We have added partial support for the Pi5 in 3.1.0 (IIRC), but you should get it to work by calling

var gpioController = new GpioController(new LibgpiodDriver(4));
dotnet-policy-service[bot] commented 3 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.