-
Notifications
You must be signed in to change notification settings - Fork 9
fix(flutter_gpiod)!: Support cases in which the GPIO chip numbers are not a sequence #37
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
Conversation
|
I am having an issue right now that I think is related to this. I can't run my app at all because of a FileSystem error stating that gpiochip2 can't be found. I think this would resolve the issue. |
|
Sorry, was on vacation for the past 2 weeks. Thanks for the fix! |
|
You're right it is a bit problematic, making the elements nullable would mean people would have to add null-safety assertions everywhere. Making it a Map would break easy iteration over the elements. A sparse list would be good but that also breaks if people do old-school I think I'd go with the Map, it is a breaking change and I'll have to increase major versions, but there's no other way around AFAICT |
ardera
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest of the code looks good to me though 👍
5546891 to
8a64485
Compare
|
I went ahead and changed it to map as discussed, and hopefully caught every reference to the list in comments, examples, and the documentation. As a heads-up, while I adjusted the integration tests accordingly, it is beyond me on how to actually execute them with my current setup. While a quick manual check seems to work as expected, you probably still want to run them :) |
|
Looks good. Thanks a lot for the fix! Btw, it could be that we need to be even more conservative in the future. I just checked how And Doesn't even have the concept of a chip index. AFAICT the only thing that can be reliably used as an identifier is the chip name, which is a string. But changing that would be a pretty big change, so I think it can be delayed for now. Maybe it can be done in combination with the support for the GPIOD v2 ABI. |
Currently,
flutter_gpiodassumes the GPIO numbers to be a sequence and therefore reconstructs the file descriptor paths accordinglyOn more recent images of the Raspberry Pi OS, the GPIO chip numbers are no longer a sequence, causing any app using
flutter_gpiodto crash during the initialization process. In particular,/dev/gpiochip3does not exists but/dev/gpiochip4, which seems to also map the chipbcm2835in my case. Apparently this is related to changes introduced for the Raspberry Pi 5.I propose to not rely on the reconstruction of the device file paths, but use the paths already queried to solve this issue. The implementation in this PR worked for me and but does not garantuar that the index in the list
FlutterGpiod.instance.chipsmatches the chip number as the following comment states:Also, this example
fails as their are now two entries with the same chip label. Using
firstWhereinstead ofsingleWherestill works. I suppose this does not need any changes to the library itself but in the documentation, as this affects specifically Raspberry Pi devices.Using a map instead of a list for
FlutterGpiod.instance.chipsseems the most fitting to me right now, but I am not sure. It looks like a breaking change is unavoidable in order to fix this issue. Let me know your thoughts on this.…and thank you for this handy library :)