From 516416099c37870126bf8b31227251195656e85a Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Tue, 11 May 2021 09:58:38 +0100 Subject: [PATCH] Fixes for virtual serial port in Windows. --- pttyhandler.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pttyhandler.cpp b/pttyhandler.cpp index 8457021..4a5516c 100644 --- a/pttyhandler.cpp +++ b/pttyhandler.cpp @@ -4,10 +4,11 @@ #include #include -#include +#ifndef Q_OS_WIN #include #include #include +#endif // Copyright 2017-2021 Elliott H. Liggett & Phil Taylor @@ -37,11 +38,15 @@ void pttyHandler::openPort() bool success=false; #ifdef Q_OS_WIN + port = new QSerialPort(); port->setPortName(portName); port->setBaudRate(baudRate); port->setStopBits(QSerialPort::OneStop);// OneStop is other option success = port->open(QIODevice::ReadWrite); - connect(port, SIGNAL(readyRead()), this, SLOT(receiveDataIn(0))); + + if (success) { + connect(port, &QSerialPort::readyRead, this, std::bind(&pttyHandler::receiveDataIn, this, (int)0)); + } #else // Generic method in Linux/MacOS to find a pty ptfd = ::posix_openpt(O_RDWR | O_NOCTTY);