Modified the way that the serial port is opened to hopefully be more cross platform.

This commit is contained in:
Collin Kidder
2015-05-13 20:00:59 -04:00
parent 60e5b323cf
commit b634024fb2
4 changed files with 33 additions and 22 deletions
+19 -18
View File
@@ -16,26 +16,27 @@ SerialWorker::~SerialWorker()
if (serial != NULL) delete serial;
}
void SerialWorker::setSerialPort(QString portName)
void SerialWorker::setSerialPort(QSerialPortInfo &port)
{
if (serial == NULL) serial = new QSerialPort(this);
if (!(serial == NULL))
{
if (serial->isOpen())
{
serial->close();
}
delete serial;
}
if (serial->isOpen())
{
serial->close();
}
else
{
qDebug() << "Serial port name is " << portName;
serial->setPortName(portName);
serial->open(QIODevice::ReadWrite);
QByteArray output;
output.append(0xE7);
output.append(0xE7);
serial->write(output);
///isConnected = true;
connect(serial, SIGNAL(readyRead()), this, SLOT(readSerialData()));
}
serial = new QSerialPort(port);
qDebug() << "Serial port name is " << port.portName();
serial->open(QIODevice::ReadWrite);
QByteArray output;
output.append(0xE7);
output.append(0xE7);
serial->write(output);
///isConnected = true;
connect(serial, SIGNAL(readyRead()), this, SLOT(readSerialData()));
}
void SerialWorker::readSerialData()