Commit 5910f425 authored by Don Gagne's avatar Don Gagne

Remove unused code, add error address

parent ae8ffd0c
......@@ -78,54 +78,12 @@ static quint32 crc32(const uint8_t *src, unsigned len, unsigned state)
return state;
}
#if 0
const struct PX4Bootloader::serialPortErrorString PX4Bootloader::_rgSerialPortErrors[14] = {
{ QextSerialPort::NoError, "No error occurred." },
{ QextSerialPort::DeviceNotFoundError, "An error occurred while attempting to open a non-existing device." },
{ QextSerialPort::PermissionError, "An error occurred while attempting to open an already opened device by another process or a user not having enough permission and credentials to open." },
{ QextSerialPort::OpenError, "An error occurred while attempting to open an already opened device in this object." },
{ QextSerialPort::NotOpenError, "This error occurs when an operation is executed that can only be successfully performed if the device is open." },
{ QextSerialPort::ParityError, "Parity error detected by the hardware while reading data." },
{ QextSerialPort::FramingError, "Framing error detected by the hardware while reading data." },
{ QextSerialPort::BreakConditionError, "Break condition detected by the hardware on the input line." },
{ QextSerialPort::WriteError, "An I/O error occurred while writing the data." },
{ QextSerialPort::ReadError, "An I/O error occurred while reading the data." },
{ QextSerialPort::ResourceError, "An I/O error occurred when a resource becomes unavailable, e.g. when the device is unexpectedly removed from the system." },
{ QextSerialPort::UnsupportedOperationError, "The requested device operation is not supported or prohibited by the running operating system." },
{ QextSerialPort::TimeoutError, "A timeout error occurred." },
{ QextSerialPort::UnknownError, "An unidentified error occurred." }
};
#endif
PX4Bootloader::PX4Bootloader(QObject *parent) :
QObject(parent)
{
}
/// @brief Translate a QextSerialPort::SerialPortError code into a string.
const char* PX4Bootloader::_serialPortErrorString(int error)
{
Q_UNUSED(error);
#if 0
Again:
for (size_t i=0; i<sizeof(_rgSerialPortErrors)/sizeof(_rgSerialPortErrors[0]); i++) {
if (error == _rgSerialPortErrors[i].error) {
return _rgSerialPortErrors[i].errorString;
}
}
error = QextSerialPort::UnknownError;
goto Again;
Q_ASSERT(false);
return NULL;
#else
return "NYI error";
#endif
}
bool PX4Bootloader::write(QextSerialPort* port, const uint8_t* data, qint64 maxSize)
{
qint64 bytesWritten = port->write((const char*)data, maxSize);
......@@ -301,7 +259,7 @@ bool PX4Bootloader::program(QextSerialPort* port, const QString& firmwareFilenam
}
}
if (failed) {
_errorString = tr("Flash failed: %1").arg(_errorString);
_errorString = tr("Flash failed: %1 at address 0x%2").arg(_errorString).arg(bytesSent, 8, 16, QLatin1Char('0'));
qWarning() << _errorString;
return false;
}
......@@ -393,12 +351,14 @@ bool PX4Bootloader::_bootloaderVerifyRev2(QextSerialPort* port, const QString fi
}
}
if (failed) {
_errorString = tr("Verify failed: %1 at address: 0x%2").arg(_errorString).arg(bytesVerified, 8, 16, QLatin1Char('0'));
qWarning() << _errorString;
return false;
}
for (int i=0; i<bytesToRead; i++) {
if (fileBuf[i] != flashBuf[i]) {
_errorString = tr("Compare failed at %1: file(0x%2) flash(0x%3)").arg(bytesVerified + i).arg(fileBuf[i], 2, 16, QLatin1Char('0')).arg(flashBuf[i], 2, 16, QLatin1Char('0'));
_errorString = tr("Compare failed at %1: file(0x%2) flash(0x%3) at address: 0x%4").arg(bytesVerified + i).arg(fileBuf[i], 2, 16, QLatin1Char('0')).arg(flashBuf[i], 2, 16, QLatin1Char('0')).arg(bytesVerified, 8, 16, QLatin1Char('0'));
qWarning() << _errorString;
return false;
}
......
......@@ -138,12 +138,7 @@ private:
INFO_FLASH_SIZE = 4, ///< max firmware size in bytes
PROG_MULTI_MAX = 32, ///< write size for PROTO_PROG_MULTI, must be multiple of 4
READ_MULTI_MAX = 64 ///< read size for PROTO_READ_MULTI, must be multiple of 4
};
struct serialPortErrorString {
int error;
const char* errorString;
READ_MULTI_MAX = 32 ///< read size for PROTO_READ_MULTI, must be multiple of 4
};
bool _findBootloader(void);
......@@ -151,8 +146,6 @@ private:
bool _bootloaderVerifyRev2(QextSerialPort* port, const QString firmwareFilename);
bool _bootloaderVerifyRev3(QextSerialPort* port);
const char* _serialPortErrorString(int error);
static const int _boardIDPX4FMUV1 = 5; ///< Board ID for PX4 V1 board
static const int _boardIDPX4FMUV2 = 9; ///< Board ID for PX4 V2 board
static const int _boardIDPX4Flow = 6; ///< Board ID for PX4 Floaw board
......@@ -166,8 +159,6 @@ private:
QString _errorString; ///< Last error
static const struct serialPortErrorString _rgSerialPortErrors[14]; ///< Translation of QextSerialPort::SerialPortError into string
static const int _eraseTimeout = 20000; ///< Msecs to wait for response from erase command
static const int _rebootTimeout = 10000; ///< Msecs to wait for reboot command to cause serial port to disconnect
static const int _verifyTimeout = 5000; ///< Msecs to wait for response to PROTO_GET_CRC command
......
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