Browse Source

Switch only to MAVLink 2 on first connected link. Fall back to v1 if two links to the same vehicle are connected and one can only do v1

QGC4.4
Lorenz Meier 8 years ago
parent
commit
c99291144d
  1. 17
      src/Vehicle/Vehicle.cc

17
src/Vehicle/Vehicle.cc

@ -114,7 +114,7 @@ Vehicle::Vehicle(LinkInterface* link, @@ -114,7 +114,7 @@ Vehicle::Vehicle(LinkInterface* link,
, _telemetryTXBuffer(0)
, _telemetryLNoise(0)
, _telemetryRNoise(0)
, _maxProtoVersion(100)
, _maxProtoVersion(0)
, _vehicleCapabilitiesKnown(false)
, _supportsMissionItemInt(false)
, _connectionLost(false)
@ -741,6 +741,13 @@ void Vehicle::_setCapabilities(uint64_t capabilityBits) @@ -741,6 +741,13 @@ void Vehicle::_setCapabilities(uint64_t capabilityBits)
_vehicleCapabilitiesKnown = true;
emit capabilitiesKnownChanged(true);
// This should potentially be turned into a user-facing warning
// if the general experience after deployment is that users want MAVLink 2
// but forget to upgrade their radio firmware
if (capabilityBits & MAV_PROTOCOL_CAPABILITY_MAVLINK2 && maxProtoVersion() < 200) {
qCDebug(VehicleLog) << QString("Vehicle does support MAVLink 2 but the link does not allow for it.");
}
qCDebug(VehicleLog) << QString("Vehicle %1 MISSION_ITEM_INT").arg(_supportsMissionItemInt ? QStringLiteral("supports") : QStringLiteral("does not support"));
}
@ -797,8 +804,12 @@ void Vehicle::_handleProtocolVersion(LinkInterface *link, mavlink_message_t& mes @@ -797,8 +804,12 @@ void Vehicle::_handleProtocolVersion(LinkInterface *link, mavlink_message_t& mes
}
void Vehicle::_setMaxProtoVersion(unsigned version) {
_maxProtoVersion = version;
emit requestProtocolVersion(_maxProtoVersion);
// Set only once or if we need to reduce the max version
if (_maxProtoVersion == 0 || version < _maxProtoVersion) {
_maxProtoVersion = version;
emit requestProtocolVersion(_maxProtoVersion);
}
}
void Vehicle::_handleHilActuatorControls(mavlink_message_t &message)

Loading…
Cancel
Save