PinNumberingScheme.Board is broken #2326
Labels
bug
Something isn't working
Priority:1
Work that is critical for the release, but we could probably ship without
Describe the bug
Using PinNumberingScheme.Board seems broken. I had a problem when writing a BoagleBoard driver, and looked at the RaspberryPi driver to see how it was handled there. It seems that trying to use PinNumberingScheme.Board on the Raspberry Pi - and probably any board - doesn't work.
Steps to reproduce
This code fails with System.ArgumentException: The specified pin number is invalid. (Parameter 'pinNumber'):
This code - using Logical numbering to refer to the same pin works fine:
Both snippets of code refer to the same pin - logical pin 20 which is pin 38 of the Pi 3 header
Expected behavior
The pin value should be read
Actual behavior
Some Investigation
I've tracked down what I believe to be the issue.
When the pin is created, the board value 38 is correctly mapped to the logical value of 20 in RaspberryPi3LinuxDriver.ConvertPinNumberToLogicalNumberingScheme(). However, from this point on, the pin number of the GpioPin remains 38. When the Read() operation occurs, the driver treats the pin number as if it was a logical pin 38 and this is not valid. (If the Board pin number was below 28, then the Read() operation would potentially read the wrong pin instead of throwing an exception.) The GpioPin has no concept of whether it was created as a Board or Logical pin.
A potential solution would be for a GpioPin to contain both the pin number used to refer to it and also the pin number used by the driver. There's some overlap with concepts in the Virtual Contoller and Pin code in #2180, but it's not quite the same.
Versions used
This is running using the latest code from the main branch compiled locally. Tested on a Pi3 running latest 64-bit OS.
The text was updated successfully, but these errors were encountered: