Commit 3217c367 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5146 from DonLakeFlyer/FirmwareCustomVersion

Pull firmware custom version from PX4
parents 5bc0f432 76efcc81
...@@ -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)
...@@ -713,10 +721,15 @@ void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& me ...@@ -713,10 +721,15 @@ void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& me
setFirmwareVersion(majorVersion, minorVersion, patchVersion, versionType); setFirmwareVersion(majorVersion, minorVersion, patchVersion, versionType);
} }
// Git hash
if (autopilotVersion.flight_custom_version[0] != 0) {
// 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);
// PX4 Firmware stores the first 16 characters of the git hash as binary, with the individual bytes in reverse order
_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--) {
...@@ -727,7 +740,6 @@ void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& me ...@@ -727,7 +740,6 @@ void Vehicle::_handleAutopilotVersion(LinkInterface *link, mavlink_message_t& me
_gitHash = QString::fromUtf8((char*)autopilotVersion.flight_custom_version, 8); _gitHash = QString::fromUtf8((char*)autopilotVersion.flight_custom_version, 8);
} }
emit gitHashChanged(_gitHash); emit gitHashChanged(_gitHash);
}
_setCapabilities(autopilotVersion.capabilities); _setCapabilities(autopilotVersion.capabilities);
_startPlanRequest(); _startPlanRequest();
...@@ -2291,10 +2303,15 @@ void Vehicle::setFirmwareVersion(int majorVersion, int minorVersion, int patchVe ...@@ -2291,10 +2303,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,11 +351,14 @@ public: ...@@ -351,11 +351,14 @@ 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(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) Q_PROPERTY(QString gitHash READ gitHash NOTIFY gitHashChanged)
/// Resets link status counters /// Resets link status counters
...@@ -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