1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

GCS-Use uavo definition hash to check for compatability

Unfortunately had to change the iap object.
This commit is contained in:
PT_Dreamer 2012-09-17 17:08:15 +01:00
parent fa2aa81079
commit fb073059ad
11 changed files with 55 additions and 24 deletions

View File

@ -12,12 +12,14 @@
VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py
VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcsversioninfotemplate.h VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcsversioninfotemplate.h
VERSION_INFO_COMMAND = python \"$$VERSION_INFO_SCRIPT\" VERSION_INFO_COMMAND = python \"$$VERSION_INFO_SCRIPT\"
UAVO_DEF_PATH = $$ROOT_DIR/shared/uavobjectdefinition
# Create custom version_info target which generates a header # Create custom version_info target which generates a header
version_info.target = $$VERSION_INFO_HEADER version_info.target = $$VERSION_INFO_HEADER
version_info.commands = $$VERSION_INFO_COMMAND \ version_info.commands = $$VERSION_INFO_COMMAND \
--path=\"$$GCS_SOURCE_TREE\" \ --path=\"$$GCS_SOURCE_TREE\" \
--template=\"$$VERSION_INFO_TEMPLATE\" \ --template=\"$$VERSION_INFO_TEMPLATE\" \
--uavodir=\"$$UAVO_DEF_PATH\" \
--outfile=\"$$VERSION_INFO_HEADER\" --outfile=\"$$VERSION_INFO_HEADER\"
version_info.depends = FORCE version_info.depends = FORCE
QMAKE_EXTRA_TARGETS += version_info QMAKE_EXTRA_TARGETS += version_info

View File

@ -92,6 +92,7 @@ plugin_uploader.subdir = uploader
plugin_uploader.depends = plugin_coreplugin plugin_uploader.depends = plugin_coreplugin
plugin_uploader.depends += plugin_uavobjects plugin_uploader.depends += plugin_uavobjects
plugin_uploader.depends += plugin_rawhid plugin_uploader.depends += plugin_rawhid
plugin_uploader.depends += plugin_uavobjectutil
SUBDIRS += plugin_uploader SUBDIRS += plugin_uploader
#Dial gadget #Dial gadget

View File

@ -8,7 +8,8 @@ public:
QString gitHash; QString gitHash;
QString gitDate; QString gitDate;
QString gitTag; QString gitTag;
QString uavoHash; QByteArray fwHash;
QByteArray uavoHash;
int boardType; int boardType;
int boardRevision; int boardRevision;
static QString idToBoardName(int id) static QString idToBoardName(int id)

View File

@ -257,7 +257,12 @@ FirmwareIAPObj::DataFields UAVObjectUtilManager::getFirmwareIap()
int UAVObjectUtilManager::getBoardModel() int UAVObjectUtilManager::getBoardModel()
{ {
FirmwareIAPObj::DataFields firmwareIapData = getFirmwareIap(); 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 UAVObjectUtilManager::getBoardDescriptionStruct()
{ {
deviceDescriptorStruct ret; deviceDescriptorStruct ret;
descriptionToStructure(getBoardDescription(),&ret); descriptionToStructure(getBoardDescription(),ret);
return ret; return ret;
} }
bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescriptorStruct *struc) bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescriptorStruct & struc)
{ {
if (desc.startsWith("OpFw")) { if (desc.startsWith("OpFw")) {
/* /*
@ -651,24 +656,26 @@ bool UAVObjectUtilManager::descriptionToStructure(QByteArray desc, deviceDescrip
gitCommitHash = gitCommitHash << 8; gitCommitHash = gitCommitHash << 8;
gitCommitHash += desc.at(7-i) & 0xFF; gitCommitHash += desc.at(7-i) & 0xFF;
} }
struc->gitHash = QString::number(gitCommitHash, 16); struc.gitHash = QString::number(gitCommitHash, 16);
quint32 gitDate = desc.at(11) & 0xFF; quint32 gitDate = desc.at(11) & 0xFF;
for (int i = 1; i < 4; i++) { for (int i = 1; i < 4; i++) {
gitDate = gitDate << 8; gitDate = gitDate << 8;
gitDate += desc.at(11-i) & 0xFF; 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)); QString gitTag = QString(desc.mid(14,26));
struc->gitTag = gitTag; struc.gitTag = gitTag;
// TODO: check platform compatibility // TODO: check platform compatibility
QByteArray targetPlatform = desc.mid(12,2); QByteArray targetPlatform = desc.mid(12,2);
struc->boardType = (int)targetPlatform.at(0); struc.boardType = (int)targetPlatform.at(0);
struc->boardRevision = (int)targetPlatform.at(1); struc.boardRevision = (int)targetPlatform.at(1);
struc.fwHash.clear();
struc->uavoHash=desc.mid(46,20); struc.fwHash=desc.mid(40,20);
struc.uavoHash.clear();
struc.uavoHash=desc.mid(60,20);
return true; return true;
} }
return false; return false;

View File

@ -68,7 +68,7 @@ public:
quint32 getFirmwareCRC(); quint32 getFirmwareCRC();
QByteArray getBoardDescription(); QByteArray getBoardDescription();
deviceDescriptorStruct getBoardDescriptionStruct(); deviceDescriptorStruct getBoardDescriptionStruct();
static bool descriptionToStructure(QByteArray desc,deviceDescriptorStruct * struc); static bool descriptionToStructure(QByteArray desc,deviceDescriptorStruct & struc);
UAVObjectManager* getObjectManager(); UAVObjectManager* getObjectManager();
void saveObjectToSD(UAVObject *obj); void saveObjectToSD(UAVObject *obj);
protected: protected:

View File

@ -154,7 +154,7 @@ void deviceWidget::freeze()
*/ */
bool deviceWidget::populateBoardStructuredDescription(QByteArray desc) bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
{ {
if(UAVObjectUtilManager::descriptionToStructure(desc,&onBoardDescription)) if(UAVObjectUtilManager::descriptionToStructure(desc,onBoardDescription))
{ {
myDevice->lblGitTag->setText(onBoardDescription.gitHash); myDevice->lblGitTag->setText(onBoardDescription.gitHash);
myDevice->lblBuildDate->setText(onBoardDescription.gitDate.insert(4,"-").insert(7,"-")); myDevice->lblBuildDate->setText(onBoardDescription.gitDate.insert(4,"-").insert(7,"-"));
@ -184,7 +184,7 @@ bool deviceWidget::populateBoardStructuredDescription(QByteArray desc)
} }
bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc) bool deviceWidget::populateLoadedStructuredDescription(QByteArray desc)
{ {
if(UAVObjectUtilManager::descriptionToStructure(desc,&LoadedDescription)) if(UAVObjectUtilManager::descriptionToStructure(desc,LoadedDescription))
{ {
myDevice->lblGitTagL->setText(LoadedDescription.gitHash); myDevice->lblGitTagL->setText(LoadedDescription.gitHash);
myDevice->lblBuildDateL->setText( LoadedDescription.gitDate.insert(4,"-").insert(7,"-")); myDevice->lblBuildDateL->setText( LoadedDescription.gitDate.insert(4,"-").insert(7,"-"));

View File

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

View File

@ -650,16 +650,35 @@ void UploaderGadgetWidget::versionMatchCheck()
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>(); UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct(); deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
QByteArray uavoHashArray;
QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR); QString uavoHash = QString::fromLatin1(Core::Constants::UAVOSHA1_STR);
uavoHash.remove( QRegExp("^[0]*") ); uavoHash.chop(2);
QString gcsVersion = uavoHash; uavoHash.remove(0,2);
QString fwVersion = boardDescription.gitHash; 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( QString warning = QString(tr(
"GCS and firmware versions of the UAV object set do not match which can cause configuration problems. " "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); msg->showMessage(warning);
} }
} }

View File

@ -41,7 +41,8 @@
* 26 bytes: commit tag if it is there, otherwise branch name. '-dirty' may be added if needed. Zero-padded. * 26 bytes: commit tag if it is there, otherwise branch name. '-dirty' may be added if needed. Zero-padded.
* ---- 40 bytes limit --- * ---- 40 bytes limit ---
* 20 bytes: SHA1 sum of the firmware. * 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.
* *
*/ */

View File

@ -26,7 +26,7 @@
*/ */
#define GCS_REVISION ${TAG_OR_BRANCH}:${HASH8}${DIRTY} ${DATETIME} #define GCS_REVISION ${TAG_OR_BRANCH}:${HASH8}${DIRTY} ${DATETIME}
#define UAVO_HASH ${UAVOSHA1} #define UAVO_HASH "{ ${UAVOSHA1} }"
/** /**
* @} * @}
*/ */

View File

@ -2,7 +2,7 @@
<object name="FirmwareIAPObj" singleinstance="true" settings="false"> <object name="FirmwareIAPObj" singleinstance="true" settings="false">
<description>Queries board for SN, model, revision, and sends reset command</description> <description>Queries board for SN, model, revision, and sends reset command</description>
<field name="Command" units="" type="uint16" elements="1"/> <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="CPUSerial" units="" type="uint8" elements="12" />
<field name="BoardRevision" units="" type="uint16" elements="1"/> <field name="BoardRevision" units="" type="uint16" elements="1"/>
<field name="BoardType" units="" type="uint8" elements="1"/> <field name="BoardType" units="" type="uint8" elements="1"/>