Commit 71e284cd authored by Lorenz Meier's avatar Lorenz Meier

Do not try to talk to bootloaders in the main flight code management routines

parent 323d162e
......@@ -115,6 +115,32 @@ QList<QString> SerialLink::getCurrentPorts()
return m_ports;
}
bool SerialLink::isBootloader()
{
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
if( portList.count() == 0){
return false;
}
foreach (const QSerialPortInfo &info, portList)
{
// qDebug() << "PortName : " << info.portName()
// << "Description : " << info.description();
// qDebug() << "Manufacturer: " << info.manufacturer();
if (info.portName().trimmed() == this->m_portName.trimmed() &&
(info.description().toLower().contains("bootloader") ||
info.description().toLower().contains("px4 bl"))) {
qDebug() << "BOOTLOADER FOUND";
return true;
}
}
// Not found
return false;
}
void SerialLink::loadSettings()
{
// Load defaults from settings
......@@ -445,6 +471,28 @@ bool SerialLink::hardwareConnect(QString &type)
}
qDebug() << "SerialLink: hardwareConnect to " << m_portName;
if (isBootloader()) {
qDebug() << "Not connecting to a bootloader, waiting for 2nd chance";
const unsigned retry_limit = 12;
unsigned retries;
for (retries = 0; retries < retry_limit; retries++) {
if (!isBootloader()) {
break;
}
QGC::SLEEP::msleep(500);
}
// Check limit
if (retries == retry_limit) {
// bail out
return false;
}
}
m_port = new QSerialPort(m_portName);
m_port->moveToThread(this);
......
......@@ -72,6 +72,9 @@ public:
/** @brief Get a list of the currently available ports */
QList<QString> getCurrentPorts();
/** @brief Check if the current port is a bootloader */
bool isBootloader();
void requestReset();
bool isConnected() const;
......
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