From 671da5a28bd44ad7155b71880a489c99a1968fde Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 28 Apr 2015 09:15:39 -0700 Subject: [PATCH 1/2] MockLink always added in debug builds --- src/comm/LinkManager.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index a48e902..78caa91 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -409,6 +409,15 @@ void LinkManager::loadLinkConfigurationList() } emit linkConfigurationChanged(); } + + // Debug buids always add MockLink automatically +#ifdef QT_DEBUG + MockConfiguration* pMock = new MockConfiguration("Mock Link"); + pMock->setDynamic(true); + addLinkConfiguration(pMock); + emit linkConfigurationChanged(); +#endif + // Enable automatic PX4 hunting _configurationsLoaded = true; } From 1191018ab70d09843d9dce192462528b18b45518 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Tue, 28 Apr 2015 09:15:54 -0700 Subject: [PATCH 2/2] Fix null termination --- src/comm/MockLink.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/comm/MockLink.cc b/src/comm/MockLink.cc index d14fc91..cbd6d17 100644 --- a/src/comm/MockLink.cc +++ b/src/comm/MockLink.cc @@ -503,11 +503,14 @@ void MockLink::_handleParamSet(const mavlink_message_t& msg) Q_ASSERT(request.target_system == _vehicleSystemId); int componentId = request.target_component; - + // Param may not be null terminated if exactly fits char paramId[MAVLINK_MSG_PARAM_SET_FIELD_PARAM_ID_LEN + 1]; + paramId[MAVLINK_MSG_PARAM_SET_FIELD_PARAM_ID_LEN] = 0; strncpy(paramId, request.param_id, MAVLINK_MSG_PARAM_SET_FIELD_PARAM_ID_LEN); + qCDebug(MockLinkLog) << "_handleParamSet" << componentId << paramId << request.param_type; + Q_ASSERT(_mapParamName2Value.contains(componentId)); Q_ASSERT(_mapParamName2Value[componentId].contains(paramId)); Q_ASSERT(request.param_type == _mapParamName2MavParamType[paramId]);