mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 12:30:27 +08:00
mavlink: check TX buffer before processing command ack
This commit is contained in:
committed by
Lorenz Meier
parent
8d5813994f
commit
a66cb0cbaf
@@ -2336,24 +2336,27 @@ Mavlink::task_main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* send command ACK */
|
/* send command ACK */
|
||||||
uint16_t current_command_ack = 0;
|
uint16_t current_command_ack = 0;
|
||||||
vehicle_command_ack_s command_ack;
|
|
||||||
|
|
||||||
if (ack_sub.update(&command_ack)) {
|
if (ack_sub.updated() && (get_free_tx_buf() >= MAVLINK_MSG_ID_COMMAND_ACK_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES)) {
|
||||||
if (!command_ack.from_external) {
|
vehicle_command_ack_s command_ack;
|
||||||
mavlink_command_ack_t msg;
|
|
||||||
msg.result = command_ack.result;
|
|
||||||
msg.command = command_ack.command;
|
|
||||||
msg.progress = command_ack.result_param1;
|
|
||||||
msg.result_param2 = command_ack.result_param2;
|
|
||||||
msg.target_system = command_ack.target_system;
|
|
||||||
msg.target_component = command_ack.target_component;
|
|
||||||
current_command_ack = command_ack.command;
|
|
||||||
|
|
||||||
// TODO: always transmit the acknowledge once it is only sent over the instance the command is received
|
if (ack_sub.update(&command_ack)) {
|
||||||
//bool _transmitting_enabled_temp = _transmitting_enabled;
|
if (!command_ack.from_external) {
|
||||||
//_transmitting_enabled = true;
|
mavlink_command_ack_t msg;
|
||||||
mavlink_msg_command_ack_send_struct(get_channel(), &msg);
|
msg.result = command_ack.result;
|
||||||
//_transmitting_enabled = _transmitting_enabled_temp;
|
msg.command = command_ack.command;
|
||||||
|
msg.progress = command_ack.result_param1;
|
||||||
|
msg.result_param2 = command_ack.result_param2;
|
||||||
|
msg.target_system = command_ack.target_system;
|
||||||
|
msg.target_component = command_ack.target_component;
|
||||||
|
current_command_ack = command_ack.command;
|
||||||
|
|
||||||
|
// TODO: always transmit the acknowledge once it is only sent over the instance the command is received
|
||||||
|
//bool _transmitting_enabled_temp = _transmitting_enabled;
|
||||||
|
//_transmitting_enabled = true;
|
||||||
|
mavlink_msg_command_ack_send_struct(get_channel(), &msg);
|
||||||
|
//_transmitting_enabled = _transmitting_enabled_temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user