Commit f7ea1b9c authored by Bryan Godbolt's avatar Bryan Godbolt

Began skeleton of parameter interface between opalrt and qgc

parent 66289e5a
......@@ -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
}
......@@ -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, &param,
......@@ -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<numParams; i++)
path[i]=new char[maxPathLen];
allocatedPathLen = maxPathLen;
name = new char*[numParams];
for (int i=0; i<numParams; i++)
name[i] = new char[maxNameLen];
allocatedNameLen = maxNameLen;
var = new char*[numParams];
for (int i=0; i<numParams; i++)
var[i] = new char[maxVarLen];
allocatedVarLen = maxVarLen;
returnValue = OpalGetParameterList(allocatedParams, &numParams, idParam,
allocatedPathLen, &maxPathLen, path,
allocatedNameLen, &maxNameLen, name,
allocatedVarLen, &maxVarLen, var);
if (returnValue != EOK)
{
setLastErrorMsg();
displayLastErrorMsg();
return;
}
qDebug() << "Num params: " << numParams << endl;
qDebug() << "Name\tPath\tVar" << endl;
for (int i=0; i<numParams; i++)
qDebug() << qSetFieldWidth(20) << name[i] << qSetFieldWidth(5) << idParam[i]
<< qSetFieldWidth(50) << path[i];
}
/*
*
Administrative
......@@ -318,7 +390,7 @@ bool OpalLink::connect()
else
{
connectState = false;
displayErrorMsg();
displayLastErrorMsg();
}
emit connected(connectState);
......@@ -330,7 +402,7 @@ bool OpalLink::disconnect()
return false;
}
void OpalLink::displayErrorMsg()
void OpalLink::displayLastErrorMsg()
{
setLastErrorMsg();
QMessageBox msgBox;
......
......@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project
#include <QMutex>
#include <QDebug>
#include <QTextStreamManipulator>
#include <QMessageBox>
#include <QTimer>
#include <QQueue>
......@@ -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();
};
......
......@@ -43,6 +43,6 @@ namespace OpalRT
B_W_0,
B_W_1,
B_W_2
};
};
}
#endif // OPALRT_H
#include "Parameter.h"
using namespace OpalRT;
Parameter::Parameter()
{
}
#ifndef PARAMETER_H
#define PARAMETER_H
#include <QString>
#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
#include "QGCParamID.h"
using namespace OpalRT;
QGCParamID::QGCParamID()
{
}
#ifndef QGCPARAMID_H
#define QGCPARAMID_H
#include <QString>
#include <QObject>
namespace OpalRT
{
class QGCParamID : public QString
{
Q_OBJECT
public:
QGCParamID();
};
}
#endif // QGCPARAMID_H
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