Improve high latency switching and acknowledge

- Move publishing the telemetry status from the IridiumSBD driver to the mavlink instance
- In the commander use the iridiumsbd_status message for heartbeat in case of a high latency link
- Move positive acknowledge to the mavlink instance
- Add a failed acknowledge in the commander if no high latency link exists
This commit is contained in:
acfloria
2018-05-27 12:11:35 -04:00
committed by Daniel Agar
parent 30fc8cd608
commit 57162ff08d
6 changed files with 83 additions and 85 deletions
+41 -9
View File
@@ -1972,6 +1972,9 @@ Mavlink::task_main(int argc, char *argv[])
ack_sub->subscribe_from_beginning(true);
cmd_sub->subscribe_from_beginning(true);
/* command ack */
orb_advert_t command_ack_pub = nullptr;
MavlinkOrbSubscription *mavlink_log_sub = add_orb_subscription(ORB_ID(mavlink_log));
struct vehicle_status_s status;
@@ -2202,6 +2205,20 @@ Mavlink::task_main(int argc, char *argv[])
set_hil_enabled(status.hil_state == vehicle_status_s::HIL_STATE_ON);
set_manual_input_mode_generation(status.rc_input_mode == vehicle_status_s::RC_IN_MODE_GENERATED);
if (_mode == MAVLINK_MODE_IRIDIUM) {
if (_transmitting_enabled &&
!status.high_latency_data_link_active &&
!_transmitting_enabled_commanded &&
(_last_write_success_time > 0u)) { // a first message is written
_transmitting_enabled = false;
mavlink_and_console_log_info(&_mavlink_log_pub, "Disable transmitting with IRIDIUM mavlink on device %s", _device_name);
} else if (!_transmitting_enabled && status.high_latency_data_link_active) {
_transmitting_enabled = true;
mavlink_and_console_log_info(&_mavlink_log_pub, "Enable transmitting with IRIDIUM mavlink on device %s", _device_name);
}
}
}
struct vehicle_command_s vehicle_cmd;
@@ -2211,7 +2228,8 @@ Mavlink::task_main(int argc, char *argv[])
(_mode == MAVLINK_MODE_IRIDIUM)) {
if (vehicle_cmd.param1 > 0.5f) {
if (!_transmitting_enabled) {
PX4_INFO("Enable transmitting with IRIDIUM mavlink on device %s by command", _device_name);
mavlink_and_console_log_info(&_mavlink_log_pub, "Enable transmitting with IRIDIUM mavlink on device %s by command",
_device_name);
}
_transmitting_enabled = true;
@@ -2219,12 +2237,33 @@ Mavlink::task_main(int argc, char *argv[])
} else {
if (_transmitting_enabled) {
PX4_INFO("Disable transmitting with IRIDIUM mavlink on device %s by command", _device_name);
mavlink_and_console_log_info(&_mavlink_log_pub, "Disable transmitting with IRIDIUM mavlink on device %s by command",
_device_name);
}
_transmitting_enabled = false;
_transmitting_enabled_commanded = false;
}
// send positive command ack
struct vehicle_command_ack_s command_ack = {
.timestamp = vehicle_cmd.timestamp,
.result_param2 = 0,
.command = vehicle_cmd.command,
.result = vehicle_command_ack_s::VEHICLE_RESULT_ACCEPTED,
.from_external = !vehicle_cmd.from_external,
.result_param1 = 0,
.target_system = vehicle_cmd.source_system,
.target_component = vehicle_cmd.source_component
};
if (command_ack_pub != nullptr) {
orb_publish(ORB_ID(vehicle_command_ack), command_ack_pub, &command_ack);
} else {
command_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &command_ack,
vehicle_command_ack_s::ORB_QUEUE_LENGTH);
}
}
}
@@ -2335,13 +2374,6 @@ Mavlink::task_main(int argc, char *argv[])
stream->update(t);
}
if (_mode == MAVLINK_MODE_IRIDIUM) {
if ((_last_write_success_time > 0u) && !_transmitting_enabled_commanded && _transmitting_enabled) {
_transmitting_enabled = false;
PX4_INFO("Disable Iridium Mavlink after first packet is sent");
}
}
/* pass messages from other UARTs */
if (_forwarding_on) {
+16
View File
@@ -2408,6 +2408,22 @@ MavlinkReceiver::receive_thread(void *arg)
// poll timeout in ms. Also defines the max update frequency of the mission & param manager, etc.
const int timeout = 10;
// publish the telemetry status once for the iridium telemetry
if (_mavlink->get_mode() == Mavlink::MAVLINK_MODE_IRIDIUM) {
struct telemetry_status_s &tstatus = _mavlink->get_rx_status();
tstatus.timestamp = hrt_absolute_time();
tstatus.type = telemetry_status_s::TELEMETRY_STATUS_RADIO_TYPE_IRIDIUM;
if (_telemetry_status_pub == nullptr) {
int multi_instance;
_telemetry_status_pub = orb_advertise_multi(ORB_ID(telemetry_status), &tstatus, &multi_instance, ORB_PRIO_HIGH);
} else {
orb_publish(ORB_ID(telemetry_status), _telemetry_status_pub, &tstatus);
}
}
#ifdef __PX4_POSIX
/* 1500 is the Wifi MTU, so we make sure to fit a full packet */
uint8_t buf[1600 * 5];