From 8617880714ef575798332b2560fc1e7d9b2edd84 Mon Sep 17 00:00:00 2001 From: Tom Pittenger Date: Mon, 18 Jul 2016 15:05:27 -0700 Subject: [PATCH] AP_ADSB: check buffer space before sending --- libraries/AP_ADSB/AP_ADSB.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/AP_ADSB/AP_ADSB.cpp b/libraries/AP_ADSB/AP_ADSB.cpp index 42f9caf486..0e231460e7 100644 --- a/libraries/AP_ADSB/AP_ADSB.cpp +++ b/libraries/AP_ADSB/AP_ADSB.cpp @@ -219,16 +219,17 @@ void AP_ADSB::update(void) // haven't gotten a heartbeat health status packet in a while, assume hardware failure out_state.chan = -1; } else { - if (now - out_state.last_config_ms >= 5000) { - out_state.last_config_ms = now; - send_configure((mavlink_channel_t)(MAVLINK_COMM_0 + out_state.chan)); - } // last_config_ms + mavlink_channel_t chan = (mavlink_channel_t)(MAVLINK_COMM_0 + out_state.chan); + if (now - out_state.last_config_ms >= 5000 && HAVE_PAYLOAD_SPACE(chan, ADSB_TRANSPONDER_STATIC_INPUT)) { + out_state.last_config_ms = now; + send_configure(chan); + } // last_config_ms // send dynamic data to transceiver at 5Hz - if (now - out_state.last_report_ms >= 200) { - out_state.last_report_ms = now; - send_dynamic_out((mavlink_channel_t)(MAVLINK_COMM_0 + out_state.chan)); - } // last_report_ms + if (now - out_state.last_report_ms >= 200 && HAVE_PAYLOAD_SPACE(chan, ADSB_TRANSPONDER_DYNAMIC_INPUT)) { + out_state.last_report_ms = now; + send_dynamic_out(chan); + } // last_report_ms } // chan_last_ms } }