APM: added new TELEM_DELAY parameter

number of seconds to delay telemetry
This commit is contained in:
Andrew Tridgell 2012-08-30 08:59:39 +10:00
parent a9af6e95cb
commit f6c3197cd2
4 changed files with 38 additions and 11 deletions

View File

@ -474,15 +474,38 @@ static void NOINLINE send_statustext(mavlink_channel_t chan)
pending_status.text);
}
// are we still delaying telemetry to try to avoid Xbee bricking?
static bool telemetry_delayed(mavlink_channel_t chan)
{
uint32_t tnow = millis() >> 10;
if (tnow > g.telem_delay) {
return false;
}
#if USB_MUX_PIN > 0
if (chan == MAVLINK_COMM_0 && usb_connected) {
// this is an APM2 with USB telemetry
return false;
}
// we're either on the 2nd UART, or no USB cable is connected
// we need to delay telemetry
return true;
#else
if (chan == MAVLINK_COMM_0) {
// we're on the USB port
return false;
}
// don't send telemetry yet
return true;
#endif
}
// try to send a message, return false if it won't fit in the serial tx buffer
static bool mavlink_try_send_message(mavlink_channel_t chan, enum ap_message id, uint16_t packet_drops)
{
int16_t payload_space = comm_get_txspace(chan) - MAVLINK_NUM_NON_PAYLOAD_BYTES;
if (chan == MAVLINK_COMM_1 && millis() < MAVLINK_TELEMETRY_PORT_DELAY) {
// defer any messages on the telemetry port for 1 second after
// bootup, to try to prevent bricking of Xbees
if (telemetry_delayed(chan)) {
return false;
}
@ -693,9 +716,7 @@ static void mavlink_send_message(mavlink_channel_t chan, enum ap_message id, uin
void mavlink_send_text(mavlink_channel_t chan, gcs_severity severity, const char *str)
{
if (chan == MAVLINK_COMM_1 && millis() < MAVLINK_TELEMETRY_PORT_DELAY) {
// don't send status MAVLink messages for 2 seconds after
// bootup, to try to prevent Xbee bricking
if (telemetry_delayed(chan)) {
return;
}

View File

@ -81,6 +81,7 @@ public:
k_param_sysid_this_mav,
k_param_sysid_my_gcs,
k_param_serial3_baud,
k_param_telem_delay,
// 120: Fly-by-wire control
//
@ -219,6 +220,7 @@ public:
AP_Int16 sysid_this_mav;
AP_Int16 sysid_my_gcs;
AP_Int8 serial3_baud;
AP_Int8 telem_delay;
// Feed-forward gains
//

View File

@ -26,6 +26,15 @@ const AP_Param::Info var_info[] PROGMEM = {
// @User: Standard
GSCALAR(serial3_baud, "SERIAL3_BAUD", SERIAL3_BAUD/1000),
// @Param: TELEM_DELAY
// @DisplayName: Telemetry startup delay
// @Description: The amount of time (in seconds) to delay radio telemetry to prevent an Xbee bricking on power up
// @User: Standard
// @Units: seconds
// @Range: 0 10
// @Increment: 1
GSCALAR(telem_delay, "TELEM_DELAY", 0),
// @Param: KFF_PTCHCOMP
// @DisplayName: Pitch Compensation
// @Description: Adds pitch input to compensate for the loss of lift due to roll control. 0 = 0 %, 1 = 100%

View File

@ -816,11 +816,6 @@
# define CLI_ENABLED ENABLED
#endif
// delay to prevent Xbee bricking, in milliseconds
#ifndef MAVLINK_TELEMETRY_PORT_DELAY
# define MAVLINK_TELEMETRY_PORT_DELAY 6000
#endif
// use this to disable geo-fencing
#ifndef GEOFENCE_ENABLED
# define GEOFENCE_ENABLED ENABLED