Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
7fc8a233
Commit
7fc8a233
authored
Mar 05, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error messaging
parent
f5776307
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
FirmwareImage.cc
src/VehicleSetup/FirmwareImage.cc
+13
-13
No files found.
src/VehicleSetup/FirmwareImage.cc
View file @
7fc8a233
...
...
@@ -74,7 +74,7 @@ bool FirmwareImage::load(const QString& imageFilename, uint32_t boardId)
_binFormat
=
false
;
return
_ihxLoad
(
imageFilename
);
}
else
{
emit
error
Message
(
"Unsupported file format"
);
emit
status
Message
(
"Unsupported file format"
);
return
false
;
}
}
...
...
@@ -132,7 +132,7 @@ bool FirmwareImage::_ihxLoad(const QString& ihxFilename)
QFile
ihxFile
(
ihxFilename
);
if
(
!
ihxFile
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
emit
error
Message
(
QString
(
"Unable to open firmware file %1, error: %2"
).
arg
(
ihxFilename
).
arg
(
ihxFile
.
errorString
()));
emit
status
Message
(
QString
(
"Unable to open firmware file %1, error: %2"
).
arg
(
ihxFilename
).
arg
(
ihxFile
.
errorString
()));
return
false
;
}
...
...
@@ -140,7 +140,7 @@ bool FirmwareImage::_ihxLoad(const QString& ihxFilename)
while
(
true
)
{
if
(
stream
.
read
(
1
)
!=
":"
)
{
emit
error
Message
(
"Incorrectly formatted .ihx file, line does not begin with :"
);
emit
status
Message
(
"Incorrectly formatted .ihx file, line does not begin with :"
);
return
false
;
}
...
...
@@ -155,12 +155,12 @@ bool FirmwareImage::_ihxLoad(const QString& ihxFilename)
!
_readByteFromStream
(
stream
,
recordType
)
||
!
_readBytesFromStream
(
stream
,
blockByteCount
,
bytes
)
||
!
_readByteFromStream
(
stream
,
crc
))
{
emit
error
Message
(
"Incorrectly formatted line in .ihx file, line too short"
);
emit
status
Message
(
"Incorrectly formatted line in .ihx file, line too short"
);
return
false
;
}
if
(
!
(
recordType
==
0
||
recordType
==
1
))
{
emit
error
Message
(
QString
(
"Unsupported record type in file: %1"
).
arg
(
recordType
));
emit
status
Message
(
QString
(
"Unsupported record type in file: %1"
).
arg
(
recordType
));
return
false
;
}
...
...
@@ -215,7 +215,7 @@ bool FirmwareImage::_px4Load(const QString& imageFilename)
QFile
px4File
(
imageFilename
);
if
(
!
px4File
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
emit
error
Message
(
QString
(
"Unable to open firmware file %1, error: %2"
).
arg
(
imageFilename
).
arg
(
px4File
.
errorString
()));
emit
status
Message
(
QString
(
"Unable to open firmware file %1, error: %2"
).
arg
(
imageFilename
).
arg
(
px4File
.
errorString
()));
return
false
;
}
...
...
@@ -224,7 +224,7 @@ bool FirmwareImage::_px4Load(const QString& imageFilename)
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
bytes
);
if
(
doc
.
isNull
())
{
emit
error
Message
(
"Supplied file is not a valid JSON document"
);
emit
status
Message
(
"Supplied file is not a valid JSON document"
);
return
false
;
}
...
...
@@ -235,7 +235,7 @@ bool FirmwareImage::_px4Load(const QString& imageFilename)
QStringList
requiredKeys
;
requiredKeys
<<
_jsonBoardIdKey
<<
_jsonImageKey
<<
_jsonImageSizeKey
;
if
(
!
JsonHelper
::
validateRequiredKeys
(
px4Json
,
requiredKeys
,
errorString
))
{
emit
error
Message
(
QString
(
"Firmware file mission required key: %1"
).
arg
(
errorString
));
emit
status
Message
(
QString
(
"Firmware file mission required key: %1"
).
arg
(
errorString
));
return
false
;
}
...
...
@@ -245,13 +245,13 @@ bool FirmwareImage::_px4Load(const QString& imageFilename)
keys
<<
_jsonBoardIdKey
<<
_jsonParamXmlSizeKey
<<
_jsonParamXmlKey
<<
_jsonAirframeXmlSizeKey
<<
_jsonAirframeXmlKey
<<
_jsonImageSizeKey
<<
_jsonImageKey
<<
_jsonMavAutopilotKey
;
types
<<
QJsonValue
::
Double
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
<<
QJsonValue
::
String
<<
QJsonValue
::
Double
;
if
(
!
JsonHelper
::
validateKeyTypes
(
px4Json
,
keys
,
types
,
errorString
))
{
emit
error
Message
(
QString
(
"Firmware file has invalid key: %1"
).
arg
(
errorString
));
emit
status
Message
(
QString
(
"Firmware file has invalid key: %1"
).
arg
(
errorString
));
return
false
;
}
uint32_t
firmwareBoardId
=
(
uint32_t
)
px4Json
.
value
(
_jsonBoardIdKey
).
toInt
();
if
(
firmwareBoardId
!=
_boardId
)
{
emit
error
Message
(
QString
(
"Downloaded firmware board id does not match hardware board id: %1 != %2"
).
arg
(
firmwareBoardId
).
arg
(
_boardId
));
emit
status
Message
(
QString
(
"Downloaded firmware board id does not match hardware board id: %1 != %2"
).
arg
(
firmwareBoardId
).
arg
(
_boardId
));
return
false
;
}
...
...
@@ -342,13 +342,13 @@ bool FirmwareImage::_px4Load(const QString& imageFilename)
QFile
decompressFile
(
decompressFilename
);
if
(
!
decompressFile
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Truncate
))
{
emit
error
Message
(
QString
(
"Unable to open decompressed file %1 for writing, error: %2"
).
arg
(
decompressFilename
).
arg
(
decompressFile
.
errorString
()));
emit
status
Message
(
QString
(
"Unable to open decompressed file %1 for writing, error: %2"
).
arg
(
decompressFilename
).
arg
(
decompressFile
.
errorString
()));
return
false
;
}
qint64
bytesWritten
=
decompressFile
.
write
(
decompressedBytes
);
if
(
bytesWritten
!=
decompressedBytes
.
count
())
{
emit
error
Message
(
QString
(
"Write failed for decompressed image file, error: %1"
).
arg
(
decompressFile
.
errorString
()));
emit
status
Message
(
QString
(
"Write failed for decompressed image file, error: %1"
).
arg
(
decompressFile
.
errorString
()));
return
false
;
}
decompressFile
.
close
();
...
...
@@ -441,7 +441,7 @@ bool FirmwareImage::_binLoad(const QString& imageFilename)
{
QFile
binFile
(
imageFilename
);
if
(
!
binFile
.
open
(
QIODevice
::
ReadOnly
))
{
emit
error
Message
(
QString
(
"Unabled to open firmware file %1, %2"
).
arg
(
imageFilename
).
arg
(
binFile
.
errorString
()));
emit
status
Message
(
QString
(
"Unabled to open firmware file %1, %2"
).
arg
(
imageFilename
).
arg
(
binFile
.
errorString
()));
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment