mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
CC-39 New helper function to get the Board model (synchronously). Will be used by config gadget to dynamically load the right interfaces for the board type.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3073 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
eafcf35fa6
commit
34fffd0e50
@ -32,6 +32,8 @@
|
||||
|
||||
#include <QMutexLocker>
|
||||
#include <QDebug>
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
|
||||
// ******************************
|
||||
// constructor/destructor
|
||||
@ -114,6 +116,34 @@ void UAVObjectUtilManager::transactionCompleted(UAVObject *obj, bool success)
|
||||
saveNextObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UAV Board model, for anyone interested. Return format is:
|
||||
* (Board Type << 8) + BoardRevision.
|
||||
*/
|
||||
int UAVObjectUtilManager::getBoardModel()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
if (!pm)
|
||||
return 0;
|
||||
UAVObjectManager *om = pm->getObject<UAVObjectManager>();
|
||||
if (!om)
|
||||
return 0;
|
||||
|
||||
UAVDataObject *obj = dynamic_cast<UAVDataObject *>(om->getObject(QString("FirmwareIAPObj")));
|
||||
// The code below will ask for the object update and wait for the updated to be received,
|
||||
// or the timeout of the timer, set to 1 second.
|
||||
QEventLoop loop;
|
||||
connect(obj, SIGNAL(objectUpdated(UAVObject*)), &loop, SLOT(quit()));
|
||||
QTimer::singleShot(1000, &loop, SLOT(quit())); // Create a timeout
|
||||
obj->requestUpdate();
|
||||
loop.exec();
|
||||
|
||||
int boardType = (obj->getField("BoardType")->getValue().toInt()) << 8;
|
||||
boardType += obj->getField("BoardRevision")->getValue().toInt();
|
||||
return boardType;
|
||||
}
|
||||
|
||||
|
||||
// ******************************
|
||||
// HomeLocation
|
||||
|
||||
|
@ -60,6 +60,8 @@ public:
|
||||
int getTelemetrySerialPortSpeed(QString &speed);
|
||||
int getTelemetrySerialPortSpeeds(QComboBox *comboBox);
|
||||
|
||||
int getBoardModel();
|
||||
|
||||
private:
|
||||
QMutex *mutex;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user