pjgpetecodes / rpirobot

A Raspberry Pi Robot Arm using .NET
47 stars 5 forks source link

Update 06-flash-led.md #7

Closed eoinward closed 3 years ago

eoinward commented 3 years ago

Currently on your Garage course and working "On the Flash LEDs": https://github.com/pjgpetecodes/rpirobot/blob/main/workshop/06-flash-led.md

I am getting an error using a PIE 3

Unhandled exception. System.PlatformNotSupportedException: This driver is generic so it can not perform conversions between pin numbering schemes. at System.Device.Gpio.Drivers.SysFsDriver.ConvertPinNumberToLogicalNumberingScheme(Int32 pinNumber) at System.Device.Gpio.GpioController.GetLogicalPinNumber(Int32 pinNumber) at System.Device.Gpio.GpioController.OpenPinCore(Int32 pinNumber) at System.Device.Gpio.GpioController.OpenPin(Int32 pinNumber) at System.Device.Gpio.GpioController.OpenPin(Int32 pinNumber, PinMode mode) at robot_firmware.Program.Main(String[] args) in /home/pi/share/robot_firmware/Program.cs:line 19

You can force the System.Device.Gpio.Drivers.RaspberryPi3LinuxDriver rather than it falling through to the generic

         var assembly = typeof(GpioDriver).Assembly;

        var driverType = assembly.GetType("System.Device.Gpio.Drivers.RaspberryPi3LinuxDriver");

         var ctor = driverType.GetConstructor(new Type[]{});

         var driver = ctor.Invoke(null) as GpioDriver;

         GpioController controller = new GpioController(PinNumberingScheme.Board, driver);

Maybe just a note for future users if they are still on an old Pi they could just add to all the code: Solution form here: https://www.gitmemory.com/issue/dotnet/iot/1329/735402962

eoinward commented 3 years ago

Issue with Pi2 not Pi3.