|
|
|
@ -115,6 +115,32 @@ QList<QString> SerialLink::getCurrentPorts()
@@ -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)
@@ -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); |
|
|
|
|
|
|
|
|
|