|
|
@ -242,7 +242,6 @@ bool FirmwareImage::_px4Load(const QString& imageFilename) |
|
|
|
QSettings settings; |
|
|
|
QSettings settings; |
|
|
|
QDir parameterDir = QFileInfo(settings.fileName()).dir(); |
|
|
|
QDir parameterDir = QFileInfo(settings.fileName()).dir(); |
|
|
|
QString parameterFilename = parameterDir.filePath("PX4ParameterFactMetaData.xml"); |
|
|
|
QString parameterFilename = parameterDir.filePath("PX4ParameterFactMetaData.xml"); |
|
|
|
qDebug() << parameterFilename; |
|
|
|
|
|
|
|
QFile parameterFile(parameterFilename); |
|
|
|
QFile parameterFile(parameterFilename); |
|
|
|
|
|
|
|
|
|
|
|
if (parameterFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
|
|
|
if (parameterFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
|
|
@ -260,6 +259,35 @@ bool FirmwareImage::_px4Load(const QString& imageFilename) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Decompress the airframe xml and save to file
|
|
|
|
|
|
|
|
success = _decompressJsonValue(px4Json, // JSON object
|
|
|
|
|
|
|
|
bytes, // Raw bytes of JSON document
|
|
|
|
|
|
|
|
"airframe_xml_size", // key which holds byte size
|
|
|
|
|
|
|
|
"airframe_xml", // key which holds compress bytes
|
|
|
|
|
|
|
|
decompressedBytes); // Returned decompressed bytes
|
|
|
|
|
|
|
|
if (success) { |
|
|
|
|
|
|
|
// We cache the airframe xml in the same location as settings and parameters
|
|
|
|
|
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
QDir airframeDir = QFileInfo(settings.fileName()).dir(); |
|
|
|
|
|
|
|
QString airframeFilename = airframeDir.filePath("PX4AirframeFactMetaData.xml"); |
|
|
|
|
|
|
|
qDebug() << airframeFilename; |
|
|
|
|
|
|
|
QFile airframeFile(airframeFilename); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (airframeFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
|
|
|
|
|
|
|
qint64 bytesWritten = airframeFile.write(decompressedBytes); |
|
|
|
|
|
|
|
if (bytesWritten != decompressedBytes.count()) { |
|
|
|
|
|
|
|
// FIXME: What about these warnings?
|
|
|
|
|
|
|
|
emit statusMessage(QString("Write failed for airframe meta data file, error: %1").arg(airframeFile.errorString())); |
|
|
|
|
|
|
|
airframeFile.close(); |
|
|
|
|
|
|
|
QFile::remove(airframeFilename); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
airframeFile.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
emit statusMessage(QString("Unable to open airframe meta data file %1 for writing, error: %2").arg(airframeFilename).arg(airframeFile.errorString())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Decompress the image and save to file
|
|
|
|
// Decompress the image and save to file
|
|
|
|
_imageSize = px4Json.value(QString("image_size")).toInt(); |
|
|
|
_imageSize = px4Json.value(QString("image_size")).toInt(); |
|
|
|
success = _decompressJsonValue(px4Json, // JSON object
|
|
|
|
success = _decompressJsonValue(px4Json, // JSON object
|
|
|
|