Skip to content

Commit

Permalink
Bugfix for racy crash on opening bad serial port
Browse files Browse the repository at this point in the history
Signed-off-by: Benoit Maurin <[email protected]>
  • Loading branch information
unjambonakap committed Nov 21, 2024
1 parent 88f6dd4 commit aacb664
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Comms/SerialLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ bool SerialLink::_hardwareConnect(QSerialPort::SerialPortError& error, QString&

_port = new QSerialPort(_serialConfig->portName(), this);

QObject::connect(_port, &QSerialPort::errorOccurred, this, &SerialLink::linkError);
QObject::connect(_port, &QIODevice::readyRead, this, &SerialLink::_readBytes);

// After the bootloader times out, it still can take a second or so for the Pixhawk USB driver to come up and make
// the port available for open. So we retry a few times to wait for it.
Expand Down Expand Up @@ -216,6 +214,9 @@ bool SerialLink::_hardwareConnect(QSerialPort::SerialPortError& error, QString&

emit connected();

QObject::connect(_port, &QSerialPort::errorOccurred, this, &SerialLink::linkError);
QObject::connect(_port, &QIODevice::readyRead, this, &SerialLink::_readBytes);

qCDebug(SerialLinkLog) << "Connection SeriaLink: " << "with settings" << _serialConfig->portName()
<< _serialConfig->baud() << _serialConfig->dataBits() << _serialConfig->parity() << _serialConfig->stopBits();

Expand Down

0 comments on commit aacb664

Please sign in to comment.