-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plan to remove PinNumberingScheme.Board #2326
Comments
Honestly, I think we should drop support for different PinNumberingScheme's alltogether. It works only for very few boards (namely the RPI3 and 4), and even then only sometimes (as this ticket shows) and has little practical use. Everybody else is working with the logical numbers. |
[Triage] We want to make it go away either directly or through deprecation period first. |
[Triage] changing priority to 0 as we should at least come up with a plan this release. |
[Triage] Plan:
|
Re-openning to track |
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: