mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 03:13:44 +08:00
commander: check for stale arming_check_reply messages
based on the message timestamp. Previously it was possible to run into the following case: - 2 external modes are registered (running inside the same ROS node) - they time out due to the micro xrce agent being blocked for some reason - PX4 removes them - the latest arming check replies still arrive to PX4 - the application restarts - the first mode gets registered - PX4 handles the previous arming check reply, and clears waiting_for_first_response, which reduces the timeout - the second mode registers and as part of that checks for message compatibility. This takes ~1s, triggering a timeout of the first mode
This commit is contained in:
@@ -229,8 +229,10 @@ void ExternalChecks::update()
|
||||
int max_num_updates = arming_check_reply_s::ORB_QUEUE_LENGTH;
|
||||
|
||||
while (_arming_check_reply_sub.update(&reply) && --max_num_updates >= 0) {
|
||||
if (reply.registration_id < MAX_NUM_REGISTRATIONS && registrationValid(reply.registration_id)
|
||||
&& _current_request_id == reply.request_id) {
|
||||
const bool valid = reply.registration_id < MAX_NUM_REGISTRATIONS && registrationValid(reply.registration_id);
|
||||
const bool timed_out = now > reply.timestamp + 300_ms;
|
||||
|
||||
if (!timed_out && valid && _current_request_id == reply.request_id) {
|
||||
_reply_received_mask |= 1u << reply.registration_id;
|
||||
_registrations[reply.registration_id].num_no_response = 0;
|
||||
_registrations[reply.registration_id].waiting_for_first_response = false;
|
||||
|
||||
Reference in New Issue
Block a user