mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
* use QSerialPortInfo do detect presence of a serial port (fix #836) * checking for existence of device file does not work on windows * instead: construct QSerialPortInfo from device name and check, if it is not null When constructing QSerialPortInfo from device name, this constructor finds the relevant serial port among the available ones according to the port name name, and constructs the serial port info instance for that port. (https://doc.qt.io/qt-5/qserialportinfo.html#QSerialPortInfo-2) * serial port: set device in error with a failure text, if device name is invalid Co-authored-by: heiko <heiko@bihr.internal>
This commit is contained in:
parent
2562787dae
commit
e365a2839d
@ -201,7 +201,9 @@ bool ProviderRs232::tryOpen(const int delayAfterConnect_ms)
|
||||
if ( ! _rs232Port.isOpen() )
|
||||
{
|
||||
_frameDropCounter = 0;
|
||||
if (QFile::exists(_deviceName))
|
||||
|
||||
QSerialPortInfo serialPortInfo(_deviceName);
|
||||
if (! serialPortInfo.isNull())
|
||||
{
|
||||
if ( _preOpenDelayTimeOut > QDateTime::currentMSecsSinceEpoch() )
|
||||
{
|
||||
@ -223,6 +225,8 @@ bool ProviderRs232::tryOpen(const int delayAfterConnect_ms)
|
||||
}
|
||||
else
|
||||
{
|
||||
QString errortext = QString("Invalid serial device name: [%1]!").arg(_deviceName);
|
||||
this->setInError(errortext);
|
||||
_preOpenDelayTimeOut = QDateTime::currentMSecsSinceEpoch() + _preOpenDelay;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user