Browse Source

ComponentInformation: minor cleanup, require valid uriMetaData & crcMetaDataValid

QGC4.4
Beat Küng 4 years ago committed by Don Gagne
parent
commit
2076592ef7
  1. 9
      src/Vehicle/CompInfoGeneral.cc
  2. 6
      src/comm/MockLink.cc
  3. 2
      src/comm/MockLink.h

9
src/Vehicle/CompInfoGeneral.cc

@ -76,7 +76,7 @@ void CompInfoGeneral::setJson(const QString& metadataJsonFileName, const QString @@ -76,7 +76,7 @@ void CompInfoGeneral::setJson(const QString& metadataJsonFileName, const QString
continue;
Uris uris;
uris.uriMetaData = typeValue["uri"].toString();
uris.crcMetaData = typeValue["fileCrc"].toVariant().toLongLong(); // Note: can't use toInt()
uris.crcMetaData = typeValue["fileCrc"].toVariant().toLongLong(); // Note: can't use toInt(), as it returns 0 when exceeding 2^31
uris.crcMetaDataValid = typeValue.toObject().contains("fileCrc");
uris.uriMetaDataFallback = typeValue["uriFallback"].toString();
uris.crcMetaDataFallback = typeValue["fileCrcFallback"].toVariant().toLongLong();
@ -87,6 +87,13 @@ void CompInfoGeneral::setJson(const QString& metadataJsonFileName, const QString @@ -87,6 +87,13 @@ void CompInfoGeneral::setJson(const QString& metadataJsonFileName, const QString
uris.uriTranslationFallback = typeValue["translationUriFallback"].toString();
uris.crcTranslationFallback = typeValue["translationFileCrcFallback"].toVariant().toLongLong();
uris.crcTranslationFallbackValid = typeValue.toObject().contains("translationFileCrcFallback");
if (uris.uriMetaData.isEmpty() || !uris.crcMetaDataValid) {
qCWarning(CompInfoGeneralLog) << "Metadata missing required fields: type:uri:crcValid" << type <<
uris.uriMetaData << uris.crcMetaDataValid;
continue;
}
_supportedTypes[(COMP_METADATA_TYPE)type] = uris;
qCDebug(CompInfoGeneralLog) << "Metadata type : uri : crc" << type << uris.uriMetaData << uris.crcMetaData;
}

6
src/comm/MockLink.cc

@ -1576,7 +1576,7 @@ bool MockLink::_handleRequestMessage(const mavlink_command_long_t& request, bool @@ -1576,7 +1576,7 @@ bool MockLink::_handleRequestMessage(const mavlink_command_long_t& request, bool
switch ((int)request.param1) {
case MAVLINK_MSG_ID_COMPONENT_INFORMATION:
if (_firmwareType == MAV_AUTOPILOT_PX4) {
_sendVersionMetaData();
_sendGeneralMetaData();
return true;
}
break;
@ -1609,7 +1609,7 @@ bool MockLink::_handleRequestMessage(const mavlink_command_long_t& request, bool @@ -1609,7 +1609,7 @@ bool MockLink::_handleRequestMessage(const mavlink_command_long_t& request, bool
return false;
}
void MockLink::_sendVersionMetaData(void)
void MockLink::_sendGeneralMetaData(void)
{
mavlink_message_t responseMsg;
#if 1
@ -1617,7 +1617,7 @@ void MockLink::_sendVersionMetaData(void) @@ -1617,7 +1617,7 @@ void MockLink::_sendVersionMetaData(void)
#else
char metaDataURI[MAVLINK_MSG_COMPONENT_INFORMATION_FIELD_GENERAL_METADATA_URI_LEN] = "https://bit.ly/31nm0fs";
#endif
char peripheralsMetaDataURI[MAVLINK_MSG_COMPONENT_INFORMATION_FIELD_PERIPHERALS_METADATA_URI_LEN] = "https://bit.ly/31nm0fs";
char peripheralsMetaDataURI[MAVLINK_MSG_COMPONENT_INFORMATION_FIELD_PERIPHERALS_METADATA_URI_LEN] = "";
mavlink_msg_component_information_pack_chan(_vehicleSystemId,
_vehicleComponentId,

2
src/comm/MockLink.h

@ -227,7 +227,7 @@ private: @@ -227,7 +227,7 @@ private:
void _logDownloadWorker (void);
void _sendADSBVehicles (void);
void _moveADSBVehicle (void);
void _sendVersionMetaData (void);
void _sendGeneralMetaData (void);
static MockLink* _startMockLinkWorker(QString configName, MAV_AUTOPILOT firmwareType, MAV_TYPE vehicleType, bool sendStatusText, MockConfiguration::FailureMode_t failureMode);
static MockLink* _startMockLink(MockConfiguration* mockConfig);

Loading…
Cancel
Save