From 0b811ba6a99cd8cc6dc456e7e51347b1179f5a01 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 19 Mar 2014 06:43:22 +1100 Subject: [PATCH] GCS_MAVLink: added have_flow_control() method can be used to change speed of handling some protocol methods, as we know communication will be reliable --- libraries/GCS_MAVLink/GCS.h | 4 ++++ libraries/GCS_MAVLink/GCS_Common.cpp | 19 +++++++++++++++++++ libraries/GCS_MAVLink/GCS_Logs.cpp | 7 +------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 2e4f431aa8..54e6f4273c 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -287,10 +287,14 @@ private: void handle_mission_request_list(AP_Mission &mission, mavlink_message_t *msg); void handle_mission_request(AP_Mission &mission, mavlink_message_t *msg, AP_Mission::Mission_Command &cmd); + void handle_mission_set_current(AP_Mission &mission, mavlink_message_t *msg); void handle_mission_count(AP_Mission &mission, mavlink_message_t *msg); void handle_mission_clear_all(AP_Mission &mission, mavlink_message_t *msg); void handle_mission_write_partial_list(AP_Mission &mission, mavlink_message_t *msg); + + // return true if this channel has hardware flow control + bool have_flow_control(void); }; #endif // __GCS_H diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index c248c1eeac..ac0d8e08e6 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -365,3 +365,22 @@ void GCS_MAVLINK::handle_mission_write_partial_list(AP_Mission &mission, mavlink waypoint_request_i = packet.start_index; waypoint_request_last= packet.end_index; } + +/* + return true if a channel has flow control + */ +bool GCS_MAVLINK::have_flow_control(void) +{ + switch (chan) { + case MAVLINK_COMM_0: + // assume USB has flow control + return hal.gpio->usb_connected() || hal.uartA->get_flow_control() != AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE; + + case MAVLINK_COMM_1: + return hal.uartC->get_flow_control() != AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE; + + case MAVLINK_COMM_2: + return hal.uartD != NULL && hal.uartD->get_flow_control() != AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE; + } + return false; +} diff --git a/libraries/GCS_MAVLink/GCS_Logs.cpp b/libraries/GCS_MAVLink/GCS_Logs.cpp index 6afc39ddaf..9eda803103 100644 --- a/libraries/GCS_MAVLink/GCS_Logs.cpp +++ b/libraries/GCS_MAVLink/GCS_Logs.cpp @@ -141,12 +141,7 @@ void GCS_MAVLINK::handle_log_send(DataFlash_Class &dataflash) if (chan == MAVLINK_COMM_0 && hal.gpio->usb_connected()) { // when on USB we can send a lot more data num_sends = 40; - } else if (chan == MAVLINK_COMM_1 && - hal.uartC->get_flow_control() != AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE) { - num_sends = 10; - } else if (chan == MAVLINK_COMM_2 && - hal.uartD != NULL && - hal.uartD->get_flow_control() != AP_HAL::UARTDriver::FLOW_CONTROL_DISABLE) { + } else if (have_flow_control()) { num_sends = 10; }