From a2db6392894658ff213746466cfb242d25953422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 31 Oct 2017 10:30:58 +0100 Subject: [PATCH] mavlink_receiver: disable ulog streaming via Telemetry links Telemetry links don't have enough bandwidth for that feature. The vehicle will return a NACK when trying to enable log streaming on such a link. --- src/modules/mavlink/mavlink_receiver.cpp | 30 +++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/modules/mavlink/mavlink_receiver.cpp b/src/modules/mavlink/mavlink_receiver.cpp index 8a515244e5..797e59e264 100644 --- a/src/modules/mavlink/mavlink_receiver.cpp +++ b/src/modules/mavlink/mavlink_receiver.cpp @@ -547,21 +547,33 @@ void MavlinkReceiver::handle_message_command_both(mavlink_message_t *msg, const } if (cmd_mavlink.command == MAV_CMD_LOGGING_START) { - // we already instanciate the streaming object, because at this point we know on which - // mavlink channel streaming was requested. But in fact it's possible that the logger is - // not even running. The main mavlink thread takes care of this by waiting for an ack - // from the logger. - _mavlink->try_start_ulog_streaming(msg->sysid, msg->compid); + // check that we have enough bandwidth available: this is given by the configured logger topics + // and rates. The 5000 is somewhat arbitrary, but makes sure that we cannot enable log streaming + // on a radio link + if (_mavlink->get_data_rate() < 5000) { + send_ack = true; + ret = PX4_ERROR; + _mavlink->send_statustext_critical("Not enough bandwidth to enable log streaming"); + + } else { + // we already instanciate the streaming object, because at this point we know on which + // mavlink channel streaming was requested. But in fact it's possible that the logger is + // not even running. The main mavlink thread takes care of this by waiting for an ack + // from the logger. + _mavlink->try_start_ulog_streaming(msg->sysid, msg->compid); + } } else if (cmd_mavlink.command == MAV_CMD_LOGGING_STOP) { _mavlink->request_stop_ulog_streaming(); } - if (_cmd_pub == nullptr) { - _cmd_pub = orb_advertise_queue(ORB_ID(vehicle_command), &vehicle_command, vehicle_command_s::ORB_QUEUE_LENGTH); + if (!send_ack) { + if (_cmd_pub == nullptr) { + _cmd_pub = orb_advertise_queue(ORB_ID(vehicle_command), &vehicle_command, vehicle_command_s::ORB_QUEUE_LENGTH); - } else { - orb_publish(ORB_ID(vehicle_command), _cmd_pub, &vehicle_command); + } else { + orb_publish(ORB_ID(vehicle_command), _cmd_pub, &vehicle_command); + } } }