[WIP] UAP_HAL_Linux: Basic safety switch infrastructure #26709
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows Linux boards to define a GPIO pin to be treated as a safety switch. Current implementation assumes an active low disarm with the pin being pulled up (via non-ardupilot means, such as device trees or physically on the PCB etc).
The code isn't directly used anywhere as I test it on a WIP internal branch for now, but it is indeed operational, e.g. shorting the pin to the ground correctly sets a disarmed (1) status:
NOTE: The virtual destructor added deep in the GPIO classes hierarchy not to be locked into a particular flavor of Linux board GPIO. I'm honestly unsure why it wasn't there in first place since
GPIO::channel
does instantiate an object which needs to be eventually freed using a base class pointer. I checked another instances of this method's usage and it seems that the pointer is never freed. So it's either a virtual destructor is indeed needed or Linux sysfs GPIO class needs to be changed in order to track the pointers that are generated by thechannel()
method.