Commit 59f7a2fc authored by DonLakeFlyer's avatar DonLakeFlyer

Pull firmware custom version from PX4

parent e8cce68c
...@@ -140,7 +140,11 @@ Vehicle::Vehicle(LinkInterface* link, ...@@ -140,7 +140,11 @@ Vehicle::Vehicle(LinkInterface* link,
, _firmwareMajorVersion(versionNotSetValue) , _firmwareMajorVersion(versionNotSetValue)
, _firmwareMinorVersion(versionNotSetValue) , _firmwareMinorVersion(versionNotSetValue)
, _firmwarePatchVersion(versionNotSetValue) , _firmwarePatchVersion(versionNotSetValue)
, _firmwareCustomMajorVersion(versionNotSetValue)
, _firmwareCustomMinorVersion(versionNotSetValue)
, _firmwareCustomPatchVersion(versionNotSetValue)
, _firmwareVersionType(FIRMWARE_VERSION_TYPE_OFFICIAL) , _firmwareVersionType(FIRMWARE_VERSION_TYPE_OFFICIAL)
, _gitHash(versionNotSetValue)
, _lastAnnouncedLowBatteryPercent(100) , _lastAnnouncedLowBatteryPercent(100)
, _rollFact (0, _rollFactName, FactMetaData::valueTypeDouble) , _rollFact (0, _rollFactName, FactMetaData::valueTypeDouble)
, _pitchFact (0, _pitchFactName, FactMetaData::valueTypeDouble) , _pitchFact (0, _pitchFactName, FactMetaData::valueTypeDouble)
...@@ -294,6 +298,10 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, ...@@ -294,6 +298,10 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType,
, _firmwareMajorVersion(versionNotSetValue) , _firmwareMajorVersion(versionNotSetValue)
, _firmwareMinorVersion(versionNotSetValue) , _firmwareMinorVersion(versionNotSetValue)
, _firmwarePatchVersion(versionNotSetValue) , _firmwarePatchVersion(versionNotSetValue)
, _firmwareCustomMajorVersion(versionNotSetValue)
, _firmwareCustomMinorVersion(versionNotSetValue)
, _firmwareCustomPatchVersion(versionNotSetValue)
, _firmwareVersionType(FIRMWARE_VERSION_TYPE_OFFICIAL)
, _gitHash(versionNotSetValue) , _gitHash(versionNotSetValue)
, _lastAnnouncedLowBatteryPercent(100) , _lastAnnouncedLowBatteryPercent(100)
, _rollFact (0, _rollFactName, FactMetaData::valueTypeDouble) , _rollFact (0, _rollFactName, FactMetaData::valueTypeDouble)
...@@ -714,14 +722,23 @@ void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& me ...@@ -714,14 +722,23 @@ void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& me
} }
// Git hash // Git hash
if (autopilotVersion.flight_custom_version[0] != 0) { if (*((uint64_t*)(&autopilotVersion.flight_custom_version)) != 0) {
// PX4 Firmware stores the first 16 characters of the git hash as binary, with the individual bytes in reverse order // PX4 Firmware stores the first 16 characters of the git hash as binary, with the individual bytes in reverse order
if (px4Firmware()) { if (px4Firmware()) {
// Lower 3 bytes is custom version
int majorVersion, minorVersion, patchVersion;
majorVersion = autopilotVersion.flight_custom_version[2];
minorVersion = autopilotVersion.flight_custom_version[1];
patchVersion = autopilotVersion.flight_custom_version[0];
setFirmwareCustomVersion(majorVersion, minorVersion, patchVersion);
qDebug() << majorVersion << minorVersion << patchVersion;
_gitHash = ""; _gitHash = "";
QByteArray array((char*)autopilotVersion.flight_custom_version, 8); QByteArray array((char*)autopilotVersion.flight_custom_version, 8);
for (int i = 7; i >= 0; i--) { for (int i = 7; i >= 0; i--) {
_gitHash.append(QString("%1").arg(autopilotVersion.flight_custom_version[i], 2, 16, QChar('0'))); _gitHash.append(QString("%1").arg(autopilotVersion.flight_custom_version[i], 2, 16, QChar('0')));
} }
} else { } else {
// APM Firmware stores the first 8 characters of the git hash as an ASCII character string // APM Firmware stores the first 8 characters of the git hash as an ASCII character string
_gitHash = QString::fromUtf8((char*)autopilotVersion.flight_custom_version, 8); _gitHash = QString::fromUtf8((char*)autopilotVersion.flight_custom_version, 8);
...@@ -2290,10 +2307,15 @@ void Vehicle::setFirmwareVersion(int majorVersion, int minorVersion, int patchVe ...@@ -2290,10 +2307,15 @@ void Vehicle::setFirmwareVersion(int majorVersion, int minorVersion, int patchVe
_firmwareMinorVersion = minorVersion; _firmwareMinorVersion = minorVersion;
_firmwarePatchVersion = patchVersion; _firmwarePatchVersion = patchVersion;
_firmwareVersionType = versionType; _firmwareVersionType = versionType;
emit firmwareMajorVersionChanged(_firmwareMajorVersion); emit firmwareVersionChanged();
emit firmwareMinorVersionChanged(_firmwareMinorVersion); }
emit firmwarePatchVersionChanged(_firmwarePatchVersion);
emit firmwareVersionTypeChanged(_firmwareVersionType); void Vehicle::setFirmwareCustomVersion(int majorVersion, int minorVersion, int patchVersion)
{
_firmwareCustomMajorVersion = majorVersion;
_firmwareCustomMinorVersion = minorVersion;
_firmwareCustomPatchVersion = patchVersion;
emit firmwareCustomVersionChanged();
} }
QString Vehicle::firmwareVersionTypeString(void) const QString Vehicle::firmwareVersionTypeString(void) const
......
...@@ -351,12 +351,15 @@ public: ...@@ -351,12 +351,15 @@ public:
Q_PROPERTY(FactGroup* vibration READ vibrationFactGroup CONSTANT) Q_PROPERTY(FactGroup* vibration READ vibrationFactGroup CONSTANT)
Q_PROPERTY(FactGroup* temperature READ temperatureFactGroup CONSTANT) Q_PROPERTY(FactGroup* temperature READ temperatureFactGroup CONSTANT)
Q_PROPERTY(int firmwareMajorVersion READ firmwareMajorVersion NOTIFY firmwareMajorVersionChanged) Q_PROPERTY(int firmwareMajorVersion READ firmwareMajorVersion NOTIFY firmwareVersionChanged)
Q_PROPERTY(int firmwareMinorVersion READ firmwareMinorVersion NOTIFY firmwareMinorVersionChanged) Q_PROPERTY(int firmwareMinorVersion READ firmwareMinorVersion NOTIFY firmwareVersionChanged)
Q_PROPERTY(int firmwarePatchVersion READ firmwarePatchVersion NOTIFY firmwarePatchVersionChanged) Q_PROPERTY(int firmwarePatchVersion READ firmwarePatchVersion NOTIFY firmwareVersionChanged)
Q_PROPERTY(int firmwareVersionType READ firmwareVersionType NOTIFY firmwareVersionTypeChanged) Q_PROPERTY(int firmwareVersionType READ firmwareVersionType NOTIFY firmwareVersionChanged)
Q_PROPERTY(QString firmwareVersionTypeString READ firmwareVersionTypeString NOTIFY firmwareVersionTypeChanged) Q_PROPERTY(QString firmwareVersionTypeString READ firmwareVersionTypeString NOTIFY firmwareVersionChanged)
Q_PROPERTY(QString gitHash READ gitHash NOTIFY gitHashChanged) Q_PROPERTY(int firmwareCustomMajorVersion READ firmwareCustomMajorVersion NOTIFY firmwareCustomVersionChanged)
Q_PROPERTY(int firmwareCustomMinorVersion READ firmwareCustomMinorVersion NOTIFY firmwareCustomVersionChanged)
Q_PROPERTY(int firmwareCustomPatchVersion READ firmwareCustomPatchVersion NOTIFY firmwareCustomVersionChanged)
Q_PROPERTY(QString gitHash READ gitHash NOTIFY gitHashChanged)
/// Resets link status counters /// Resets link status counters
Q_INVOKABLE void resetCounters (); Q_INVOKABLE void resetCounters ();
...@@ -631,8 +634,12 @@ public: ...@@ -631,8 +634,12 @@ public:
int firmwareMinorVersion(void) const { return _firmwareMinorVersion; } int firmwareMinorVersion(void) const { return _firmwareMinorVersion; }
int firmwarePatchVersion(void) const { return _firmwarePatchVersion; } int firmwarePatchVersion(void) const { return _firmwarePatchVersion; }
int firmwareVersionType(void) const { return _firmwareVersionType; } int firmwareVersionType(void) const { return _firmwareVersionType; }
int firmwareCustomMajorVersion(void) const { return _firmwareCustomMajorVersion; }
int firmwareCustomMinorVersion(void) const { return _firmwareCustomMinorVersion; }
int firmwareCustomPatchVersion(void) const { return _firmwareCustomPatchVersion; }
QString firmwareVersionTypeString(void) const; QString firmwareVersionTypeString(void) const;
void setFirmwareVersion(int majorVersion, int minorVersion, int patchVersion, FIRMWARE_VERSION_TYPE versionType = FIRMWARE_VERSION_TYPE_OFFICIAL); void setFirmwareVersion(int majorVersion, int minorVersion, int patchVersion, FIRMWARE_VERSION_TYPE versionType = FIRMWARE_VERSION_TYPE_OFFICIAL);
void setFirmwareCustomVersion(int majorVersion, int minorVersion, int patchVersion);
static const int versionNotSetValue = -1; static const int versionNotSetValue = -1;
QString gitHash(void) const { return _gitHash; } QString gitHash(void) const { return _gitHash; }
...@@ -734,11 +741,8 @@ signals: ...@@ -734,11 +741,8 @@ signals:
void telemetryRNoiseChanged (int value); void telemetryRNoiseChanged (int value);
void autoDisarmChanged (void); void autoDisarmChanged (void);
void firmwareMajorVersionChanged(int major); void firmwareVersionChanged(void);
void firmwareMinorVersionChanged(int minor); void firmwareCustomVersionChanged(void);
void firmwarePatchVersionChanged(int patch);
void firmwareVersionTypeChanged(int type);
void gitHashChanged(QString hash); void gitHashChanged(QString hash);
/// New RC channel values /// New RC channel values
...@@ -986,6 +990,9 @@ private: ...@@ -986,6 +990,9 @@ private:
int _firmwareMajorVersion; int _firmwareMajorVersion;
int _firmwareMinorVersion; int _firmwareMinorVersion;
int _firmwarePatchVersion; int _firmwarePatchVersion;
int _firmwareCustomMajorVersion;
int _firmwareCustomMinorVersion;
int _firmwareCustomPatchVersion;
FIRMWARE_VERSION_TYPE _firmwareVersionType; FIRMWARE_VERSION_TYPE _firmwareVersionType;
QString _gitHash; QString _gitHash;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment