What I'm trying to do is write string to the serial port from the windows 7 host machine to the /dev/ttys0 in the guest Ubuntu machine.
I tested this using putty on both the host and guest machine. The data is written to the /dev/ttys0 from \.\pipe\COM1.
Now I want to use a simple QT5 program using this virtual serial port to write a string to the guest putty.
The problem I have is that the program isn't able to open this port , below is the Qt program.
#include <QtCore/QCoreApplication>
#include <QSerialPort>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSerialPort serial;
qDebug() << " Serial communication starts .. ";
serial.setPortName("\\.\pipe\COM1");
if(serial.open(QIODevice::ReadWrite))
{
serial.setBaudRate(QSerialPort::Baud9600);
serial.setDataBits(QSerialPort::Data8);
serial.setParity(QSerialPort::NoParity);
serial.setStopBits(QSerialPort::OneStop);
serial.setFlowControl(QSerialPort::NoFlowControl);
serial.write("blah blah");
}
else
qDebug() << " Serial port isn't open : " << serial.errorString();
while(serial.canReadLine())
{
qDebug() << " serial.readLine()" ;
}
serial.close();
return a.exec();
}
the output of the debug :
Serial communication starts ..
Serial port isn't open : "No such file or directory"
\\\\.\\pipe\\COM1
orR"(\\.\pipe\COM1)"
– Niall