1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-19 09:54:15 +01:00

Added embedded and gcs version info to exported uavobjects file.

This commit is contained in:
zedamota 2011-07-27 19:39:08 +01:00
parent 69083ee618
commit c7cf52be39
14 changed files with 73 additions and 58 deletions

View File

@ -24,7 +24,6 @@ void smartSaveButton::processClick()
bool error=false;
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
qDebug()<<"smartbutton:save";
foreach(UAVObject * obj,objects)
{
up_result=false;

View File

@ -30,7 +30,7 @@ public:
break;
}
}
deviceDescriptorStruct();
deviceDescriptorStruct(){}
};
#endif // DEVICEDESCRIPTORSTRUCT_H

View File

@ -6,7 +6,8 @@ include(uavobjectutil_dependencies.pri)
HEADERS += uavobjectutil_global.h \
uavobjectutilmanager.h \
uavobjectutilplugin.h
uavobjectutilplugin.h \
devicedescriptorstruct.h
SOURCES += uavobjectutilmanager.cpp \
uavobjectutilplugin.cpp

View File

@ -652,4 +652,51 @@ int UAVObjectUtilManager::getTelemetrySerialPortSpeeds(QComboBox *comboBox)
return 0; // OK
}
deviceDescriptorStruct UAVObjectUtilManager::getBoardDescriptionStruct()
{
deviceDescriptorStruct ret;
descriptionToStructure(getBoardDescription(),&ret);
return ret;
}
bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescriptorStruct *struc)
{
if (desc.startsWith("OpFw")) {
// This looks like a binary with a description at the end
/*
# 4 bytes: header: "OpFw"
# 4 bytes: GIT commit tag (short version of SHA1)
# 4 bytes: Unix timestamp of compile time
# 2 bytes: target platform. Should follow same rule as BOARD_TYPE and BOARD_REVISION in board define files.
# 26 bytes: commit tag if it is there, otherwise "Unreleased". Zero-padded
# ---- 40 bytes limit ---
# 20 bytes: SHA1 sum of the firmware.
# 40 bytes: free for now.
*/
// Note: the ARM binary is big-endian:
quint32 gitCommitTag = desc.at(7)&0xFF;
for (int i=1;i<4;i++) {
gitCommitTag = gitCommitTag<<8;
gitCommitTag += desc.at(7-i) & 0xFF;
}
struc->gitTag=QString::number(gitCommitTag,16);
quint32 buildDate = desc.at(11)&0xFF;
for (int i=1;i<4;i++) {
buildDate = buildDate<<8;
buildDate += desc.at(11-i) & 0xFF;
}
struc->buildDate= QDateTime::fromTime_t(buildDate).toUTC().toString("yyyyMMdd HH:mm");
QByteArray targetPlatform = desc.mid(12,2);
// TODO: check platform compatibility
QString dscText = QString(desc.mid(14,26));
struc->boardType=(int)targetPlatform.at(0);
struc->boardRevision=(int)targetPlatform.at(1);
struc->description=dscText;
return true;
}
return false;
}
// ******************************

View File

@ -35,14 +35,14 @@
#include "uavobjectmanager.h"
#include "uavobject.h"
#include "objectpersistence.h"
#include "devicedescriptorstruct.h"
#include <QtGlobal>
#include <QObject>
#include <QTimer>
#include <QMutex>
#include <QQueue>
#include <QComboBox>
#include <QDateTime>
class UAVOBJECTUTIL_EXPORT UAVObjectUtilManager: public QObject
{
Q_OBJECT
@ -65,6 +65,8 @@ public:
QByteArray getBoardCPUSerial();
quint32 getFirmwareCRC();
QByteArray getBoardDescription();
deviceDescriptorStruct getBoardDescriptionStruct();
static bool descriptionToStructure(QByteArray desc,deviceDescriptorStruct * struc);
UAVObjectManager* getObjectManager();
void saveObjectToSD(UAVObject *obj);

View File

@ -218,10 +218,21 @@ QString UAVSettingsImportExportPlugin::createXMLDocument(
QDomDocument doc(docName);
QDomElement root = doc.createElement(isSettings ? "settings" : "data");
doc.appendChild(root);
QDomElement versionInfo =doc.createElement("versionInfo");
root.appendChild(versionInfo);
QDomElement fw=doc.createElement("Embedded");
UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
fw.setAttribute("gitcommittag",utilMngr->getBoardDescriptionStruct().gitTag);
fw.setAttribute("fwtag",utilMngr->getBoardDescriptionStruct().description);
fw.setAttribute("cpuSerial",QString(utilMngr->getBoardCPUSerial().toHex()));
versionInfo.appendChild(fw);
QDomElement gcs=doc.createElement("GCS");
gcs.setAttribute("revision",QString::fromLatin1(Core::Constants::GCS_REVISION_STR));
versionInfo.appendChild(gcs);
// iterate over settings objects
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
foreach (QList<UAVDataObject*> list, objList) {
foreach (UAVDataObject* obj, list) {
if (obj->isSettings() == isSettings) {

View File

@ -30,7 +30,7 @@
#include <extensionsystem/iplugin.h>
#include "uavobjectutil/uavobjectutilmanager.h"
#include "importsummary.h"
#include "../../../../../build/ground/openpilotgcs/gcsversioninfo.h"
class UAVSettingsImportExportPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT

View File

@ -6,7 +6,7 @@ TARGET = UAVSettingsImportExport
include(../../openpilotgcsplugin.pri)
include(uavsettingsimportexport_dependencies.pri)
HEADERS += uavsettingsimportexport.h \
importsummary.h
SOURCES += uavsettingsimportexport.cpp \

View File

@ -1,5 +0,0 @@
#include "devicedescriptorstruct.h"
deviceDescriptorStruct::deviceDescriptorStruct()
{
}

View File

@ -180,7 +180,7 @@ void deviceWidget::freeze()
*/
bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
{
if(UploaderGadgetWidget::descriptionToStructure(desc,&onBoardDescrition))
if(UAVObjectUtilManager::descriptionToStructure(desc,&onBoardDescrition))
{
myDevice->lblGitTag->setText(onBoardDescrition.gitTag);
myDevice->lblBuildDate->setText(onBoardDescrition.buildDate);
@ -210,7 +210,7 @@ bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
}
bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc)
{
if(UploaderGadgetWidget::descriptionToStructure(desc,&LoadedDescrition))
if(UAVObjectUtilManager::descriptionToStructure(desc,&LoadedDescrition))
{
myDevice->lblGitTagL->setText(LoadedDescrition.gitTag);
myDevice->lblBuildDateL->setText( LoadedDescrition.buildDate);

View File

@ -110,7 +110,7 @@ void runningDeviceWidget::populate()
QByteArray description = utilMngr->getBoardDescription();
deviceDescriptorStruct devDesc;
if(UploaderGadgetWidget::descriptionToStructure(description,&devDesc))
if(UAVObjectUtilManager::descriptionToStructure(description,&devDesc))
{
if(devDesc.description.startsWith("release",Qt::CaseInsensitive))
{

View File

@ -22,8 +22,7 @@ HEADERS += uploadergadget.h \
SSP/qssp.h \
SSP/qsspt.h \
SSP/common.h \
runningdevicewidget.h \
devicedescriptorstruct.h
runningdevicewidget.h
SOURCES += uploadergadget.cpp \
uploadergadgetconfiguration.cpp \
uploadergadgetfactory.cpp \
@ -36,8 +35,7 @@ SOURCES += uploadergadget.cpp \
SSP/port.cpp \
SSP/qssp.cpp \
SSP/qsspt.cpp \
runningdevicewidget.cpp \
devicedescriptorstruct.cpp
runningdevicewidget.cpp
OTHER_FILES += Uploader.pluginspec
FORMS += \

View File

@ -27,44 +27,7 @@
#include "uploadergadgetwidget.h"
#define DFU_DEBUG true
bool UploaderGadgetWidget::descriptionToStructure(QByteArray desc,deviceDescriptorStruct * struc)
{
if (desc.startsWith("OpFw")) {
// This looks like a binary with a description at the end
/*
# 4 bytes: header: "OpFw"
# 4 bytes: GIT commit tag (short version of SHA1)
# 4 bytes: Unix timestamp of compile time
# 2 bytes: target platform. Should follow same rule as BOARD_TYPE and BOARD_REVISION in board define files.
# 26 bytes: commit tag if it is there, otherwise "Unreleased". Zero-padded
# ---- 40 bytes limit ---
# 20 bytes: SHA1 sum of the firmware.
# 40 bytes: free for now.
*/
// Note: the ARM binary is big-endian:
quint32 gitCommitTag = desc.at(7)&0xFF;
for (int i=1;i<4;i++) {
gitCommitTag = gitCommitTag<<8;
gitCommitTag += desc.at(7-i) & 0xFF;
}
struc->gitTag=QString::number(gitCommitTag,16);
quint32 buildDate = desc.at(11)&0xFF;
for (int i=1;i<4;i++) {
buildDate = buildDate<<8;
buildDate += desc.at(11-i) & 0xFF;
}
struc->buildDate= QDateTime::fromTime_t(buildDate).toUTC().toString("yyyyMMdd HH:mm");
QByteArray targetPlatform = desc.mid(12,2);
// TODO: check platform compatibility
QString dscText = QString(desc.mid(14,26));
struc->boardType=(int)targetPlatform.at(0);
struc->boardRevision=(int)targetPlatform.at(1);
struc->description=dscText;
return true;
}
return false;
}
UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
{
m_config = new Ui_UploaderWidget();

View File

@ -68,7 +68,6 @@ public:
~UploaderGadgetWidget();
typedef enum { IAP_STATE_READY, IAP_STATE_STEP_1, IAP_STATE_STEP_2, IAP_STEP_RESET, IAP_STATE_BOOTLOADER} IAPStep;
void log(QString str);
static bool descriptionToStructure(QByteArray desc,deviceDescriptorStruct * struc);
public slots:
void onAutopilotConnect();