diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 7acfdb2873c9fa9ed279c8f67f5db340e5ac1520..8b9f3c4ab42479b19276cf4874d9c1c8254342ac 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -156,7 +156,6 @@ HEADERS += src/MG.h \ src/ui/map/Waypoint2DIcon.h \ src/ui/map/MAV2DIcon.h \ src/ui/map/QGC2DIcon.h - SOURCES += src/main.cc \ src/Core.cc \ src/uas/UASManager.cc \ @@ -227,8 +226,12 @@ win32 { LIBS += -LC:\OPAL-RT\RT-LAB7.2.4\Common\bin \ -lOpalApi INCLUDEPATH += src/lib/opalrt - SOURCES += src/comm/OpalLink.cc + SOURCES += src/comm/OpalLink.cc \ + src/comm/Parameter.cc \ + src/comm/QGCParamID.cc HEADERS += src/comm/OpalLink.h \ - src/comm/OpalRT.h + src/comm/OpalRT.h \ + src/comm/Parameter.h \ + src/comm/QGCParamID.h DEFINES += OPAL_RT } diff --git a/src/comm/OpalLink.cc b/src/comm/OpalLink.cc index a18f1f573903be3c5b643fdacba356287e825da7..1b39066008ba233c8c44979f443e4452fa005ba0 100644 --- a/src/comm/OpalLink.cc +++ b/src/comm/OpalLink.cc @@ -81,6 +81,7 @@ void OpalLink::writeBytes(const char *bytes, qint64 length) case MAVLINK_MSG_ID_PARAM_REQUEST_LIST: { qDebug() << "OpalLink::writeBytes(): request params"; + getParameterList(); mavlink_message_t param; char paramName[] = "NAV_FILT_INIT"; mavlink_msg_param_value_pack(systemID, componentID, ¶m, @@ -183,7 +184,7 @@ void OpalLink::setSignals(double *values) if (returnValue != EOK) { setLastErrorMsg(); - displayErrorMsg(); + displayLastErrorMsg(); } } void OpalLink::getSignals() @@ -255,7 +256,7 @@ void OpalLink::getSignals() else if (returnVal != EAGAIN) { getSignalsTimer->stop(); - displayErrorMsg(); + displayLastErrorMsg(); } } @@ -269,6 +270,77 @@ void OpalLink::getSignals() } +void OpalLink::getParameterList() +{ + /* inputs */ + unsigned short allocatedParams=0; + unsigned short allocatedPathLen=0; + unsigned short allocatedNameLen=0; + unsigned short allocatedVarLen=0; + + /* outputs */ + unsigned short numParams; + unsigned short *idParam=NULL; + unsigned short maxPathLen; + char **path=NULL; + unsigned short maxNameLen; + char **name=NULL; + unsigned short maxVarLen; + char **var=NULL; + + int returnValue; + + returnValue = OpalGetParameterList(allocatedParams, &numParams, idParam, + allocatedPathLen, &maxPathLen, path, + allocatedNameLen, &maxNameLen, name, + allocatedVarLen, &maxVarLen, var); + if (returnValue!=E2BIG) + { + setLastErrorMsg(); + displayLastErrorMsg(); + return; + } + + // allocate memory for parameter list + + idParam = new unsigned short[numParams]; + allocatedParams = numParams; + + path = new char*[numParams]; + for (int i=0; i #include +#include #include #include #include @@ -148,7 +149,7 @@ protected: // QMutex getSignalsMutex; QString lastErrorMsg; void setLastErrorMsg(); - void displayErrorMsg(); + void displayLastErrorMsg(); void setName(QString name); @@ -165,6 +166,8 @@ protected: const int systemID; const int componentID; + void getParameterList(); + }; diff --git a/src/comm/OpalRT.h b/src/comm/OpalRT.h index f26a727c190032af40cc78a409514ca63d2e6808..ea0005dbcedba91b3a02a05c70e323a6c0e7776c 100644 --- a/src/comm/OpalRT.h +++ b/src/comm/OpalRT.h @@ -43,6 +43,6 @@ namespace OpalRT B_W_0, B_W_1, B_W_2 - }; + }; } #endif // OPALRT_H diff --git a/src/comm/Parameter.cc b/src/comm/Parameter.cc new file mode 100644 index 0000000000000000000000000000000000000000..d59c810973a9485f9ae1964fe06e03fd1932db0a --- /dev/null +++ b/src/comm/Parameter.cc @@ -0,0 +1,6 @@ +#include "Parameter.h" +using namespace OpalRT; + +Parameter::Parameter() +{ +} diff --git a/src/comm/Parameter.h b/src/comm/Parameter.h new file mode 100644 index 0000000000000000000000000000000000000000..2fb9ba1e4d12a0c8710c4c67f949541b70a4a815 --- /dev/null +++ b/src/comm/Parameter.h @@ -0,0 +1,25 @@ +#ifndef PARAMETER_H +#define PARAMETER_H + +#include +#include "mavlink_types.h" +#include "QGCParamID.h" + +namespace OpalRT +{ +class Parameter +{ +public: + Parameter(); + +protected: + QString *simulinkName; + QString *simulinkPath; + unsigned short opalID; + + QGCParamID *paramID; + uint8_t componentID; +}; +} + +#endif // PARAMETER_H diff --git a/src/comm/QGCParamID.cc b/src/comm/QGCParamID.cc new file mode 100644 index 0000000000000000000000000000000000000000..b497dfd1be0ccfad2ea17181039e8d14be59590f --- /dev/null +++ b/src/comm/QGCParamID.cc @@ -0,0 +1,6 @@ +#include "QGCParamID.h" +using namespace OpalRT; + +QGCParamID::QGCParamID() +{ +} diff --git a/src/comm/QGCParamID.h b/src/comm/QGCParamID.h new file mode 100644 index 0000000000000000000000000000000000000000..454871875c7a115e780f017721fa0d1eb7a5e16e --- /dev/null +++ b/src/comm/QGCParamID.h @@ -0,0 +1,15 @@ +#ifndef QGCPARAMID_H +#define QGCPARAMID_H + +#include +#include +namespace OpalRT +{ + class QGCParamID : public QString + { + Q_OBJECT + public: + QGCParamID(); + }; +} +#endif // QGCPARAMID_H