Commit de5fc6a5 authored by tstellanova's avatar tstellanova

Reimplement write and read timeout retransmission

Also move default component ID into data model
parent 1f76bbed
...@@ -11,8 +11,7 @@ QGCUASParamManager::QGCUASParamManager(QObject *parent) : ...@@ -11,8 +11,7 @@ QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QObject(parent), QObject(parent),
mav(NULL), mav(NULL),
paramDataModel(this), paramDataModel(this),
paramCommsMgr(NULL), paramCommsMgr(NULL)
defaultComponentId(-1)
{ {
...@@ -63,22 +62,7 @@ void QGCUASParamManager::clearAllPendingParams() ...@@ -63,22 +62,7 @@ void QGCUASParamManager::clearAllPendingParams()
int QGCUASParamManager::getDefaultComponentId() int QGCUASParamManager::getDefaultComponentId()
{ {
int result = 0; return paramDataModel.getDefaultComponentId();
if (-1 != defaultComponentId)
return defaultComponentId;
QList<int> components = getComponentForParam("SYS_AUTOSTART");//TODO is this the best way to find the right component?
// Guard against multiple components responding - this will never show in practice
if (1 == components.count()) {
result = components.first();
defaultComponentId = result;
}
qDebug() << "Default compId: " << result;
return result;
} }
QList<int> QGCUASParamManager::getComponentForParam(const QString& parameter) const QList<int> QGCUASParamManager::getComponentForParam(const QString& parameter) const
...@@ -119,7 +103,6 @@ void QGCUASParamManager::requestParameterListIfEmpty() ...@@ -119,7 +103,6 @@ void QGCUASParamManager::requestParameterListIfEmpty()
if (mav) { if (mav) {
int totalOnboard = paramDataModel.countOnboardParams(); int totalOnboard = paramDataModel.countOnboardParams();
if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK? if (totalOnboard < 2) { //TODO arbitrary constant, maybe 0 is OK?
defaultComponentId = -1; //reset this ...we have no idea what the default component ID is
requestParameterList(); requestParameterList();
} }
} }
...@@ -135,7 +118,7 @@ void QGCUASParamManager::setParameter(int compId, QString paramName, QVariant va ...@@ -135,7 +118,7 @@ void QGCUASParamManager::setParameter(int compId, QString paramName, QVariant va
{ {
if ((0 == compId) || (-1 == compId)) { if ((0 == compId) || (-1 == compId)) {
//attempt to get an actual component ID //attempt to get an actual component ID
compId = getDefaultComponentId(); compId = paramDataModel.getDefaultComponentId();
} }
paramDataModel.updatePendingParamWithValue(compId,paramName,value); paramDataModel.updatePendingParamWithValue(compId,paramName,value);
} }
...@@ -152,7 +135,7 @@ void QGCUASParamManager::setPendingParam(int compId, const QString& paramName, ...@@ -152,7 +135,7 @@ void QGCUASParamManager::setPendingParam(int compId, const QString& paramName,
{ {
if ((0 == compId) || (-1 == compId)) { if ((0 == compId) || (-1 == compId)) {
//attempt to get an actual component ID //attempt to get an actual component ID
compId = getDefaultComponentId(); compId = paramDataModel.getDefaultComponentId();
} }
paramDataModel.updatePendingParamWithValue(compId,paramName,value); paramDataModel.updatePendingParamWithValue(compId,paramName,value);
} }
......
...@@ -125,7 +125,6 @@ protected: ...@@ -125,7 +125,6 @@ protected:
UASInterface* mav; ///< The MAV this manager is controlling UASInterface* mav; ///< The MAV this manager is controlling
UASParameterDataModel paramDataModel;///< Shared data model of parameters UASParameterDataModel paramDataModel;///< Shared data model of parameters
UASParameterCommsMgr* paramCommsMgr; ///< Shared comms mgr for parameters UASParameterCommsMgr* paramCommsMgr; ///< Shared comms mgr for parameters
int defaultComponentId; ///< Cached default component ID
}; };
......
This diff is collapsed.
...@@ -32,8 +32,9 @@ public: ...@@ -32,8 +32,9 @@ public:
protected: protected:
/** @brief Activate / deactivate parameter retransmission */
virtual void setRetransmissionGuardEnabled(bool enabled); /** @brief activate the silence timer if there are unack'd reads or writes */
virtual void updateSilenceTimer();
virtual void setParameterStatusMsg(const QString& msg, ParamCommsStatusLevel_t level=ParamCommsStatusLevel_OK); virtual void setParameterStatusMsg(const QString& msg, ParamCommsStatusLevel_t level=ParamCommsStatusLevel_OK);
...@@ -43,6 +44,12 @@ protected: ...@@ -43,6 +44,12 @@ protected:
/** @brief clear transmissionMissingPackets and transmissionMissingWriteAckPackets */ /** @brief clear transmissionMissingPackets and transmissionMissingWriteAckPackets */
void clearRetransmissionLists(int& missingReadCount, int& missingWriteCount ); void clearRetransmissionLists(int& missingReadCount, int& missingWriteCount );
/** @brief we are waiting for a response to this read param request */
virtual void markReadParamWaiting(int compId, int paramId);
/** @brief we are waiting for a response to this write param request */
void markWriteParamWaiting(int compId, QString paramName, QVariant value);
void resendReadWriteRequests(); void resendReadWriteRequests();
void resetAfterListReceive(); void resetAfterListReceive();
...@@ -75,8 +82,8 @@ public slots: ...@@ -75,8 +82,8 @@ public slots:
/** @brief Request list of parameters from MAV */ /** @brief Request list of parameters from MAV */
virtual void requestParameterList(); virtual void requestParameterList();
/** @brief Check for missing parameters */ /** @brief The max silence time expired */
virtual void retransmissionGuardTick(); virtual void silenceTimerExpired();
/** @brief Request a single parameter update by name */ /** @brief Request a single parameter update by name */
virtual void requestParameterUpdate(int component, const QString& parameter); virtual void requestParameterUpdate(int component, const QString& parameter);
...@@ -88,28 +95,24 @@ public slots: ...@@ -88,28 +95,24 @@ public slots:
protected: protected:
QMap<int, int> knownParamListSize;///< The known param list size for each component, by component ID
quint64 lastReceiveTime; ///< The last time we received anything from our partner
quint64 lastSilenceTimerReset;
UASInterface* mav; ///< The MAV we're talking to UASInterface* mav; ///< The MAV we're talking to
int maxSilenceTimeout; ///< If nothing received within this period of time, abandon resends
UASParameterDataModel* paramDataModel; UASParameterDataModel* paramDataModel;
// Communications management
QVector<bool> receivedParamsList; ///< Successfully received parameters
QMap<int, QList<int>* > missingReadPackets; ///< Missing packets
QMap<int, QMap<QString, QVariant>* > missingWriteAckPackets; ///< Missing write ACK packets
bool transmissionListMode; ///< Currently requesting list
QMap<int, bool> transmissionListSizeKnown; ///< List size initialized?
bool transmissionActive; ///< Missing packets, working on list?
bool persistParamsAfterSend; ///< Copy all parameters to persistent storage after sending bool persistParamsAfterSend; ///< Copy all parameters to persistent storage after sending
quint64 transmissionTimeout; ///< Timeout QMap<int, QSet<int>*> readsWaiting; ///< All reads that have not yet been received, by component ID
QTimer retransmissionTimer; ///< Timer handling parameter retransmission int retransmitBurstLimit; ///< Number of packets requested for retransmission per burst
quint64 lastTimerReset; ///< Last time the guard timer was reset, to prevent premature firing int silenceTimeout; ///< If nothing received within this period of time, start resends
int retransmissionTimeout; ///< Retransmission request timeout, in milliseconds QTimer silenceTimer; ///< Timer handling parameter retransmission
int rewriteTimeout; ///< Write request timeout, in milliseconds bool transmissionListMode; ///< Currently requesting list
int retransmissionBurstRequestSize; ///< Number of packets requested for retransmission per burst QMap<int, QMap<QString, QVariant>* > writesWaiting; ///< All writes that have not yet been ack'd, by component ID
quint64 listRecvTimeout; ///< How long to wait for first parameter list response before re-requesting
// Status
QString parameterStatusMsg;
}; };
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "QGCMAVLink.h" #include "QGCMAVLink.h"
UASParameterDataModel::UASParameterDataModel(QObject *parent) : UASParameterDataModel::UASParameterDataModel(QObject *parent) :
QObject(parent) QObject(parent),
defaultComponentId(-1)
{ {
onboardParameters.clear(); onboardParameters.clear();
pendingParameters.clear(); pendingParameters.clear();
...@@ -199,6 +200,26 @@ bool UASParameterDataModel::getOnboardParamValue(int componentId, const QString& ...@@ -199,6 +200,26 @@ bool UASParameterDataModel::getOnboardParamValue(int componentId, const QString&
return false; return false;
} }
int UASParameterDataModel::getDefaultComponentId()
{
int result = 0;
if (-1 != defaultComponentId)
return defaultComponentId;
QList<int> components = getComponentForOnboardParam("SYS_AUTOSTART");//TODO is this the best way to find the right component?
// Guard against multiple components responding - this will never show in practice
if (1 == components.count()) {
result = components.first();
defaultComponentId = result;
}
qDebug() << "Default compId: " << result;
return result;
}
QList<int> UASParameterDataModel::getComponentForOnboardParam(const QString& parameter) const QList<int> UASParameterDataModel::getComponentForOnboardParam(const QString& parameter) const
{ {
QList<int> components; QList<int> components;
......
...@@ -28,6 +28,9 @@ public: ...@@ -28,6 +28,9 @@ public:
virtual QString getParamDescription(const QString& param) { return paramDescriptions.value(param, ""); } virtual QString getParamDescription(const QString& param) { return paramDescriptions.value(param, ""); }
virtual void setParamDescriptions(const QMap<QString,QString>& paramInfo); virtual void setParamDescriptions(const QMap<QString,QString>& paramInfo);
/** @brief Get the default component ID for the UAS */
virtual int getDefaultComponentId();
//TODO make this method protected? //TODO make this method protected?
/** @brief Ensure that the data model is aware of this component /** @brief Ensure that the data model is aware of this component
* @param compId Id of the component * @param compId Id of the component
...@@ -113,6 +116,8 @@ public slots: ...@@ -113,6 +116,8 @@ public slots:
virtual void clearAllPendingParams(); virtual void clearAllPendingParams();
protected: protected:
int defaultComponentId; ///< Cached default component ID
int uasId; ///< The UAS / MAV to which this data model pertains int uasId; ///< The UAS / MAV to which this data model pertains
QMap<int, QMap<QString, QVariant>* > pendingParameters; ///< Changed values that have not yet been transmitted to the UAS, by component ID QMap<int, QMap<QString, QVariant>* > pendingParameters; ///< Changed values that have not yet been transmitted to the UAS, by component ID
QMap<int, QMap<QString, QVariant>* > onboardParameters; ///< All parameters confirmed to be stored onboard the UAS, by component ID QMap<int, QMap<QString, QVariant>* > onboardParameters; ///< All parameters confirmed to be stored onboard the UAS, by component ID
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment