Search code examples
linuxqtqtserialport

Qt and virtual serial ports


I've followed this in order to create a pair of serial ports. It works fine.

Now I'm developing a Qt app (using QtSerialPort) to send data through the serial port and what I really want is such a virtual serial port link. But it appears that QSerialPortInfo::availablePorts() cannot find the /dev/pts/... ports.

Which approach should I try in order to make such a serial port link on linux?


Solution

  • Because the /dev/pts are not a serial ports, and the SOCAT creates a symlinks to the /dev/pts devices. So, all correct.

    But, using SOCAT it is not a good idea, because it is unstable (after re-opening and so on, in my practice). It is better to use tty0tty project instead (but, unfortunately, the QSerialPort::availablePorts() doesn't enumerate it too). But it is not a problem, because the tty0tty's serial ports can be easy fixed for QSerialPort (required a small patch).

    So, currently there are no approach to enumerate this easy. Maybe on Qt 5.6 the tty0tty will be added for QSerialPort enumeration.

    As workaround, you can use QDir on the /dev directory to enumerate all symlinks (of course, if you create this symlinks in /dev directory).