mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
GCS-Use uavo definition hash to check for compatability
Unfortunately had to change the iap object.
This commit is contained in:
parent
fa2aa81079
commit
fb073059ad
@ -12,12 +12,14 @@
|
||||
VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py
|
||||
VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcsversioninfotemplate.h
|
||||
VERSION_INFO_COMMAND = python \"$$VERSION_INFO_SCRIPT\"
|
||||
UAVO_DEF_PATH = $$ROOT_DIR/shared/uavobjectdefinition
|
||||
|
||||
# Create custom version_info target which generates a header
|
||||
version_info.target = $$VERSION_INFO_HEADER
|
||||
version_info.commands = $$VERSION_INFO_COMMAND \
|
||||
--path=\"$$GCS_SOURCE_TREE\" \
|
||||
--template=\"$$VERSION_INFO_TEMPLATE\" \
|
||||
--uavodir=\"$$UAVO_DEF_PATH\" \
|
||||
--outfile=\"$$VERSION_INFO_HEADER\"
|
||||
version_info.depends = FORCE
|
||||
QMAKE_EXTRA_TARGETS += version_info
|
||||
|
@ -92,6 +92,7 @@ plugin_uploader.subdir = uploader
|
||||
plugin_uploader.depends = plugin_coreplugin
|
||||
plugin_uploader.depends += plugin_uavobjects
|
||||
plugin_uploader.depends += plugin_rawhid
|
||||
plugin_uploader.depends += plugin_uavobjectutil
|
||||
SUBDIRS += plugin_uploader
|
||||
|
||||
#Dial gadget
|
||||
|
@ -8,7 +8,8 @@ public:
|
||||
QString gitHash;
|
||||
QString gitDate;
|
||||
QString gitTag;
|
||||
QString uavoHash;
|
||||
QByteArray fwHash;
|
||||
QByteArray uavoHash;
|
||||
int boardType;
|
||||
int boardRevision;
|
||||
static QString idToBoardName(int id)
|
||||
|
@ -257,7 +257,12 @@ FirmwareIAPObj::DataFields UAVObjectUtilManager::getFirmwareIap()
|
||||
int UAVObjectUtilManager::getBoardModel()
|
||||
{
|
||||
FirmwareIAPObj::DataFields firmwareIapData = getFirmwareIap();
|
||||
return (firmwareIapData.BoardType << 8) + firmwareIapData.BoardRevision;
|
||||
qDebug()<<"Board type="<<firmwareIapData.BoardType;
|
||||
qDebug()<<"Board revision="<<firmwareIapData.BoardRevision;
|
||||
int ret=firmwareIapData.BoardType <<8;
|
||||
ret = ret + firmwareIapData.BoardRevision;
|
||||
qDebug()<<"Board info="<<ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -625,11 +630,11 @@ int UAVObjectUtilManager::getTelemetrySerialPortSpeeds(QComboBox *comboBox)
|
||||
deviceDescriptorStruct UAVObjectUtilManager::getBoardDescriptionStruct()
|
||||
{
|
||||
deviceDescriptorStruct ret;
|
||||
descriptionToStructure(getBoardDescription(),&ret);
|
||||
descriptionToStructure(getBoardDescription(),ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescriptorStruct *struc)
|
||||
bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescriptorStruct & struc)
|
||||
{
|
||||
if (desc.startsWith("OpFw")) {
|
||||
/*
|
||||
@ -651,24 +656,26 @@ bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescrip
|
||||
gitCommitHash = gitCommitHash << 8;
|
||||
gitCommitHash += desc.at(7-i) & 0xFF;
|
||||
}
|
||||
struc->gitHash = QString::number(gitCommitHash, 16);
|
||||
struc.gitHash = QString::number(gitCommitHash, 16);
|
||||
|
||||
quint32 gitDate = desc.at(11) & 0xFF;
|
||||
for (int i = 1; i < 4; i++) {
|
||||
gitDate = gitDate << 8;
|
||||
gitDate += desc.at(11-i) & 0xFF;
|
||||
}
|
||||
struc->gitDate = QDateTime::fromTime_t(gitDate).toUTC().toString("yyyyMMdd HH:mm");
|
||||
struc.gitDate = QDateTime::fromTime_t(gitDate).toUTC().toString("yyyyMMdd HH:mm");
|
||||
|
||||
QString gitTag = QString(desc.mid(14,26));
|
||||
struc->gitTag = gitTag;
|
||||
struc.gitTag = gitTag;
|
||||
|
||||
// TODO: check platform compatibility
|
||||
QByteArray targetPlatform = desc.mid(12,2);
|
||||
struc->boardType = (int)targetPlatform.at(0);
|
||||
struc->boardRevision = (int)targetPlatform.at(1);
|
||||
|
||||
struc->uavoHash=desc.mid(46,20);
|
||||
struc.boardType = (int)targetPlatform.at(0);
|
||||
struc.boardRevision = (int)targetPlatform.at(1);
|
||||
struc.fwHash.clear();
|
||||
struc.fwHash=desc.mid(40,20);
|
||||
struc.uavoHash.clear();
|
||||
struc.uavoHash=desc.mid(60,20);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
quint32 getFirmwareCRC();
|
||||
QByteArray getBoardDescription();
|
||||
deviceDescriptorStruct getBoardDescriptionStruct();
|
||||
static bool descriptionToStructure(QByteArray desc,deviceDescriptorStruct * struc);
|
||||
static bool descriptionToStructure(QByteArray desc,deviceDescriptorStruct & struc);
|
||||
UAVObjectManager* getObjectManager();
|
||||
void saveObjectToSD(UAVObject *obj);
|
||||
protected:
|
||||
|
@ -154,7 +154,7 @@ void deviceWidget::freeze()
|
||||
*/
|
||||
bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
|
||||
{
|
||||
if(UAVObjectUtilManager::descriptionToStructure(desc,&onBoardDescription))
|
||||
if(UAVObjectUtilManager::descriptionToStructure(desc,onBoardDescription))
|
||||
{
|
||||
myDevice->lblGitTag->setText(onBoardDescription.gitHash);
|
||||
myDevice->lblBuildDate->setText(onBoardDescription.gitDate.insert(4,"-").insert(7,"-"));
|
||||
@ -184,7 +184,7 @@ bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
|
||||
}
|
||||
bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc)
|
||||
{
|
||||
if(UAVObjectUtilManager::descriptionToStructure(desc,&LoadedDescription))
|
||||
if(UAVObjectUtilManager::descriptionToStructure(desc,LoadedDescription))
|
||||
{
|
||||
myDevice->lblGitTagL->setText(LoadedDescription.gitHash);
|
||||
myDevice->lblBuildDateL->setText( LoadedDescription.gitDate.insert(4,"-").insert(7,"-"));
|
||||
|
@ -101,7 +101,7 @@ void runningDeviceWidget::populate()
|
||||
|
||||
QByteArray description = utilMngr->getBoardDescription();
|
||||
deviceDescriptorStruct devDesc;
|
||||
if(UAVObjectUtilManager::descriptionToStructure(description,&devDesc))
|
||||
if(UAVObjectUtilManager::descriptionToStructure(description,devDesc))
|
||||
{
|
||||
if(devDesc.gitTag.startsWith("release",Qt::CaseInsensitive))
|
||||
{
|
||||
|
@ -650,16 +650,35 @@ void UploaderGadgetWidget::versionMatchCheck()
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
||||
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
|
||||
|
||||
QByteArray uavoHashArray;
|
||||
QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR);
|
||||
uavoHash.remove( QRegExp("^[0]*") );
|
||||
QString gcsVersion = uavoHash;
|
||||
QString fwVersion = boardDescription.gitHash;
|
||||
uavoHash.chop(2);
|
||||
uavoHash.remove(0,2);
|
||||
uavoHash=uavoHash.trimmed();
|
||||
bool ok;
|
||||
foreach(QString str,uavoHash.split(","))
|
||||
{
|
||||
uavoHashArray.append(str.toInt(&ok,16));
|
||||
}
|
||||
|
||||
if (boardDescription.uavoHash != uavoHash) {
|
||||
QByteArray fwVersion;
|
||||
fwVersion=boardDescription.uavoHash;
|
||||
if (fwVersion != uavoHashArray) {
|
||||
QString uavoHashStr;
|
||||
QString fwVersionStr;
|
||||
foreach(char i, fwVersion)
|
||||
{
|
||||
qDebug()<<i<<" "<<QString::number(i,16).right(2);
|
||||
fwVersionStr.append(QString::number(i,16).right(2));
|
||||
}
|
||||
foreach(char i, uavoHashArray)
|
||||
{
|
||||
qDebug()<<i<<" "<<QString::number(i,16).right(2);
|
||||
uavoHashStr.append(QString::number(i,16).right(2));
|
||||
}
|
||||
QString warning = QString(tr(
|
||||
"GCS and firmware versions of the UAV object set do not match which can cause configuration problems. "
|
||||
"GCS version: %1. Firmware version: %2.")).arg(gcsVersion).arg(fwVersion);
|
||||
"GCS version: %1. Firmware version: %2.")).arg(uavoHashStr).arg(fwVersionStr);
|
||||
msg->showMessage(warning);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,8 @@
|
||||
* 26 bytes: commit tag if it is there, otherwise branch name. '-dirty' may be added if needed. Zero-padded.
|
||||
* ---- 40 bytes limit ---
|
||||
* 20 bytes: SHA1 sum of the firmware.
|
||||
* 40 bytes: free for now.
|
||||
* 20 bytes: SHA1 sum of the uavo definitions.
|
||||
* 20 bytes: free for now.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#define GCS_REVISION ${TAG_OR_BRANCH}:${HASH8}${DIRTY} ${DATETIME}
|
||||
#define UAVO_HASH ${UAVOSHA1}
|
||||
#define UAVO_HASH "{ ${UAVOSHA1} }"
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
<object name="FirmwareIAPObj" singleinstance="true" settings="false">
|
||||
<description>Queries board for SN, model, revision, and sends reset command</description>
|
||||
<field name="Command" units="" type="uint16" elements="1"/>
|
||||
<field name="Description" units="" type="uint8" elements="40"/>
|
||||
<field name="Description" units="" type="uint8" elements="100"/>
|
||||
<field name="CPUSerial" units="" type="uint8" elements="12" />
|
||||
<field name="BoardRevision" units="" type="uint16" elements="1"/>
|
||||
<field name="BoardType" units="" type="uint8" elements="1"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user