I am working on modifying the ArduPilot codebase to read the state of the safety button. Here’s what I’ve done so far:
- Modifying
safety_update
:
Inside/ardupilot/libraries/AP_IOMCU/iofirmware
, in thevoid AP_IOMCU_FW::safety_update(void)
method, Im using the following line to read the button state:
bool safety_pressed = palReadLine(HAL_GPIO_PIN_SAFETY_INPUT);
After reading the button state, I pass the value of safety_pressed
to a new method I created in AP_HAL_CHIBIOS
.
I added a method in AP_HAL_CHIBIOS
to store the safety_pressed
value received from the previous method. I also created another method in AP_HAL_CHIBIOS
to return the safety_pressed
value.
From another file in the library folder, I call the method to retrieve safety_pressed
and print the value using:
GCS_SEND_TEXT(MAV_SEVERITY_INFO, “Safety Button State: %d”, safety_pressed);
But the problem is:
The value of safety_pressed
always remains 0
, even when I press the safety button.
Did I miss something???
i also compile the firmware the iomcu
and then i compile and upload the copter to the pixhawk orange cube
Any guidance or insights would be greatly appreciated.
Thank you!