In Fedora I run the socat command:
socat -d -d pty,link=/dev/ttyS0,raw,echo=0 tcp-listen:1234
so I can receive strings from a TCP Client (created with QT) and forward them to the serial port
ttyS0.
In the TCP Client I created a virtual driver too using this code:
<pre lang="c++">
#include <windows.h>
HANDLE hdriver = CreateFileA("\\.\COM12", GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0); hdriver = CreateFileA("\\.\COM12", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if(hdriver == INVALID_HANDLE_VALUE)
{
qDebug() << GetLastError();
CloseHandle(hdriver);
return 0;
}
else
{
qDebug("Open");
qDebug() << hdriver;
return 1;
}
That I want now is create a virtual serial port over the driver that I created.
Is possible in c++?
What I have tried:
I create the TCP Client and I create the driver