close the port under certain error conditions
This commit is contained in:
parent
379ae89cb6
commit
49b25f0a86
@ -28,6 +28,7 @@ DmxWidget::DmxWidget(QObject *parent)
|
||||
, port_(new QSerialPort(this))
|
||||
{
|
||||
connect(this, &DmxWidget::serialDataRead, this, &DmxWidget::parseMessageBuffer);
|
||||
connect(port_, &QSerialPort::errorOccurred, this, &DmxWidget::serialErrorOccured);
|
||||
}
|
||||
|
||||
|
||||
@ -159,6 +160,25 @@ void DmxWidget::sendMessage(std::shared_ptr<ENTTEC::Pro::MessageData> msg) const
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief DmxWidget::serialErrorOccured
|
||||
* @param error
|
||||
*/
|
||||
void DmxWidget::serialErrorOccured(QSerialPort::SerialPortError error)
|
||||
{
|
||||
switch (error) {
|
||||
case QSerialPort::WriteError:
|
||||
case QSerialPort::ReadError:
|
||||
case QSerialPort::ResourceError:
|
||||
case QSerialPort::TimeoutError:
|
||||
close();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief DmxWidget::availableWidgets
|
||||
* @return
|
||||
|
@ -77,6 +77,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void parseMessageBuffer();
|
||||
void serialErrorOccured(QSerialPort::SerialPortError);
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(DmxWidget::RxErrors)
|
||||
|
Loading…
Reference in New Issue
Block a user