Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Use pseudo terminals with qt-serial on OSX



  • Hi all!

    I'm trying to use pseudo terminals in a QT application on OSX, but run into an exception when starting the program.

    I am using eg /dev/ptyp0 and /dev/ttyp0. When using those with screen I can open both and see the input of the one echoed in the other.

    I am using the QT async serial port example to connect to /dev/ttyp0, but always get the following error:

    QSocketNotifier: Invalid socket 7 with type Read, disabling...
    

    What am I doing wrong, and does someone have a working example?

    Thanks in advance!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What are these two devices ?


  • Lifetime Qt Champion

    @kuzulis Any idea?



  • I have not ideas. I just can say that:

    1. Pseudo terminals are not a serial ports.
    2. Try to use socat.
    3. Any errors related to QSocketNotifier - is not a QSerialPort issues (you can address it to QtCore team). :)


  • @kuzulis said in Use pseudo terminals with qt-serial on OSX:

    I have not ideas. I just can say that:

    1. Pseudo terminals are not a serial ports.

    I know, but they do behave as serial ports. From the first link: "Thus two programs talk to each other via this method and one program on ttyp3 thinks it's talking to a serial port.".

    1. Try to use socat.

    Can I use socat to mock a serial device? What I want to do is to mock a serial device, so that it responds to requests from my actual program as if it was an actual device (with a somewhat limited/fixed response).

    As long as my actual program connects to a serial port, I am fine with any other solution!

    1. Any errors related to QSocketNotifier - is not a QSerialPort issues (you can address it to QtCore team). :)

    Is this the right sub-forum for it, or should I post my question in another one as well?

    Thanks in advance!



  • @kuzulis I've had a look at socat, and that looks to work! I now have a small example where I can write/read from a serial port. On the other end I am using screen, and my program picks up data as expected!

    Thanks for the pointer to socat! Didn't know about it..


Log in to reply