1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

LP-593 Basic check for firmware, tagged and matched firmware with GCS

This commit is contained in:
Laurent Lalanne 2018-04-10 12:00:35 +02:00
parent 1ab7956c1a
commit 877177ab51
2 changed files with 45 additions and 8 deletions

View File

@ -26,6 +26,7 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "devicewidget.h"
#include "version_info/version_info.h"
#include <QFileDialog>
#include <QDebug>
@ -216,10 +217,14 @@ bool DeviceWidget::populateBoardStructuredDescription(QByteArray desc)
if (UAVObjectUtilManager::descriptionToStructure(desc, onBoardDescription)) {
myDevice->lblGitTag->setText(onBoardDescription.gitHash);
myDevice->lblBuildDate->setText(onBoardDescription.gitDate.insert(4, "-").insert(7, "-"));
if (onBoardDescription.gitTag.startsWith("RELEASE", Qt::CaseSensitive)) {
if ((onBoardDescription.gitTag == VersionInfo::tag()) && (onBoardDescription.gitHash == VersionInfo::hash8())) {
myDevice->lblDescription->setText(onBoardDescription.gitTag);
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/application-certificate.svg"));
myDevice->lblCertified->setToolTip(tr("Tagged officially released firmware build"));
} else if ((onBoardDescription.gitTag == VersionInfo::fwTag()) && (onBoardDescription.gitHash == VersionInfo::hash8())) {
myDevice->lblDescription->setText(onBoardDescription.gitTag);
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/dialog-apply.svg"));
myDevice->lblCertified->setToolTip(tr("Matched firmware build"));
} else {
myDevice->lblDescription->setText(onBoardDescription.gitTag);
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/warning.svg"));
@ -239,11 +244,16 @@ bool DeviceWidget::populateLoadedStructuredDescription(QByteArray desc)
if (UAVObjectUtilManager::descriptionToStructure(desc, LoadedDescription)) {
myDevice->lblGitTagL->setText(LoadedDescription.gitHash);
myDevice->lblBuildDateL->setText(LoadedDescription.gitDate.insert(4, "-").insert(7, "-"));
if (LoadedDescription.gitTag.startsWith("RELEASE", Qt::CaseSensitive)) {
if ((LoadedDescription.gitTag == VersionInfo::tag()) && (LoadedDescription.gitHash == VersionInfo::hash8())) {
myDevice->lblDescritpionL->setText(LoadedDescription.gitTag);
myDevice->description->setText(LoadedDescription.gitTag);
myDevice->lblCertifiedL->setPixmap(QPixmap(":uploader/images/application-certificate.svg"));
myDevice->lblCertifiedL->setToolTip(tr("Tagged officially released firmware build"));
} else if ((LoadedDescription.gitTag == VersionInfo::fwTag()) && (LoadedDescription.gitHash == VersionInfo::hash8())) {
myDevice->lblDescritpionL->setText(LoadedDescription.gitTag);
myDevice->description->setText(LoadedDescription.gitTag);
myDevice->lblCertifiedL->setPixmap(QPixmap(":uploader/images/dialog-apply.svg"));
myDevice->lblCertifiedL->setToolTip(tr("Matched firmware build"));
} else {
myDevice->lblDescritpionL->setText(LoadedDescription.gitTag);
myDevice->description->setText(LoadedDescription.gitTag);
@ -347,7 +357,7 @@ void DeviceWidget::loadFirmware(QString fwfilename)
} else if (QDateTime::fromString(onBoardDescription.gitDate) > QDateTime::fromString(LoadedDescription.gitDate)) {
myDevice->statusLabel->setText(tr("The board has newer firmware than loaded. Are you sure you want to update?"));
px.load(QString(":/uploader/images/warning.svg"));
} else if (!LoadedDescription.gitTag.startsWith("RELEASE", Qt::CaseSensitive)) {
} else if (!(LoadedDescription.gitTag == VersionInfo::tag()) && (onBoardDescription.gitHash == VersionInfo::hash8())) {
myDevice->statusLabel->setText(tr("The loaded firmware is untagged or custom build. Update only if it was received from a trusted source (official website or your own build)."));
px.load(QString(":/uploader/images/warning.svg"));
} else {

View File

@ -28,6 +28,7 @@
#include "runningdevicewidget.h"
#include "devicedescriptorstruct.h"
#include "uploadergadgetwidget.h"
#include "version_info/version_info.h"
RunningDeviceWidget::RunningDeviceWidget(QWidget *parent) :
QWidget(parent)
@ -135,15 +136,41 @@ void RunningDeviceWidget::populate()
deviceDescriptorStruct devDesc;
if (UAVObjectUtilManager::descriptionToStructure(description, devDesc)) {
if (devDesc.gitTag.startsWith("RELEASE", Qt::CaseSensitive)) {
myDevice->lblFWTag->setText(tr("Firmware tag: ") + devDesc.gitTag);
// Convert current QString uavoHashArray stored in GCS to QByteArray
QString uavoHash = VersionInfo::uavoHashArray();
uavoHash.chop(2);
uavoHash.remove(0, 2);
uavoHash = uavoHash.trimmed();
QByteArray uavoHashArray;
bool ok;
foreach(QString str, uavoHash.split(",")) {
uavoHashArray.append(str.toInt(&ok, 16));
}
bool isCompatibleUavo = (uavoHashArray == devDesc.uavoHash);
bool isTaggedGcs = (VersionInfo::tag() != "");
bool isSameCommit = (devDesc.gitHash == VersionInfo::hash8());
bool isSameTag = (devDesc.gitTag == VersionInfo::fwTag());
if (isTaggedGcs && isSameCommit && isSameTag && isCompatibleUavo) {
// GCS tagged and firmware from same commit
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/application-certificate.svg"));
myDevice->lblCertified->setToolTip(tr("Tagged officially released firmware build"));
} else {
myDevice->lblFWTag->setText(tr("Firmware tag: ") + devDesc.gitTag);
myDevice->lblCertified->setToolTip(tr("Matched firmware build with official tagged release"));
} else if (!isTaggedGcs && isSameCommit && isSameTag && isCompatibleUavo) {
// GCS untagged and firmware from same commit
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/dialog-apply.svg"));
myDevice->lblCertified->setToolTip(tr("Matched firmware build"));
} else if ((!isSameCommit || !isSameTag) && isCompatibleUavo) {
// firmware not matching current GCS but compatible UAVO
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/warning.svg"));
myDevice->lblCertified->setToolTip(tr("Untagged or custom firmware build"));
} else {
myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/error.svg"));
myDevice->lblCertified->setToolTip(tr("Uncompatible firmware build"));
}
myDevice->lblFWTag->setText(tr("Firmware tag: ") + devDesc.gitTag);
myDevice->lblGitCommitTag->setText(tr("Git commit hash: ") + devDesc.gitHash);
myDevice->lblFWDate->setText(tr("Firmware date: ") + devDesc.gitDate.insert(4, "-").insert(7, "-"));
} else {