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
2c486689
Commit
2c486689
authored
Nov 17, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #975 from DonLakeFlyer/UpgradeErrors
Better error reporting during Firmware Upgrade
parents
a16ca740
d7257ad4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
105 deletions
+84
-105
qextserialport.cpp
libs/qextserialport/src/qextserialport.cpp
+2
-0
qextserialport.h
libs/qextserialport/src/qextserialport.h
+2
-1
qextserialport_p.h
libs/qextserialport/src/qextserialport_p.h
+2
-0
qextserialport_unix.cpp
libs/qextserialport/src/qextserialport_unix.cpp
+5
-0
qextserialport_win.cpp
libs/qextserialport/src/qextserialport_win.cpp
+17
-27
PX4Bootloader.cc
src/ui/px4_configuration/PX4Bootloader.cc
+44
-44
PX4Bootloader.h
src/ui/px4_configuration/PX4Bootloader.h
+3
-7
PX4FirmwareUpgradeThread.cc
src/ui/px4_configuration/PX4FirmwareUpgradeThread.cc
+9
-26
No files found.
libs/qextserialport/src/qextserialport.cpp
View file @
2c486689
...
...
@@ -755,6 +755,8 @@ QString QextSerialPort::errorString()
return
tr
(
"Permission denied"
);
case
E_AGAIN
:
return
tr
(
"Device is already locked"
);
case
E_OS_SPECIFIC
:
return
tr
(
"OS error: %1"
).
arg
(
d
->
lastOSErrString
);
default:
return
tr
(
"Unknown error: %1"
).
arg
(
d
->
lastErr
);
}
...
...
libs/qextserialport/src/qextserialport.h
View file @
2c486689
...
...
@@ -68,6 +68,7 @@
#define E_FILE_NOT_FOUND 15
#define E_PERMISSION_DENIED 16
#define E_AGAIN 17
#define E_OS_SPECIFIC 18 // Error did not translate, os error code in lastOSErr
enum
BaudRateType
{
...
...
@@ -201,7 +202,7 @@ public:
bool
canReadLine
()
const
;
QByteArray
readAll
();
ulong
lastError
()
const
;
ulong
lastError
()
const
;
ulong
lastOpenOSError
()
const
;
ulong
lineStatus
();
QString
errorString
();
...
...
libs/qextserialport/src/qextserialport_p.h
View file @
2c486689
...
...
@@ -197,6 +197,8 @@ public:
QextReadBuffer
readBuffer
;
int
settingsDirtyFlags
;
ulong
lastErr
;
ulong
lastOSErr
;
QString
lastOSErrString
;
QextSerialPort
::
QueryMode
queryMode
;
// platform specific members
...
...
libs/qextserialport/src/qextserialport_unix.cpp
View file @
2c486689
...
...
@@ -155,6 +155,11 @@ void QextSerialPortPrivate::translateError(ulong error)
case
EAGAIN
:
lastErr
=
E_AGAIN
;
break
;
default:
lastOSErr
=
error
;
lastOSErrString
=
strerror
(
error
);
lastErr
=
E_OS_SPECIFIC
;
break
;
}
}
...
...
libs/qextserialport/src/qextserialport_win.cpp
View file @
2c486689
...
...
@@ -106,6 +106,7 @@ bool QextSerialPortPrivate::open_sys(QIODevice::OpenMode mode)
if
(
queryMode
==
QextSerialPort
::
EventDriven
)
{
if
(
!
SetCommMask
(
handle
,
EV_TXEMPTY
|
EV_RXCHAR
|
EV_DSR
))
{
QESP_WARNING
()
<<
"failed to set Comm Mask. Error code:"
<<
GetLastError
();
translateError
(
GetLastError
());
return
false
;
}
winEventNotifier
=
new
QWinEventNotifier
(
overlap
.
hEvent
,
q
);
...
...
@@ -115,6 +116,7 @@ bool QextSerialPortPrivate::open_sys(QIODevice::OpenMode mode)
}
return
true
;
}
translateError
(
GetLastError
());
return
false
;
}
...
...
@@ -159,30 +161,18 @@ qint64 QextSerialPortPrivate::bytesAvailable_sys() const
*/
void
QextSerialPortPrivate
::
translateError
(
ulong
error
)
{
if
(
error
&
CE_BREAK
)
{
lastErr
=
E_BREAK_CONDITION
;
}
else
if
(
error
&
CE_FRAME
)
{
lastErr
=
E_FRAMING_ERROR
;
}
else
if
(
error
&
CE_IOE
)
{
lastErr
=
E_IO_ERROR
;
}
else
if
(
error
&
CE_MODE
)
{
lastErr
=
E_INVALID_FD
;
}
else
if
(
error
&
CE_OVERRUN
)
{
lastErr
=
E_BUFFER_OVERRUN
;
}
else
if
(
error
&
CE_RXPARITY
)
{
lastErr
=
E_RECEIVE_PARITY_ERROR
;
}
else
if
(
error
&
CE_RXOVER
)
{
lastErr
=
E_RECEIVE_OVERFLOW
;
}
else
if
(
error
&
CE_TXFULL
)
{
lastErr
=
E_TRANSMIT_OVERFLOW
;
}
lastOSErr
=
error
;
lastErr
=
E_OS_SPECIFIC
;
char
buf
[
256
];
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
error
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
buf
,
sizeof
(
buf
),
NULL
);
lastOSErrString
=
buf
;
}
/*
...
...
@@ -212,8 +202,8 @@ qint64 QextSerialPortPrivate::readData_sys(char *data, qint64 maxSize)
if
(
!
failed
)
return
(
qint64
)
bytesRead
;
lastErr
=
E_READ_FAILED
;
return
-
1
;
translateError
(
GetLastError
())
;
return
-
1
;
}
/*
...
...
@@ -257,7 +247,7 @@ qint64 QextSerialPortPrivate::writeData_sys(const char *data, qint64 maxSize)
if
(
!
failed
)
return
(
qint64
)
bytesWritten
;
lastErr
=
E_WRITE_FAILED
;
translateError
(
GetLastError
())
;
return
-
1
;
}
...
...
src/ui/px4_configuration/PX4Bootloader.cc
View file @
2c486689
This diff is collapsed.
Click to expand it.
src/ui/px4_configuration/PX4Bootloader.h
View file @
2c486689
...
...
@@ -43,9 +43,6 @@ public:
/// @brief Returns the error message associated with the last failed call to one of the bootloader
/// utility routine below.
QString
errorString
(
void
)
{
return
_errorString
;
}
static
const
bool
warnOnError
=
true
;
///< call qWarning to log error message on error
static
const
bool
noWarnOnError
=
false
;
///< Don't call qWarning on error
/// @brief Write a byte to the port
/// @param port Port to write to
...
...
@@ -58,13 +55,12 @@ public:
/// @brief Read a set of bytes from the port
/// @param data Read bytes into this buffer
/// @param maxSize Number of bytes to read
/// @param warnOnError true: Log error using qWarning
/// @param readTimeout Msecs to wait for bytes to become available on port
bool
read
(
QextSerialPort
*
port
,
uint8_t
*
data
,
qint64
maxSize
,
bool
warnOnError
,
int
readTimeout
=
_readTimout
);
bool
read
(
QextSerialPort
*
port
,
uint8_t
*
data
,
qint64
maxSize
,
int
readTimeout
=
_readTimout
);
/// @brief Read a PROTO_SYNC command response from the bootloader
/// @param responseTimeout Msecs to wait for response bytes to become available on port
bool
getCommandResponse
(
QextSerialPort
*
port
,
bool
warnOnError
,
const
int
responseTimeout
=
_responseTimeout
);
bool
getCommandResponse
(
QextSerialPort
*
port
,
const
int
responseTimeout
=
_responseTimeout
);
/// @brief Send a PROTO_GET_DEVICE command to retrieve a value from the bootloader
/// @param param Value to retrieve using INFO_BOARD_* enums
...
...
@@ -74,7 +70,7 @@ public:
/// @brief Send a command to the bootloader
/// @param cmd Command to send using PROTO_* enums
/// @return true: Command sent and valid sync response returned
bool
sendCommand
(
QextSerialPort
*
port
,
uint8_t
cmd
,
bool
warnOnError
,
int
responseTimeout
=
_responseTimeout
);
bool
sendCommand
(
QextSerialPort
*
port
,
uint8_t
cmd
,
int
responseTimeout
=
_responseTimeout
);
/// @brief Program the board with the specified firmware
bool
program
(
QextSerialPort
*
port
,
const
QString
&
firmwareFilename
);
...
...
src/ui/px4_configuration/PX4FirmwareUpgradeThread.cc
View file @
2c486689
...
...
@@ -102,11 +102,6 @@ void PX4FirmwareUpgradeThreadWorker::_findBoardOnce(void)
portName
=
info
.
systemLocation
();
portDescription
=
info
.
description
();
#ifdef Q_OS_WIN
// Stupid windows fixes
portName
.
prepend
(
"
\\\\
.
\\
"
);
#endif
_closeFind
();
emit
foundBoard
(
_findBoardFirstAttempt
,
portName
,
portDescription
);
return
;
...
...
@@ -121,10 +116,10 @@ void PX4FirmwareUpgradeThreadWorker::_findBoardOnce(void)
void
PX4FirmwareUpgradeThreadWorker
::
findBootloader
(
const
QString
portName
,
int
msecTimeout
)
{
connect
(
_timerRetry
,
&
QTimer
::
timeout
,
this
,
&
PX4FirmwareUpgradeThreadWorker
::
_findBootloaderOnce
);
Q_UNUSED
(
msecTimeout
);
// Once the port shows up, we only try to connect to the bootloader a single time
_portName
=
portName
;
_timerTimeout
->
start
(
msecTimeout
);
_elapsed
.
start
();
_findBootloaderOnce
();
}
...
...
@@ -144,28 +139,16 @@ void PX4FirmwareUpgradeThreadWorker::_findBootloaderOnce(void)
qDebug
()
<<
"Found bootloader"
;
emit
foundBootloader
(
bootloaderVersion
,
boardID
,
flashSize
);
return
;
}
else
{
_closeFind
();
_bootloaderPort
->
close
();
_bootloaderPort
->
deleteLater
();
_bootloaderPort
=
NULL
;
qDebug
()
<<
"Bootloader Get Board Info error:"
<<
_bootloader
->
errorString
();
emit
error
(
commandBootloader
,
_bootloader
->
errorString
());
return
;
}
}
else
{
_closeFind
();
_bootloaderPort
->
close
();
_bootloaderPort
->
deleteLater
();
_bootloaderPort
=
NULL
;
qDebug
()
<<
"Bootloader sync failed"
;
emit
bootloaderSyncFailed
();
return
;
}
}
emit
updateProgress
(
_elapsed
.
elapsed
(),
_timerTimeout
->
interval
());
_timerRetry
->
start
();
_closeFind
();
_bootloaderPort
->
close
();
_bootloaderPort
->
deleteLater
();
_bootloaderPort
=
NULL
;
qDebug
()
<<
"Bootloader error:"
<<
_bootloader
->
errorString
();
emit
error
(
commandBootloader
,
_bootloader
->
errorString
());
}
void
PX4FirmwareUpgradeThreadWorker
::
_closeFind
(
void
)
...
...
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