fix power button shutdown: use an orb topic instead of a work queue call

px4_shutdown_request() was called from the power button IRQ callback, which
invoked a work queue callback. But on NuttX, the work queue uses a
semaphore, and thus it cannot be called from IRQ context.
This patch switches to publishing an uORB msg instead, which is handled in
the commander main thread.

To increase failure resistance, we could subscribe to the same topic in
another module for redundancy, in case commander runs wild.
This commit is contained in:
Beat Küng
2017-07-29 23:10:47 +02:00
committed by Lorenz Meier
parent 61b0a81bf9
commit 2815c62acf
4 changed files with 53 additions and 6 deletions
+1
View File
@@ -81,6 +81,7 @@ set(msg_file_names
parameter_update.msg
position_setpoint.msg
position_setpoint_triplet.msg
power_button_state.msg
pwm_input.msg
qshell_req.msg
rc_channels.msg
+8
View File
@@ -0,0 +1,8 @@
# power button state notification message
uint8 PWR_BUTTON_STATE_IDEL = 0 # Button went up without meeting shutdown button down time (delete event)
uint8 PWR_BUTTON_STATE_DOWN = 1 # Button went Down
uint8 PWR_BUTTON_STATE_UP = 2 # Button went Up
uint8 PWR_BUTTON_STATE_REQUEST_SHUTDOWN = 3 # Button went Up after meeting shutdown button down time
uint8 event # one of PWR_BUTTON_STATE_*