I have a program that communicates through a serial protocol uart. I would like to test this protocol using simple terminal emulator running on the same computer.

This program opens /dev/tty. I would like to open terminal emulator (like screen, kermit or something else) to communicate with the program using the same tty.

A representation to my idea above is as follows:

<terminal> --> /dev/tty <--- <program to test>

Practically speaking, my idea was to open /dev/ptmx with a terminal emulator, then open the corresponding /dev/pts/x with my program to do it, but it seems to be hard to achieve.

More clarification about what I tried:

When I open terminal on /dev/ptmx using this command :

screen /dev/ptmx 115200

It creates a file called 7 in the following path /dev/pts/7. I can't open this file using the command:

$ screen /dev/pts/7 115200
[screen is terminating]

Or even the command cat can not open it :

$ cat /dev/pts/7
cat: /dev/pts/7: Input/output error

Also, I tried the command stty -F which could not open it as well!:

$ stty -F /dev/pts/7
stty: /dev/pts/7: Input/output error

How can I get two screens to communicate with each other using pty?

closed as unclear what you're asking by Thomas Dickey, JdeBP, msp9011, Thomas, G-Man Sep 4 '18 at 4:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • screen's intended use will create a new slave pty each time you attach to a session. – Thomas Dickey Sep 3 '18 at 10:33
  • but how can I open the new slave pty with another screen ? – FabienM Sep 3 '18 at 10:39
  • screen won't do it, because it doesn't behave like a pty master :-) – Thomas Dickey Sep 3 '18 at 10:46
  • Is there a tty terminal that can act as a pty master ? – FabienM Sep 3 '18 at 11:54
  • 1
    Pretty much all of them can and do, because using pseudo terminals and handling their master sides is part and parcel of being a terminal emulator (except in the cases of those built into kernels) or mux. You seem confused about what you actually want. Your actual goal is certainly not stated in the question, and people are having difficulty with your question because your chosen means of achieving your goal is nonsensical. Put down the chocolate-covered banana, step away from the currency systems, and explain the goal. – JdeBP Sep 3 '18 at 12:14

I managed to do the communication using the project tty0tty:

Once a kernel module is loaded into Linux /dev/tntx, the tty devices will appear. We just had managed a connection of one program to /dev/tntn, and the screen/kermit/.. on /dev/tnt(n+1) and that worked.

Not the answer you're looking for? Browse other questions tagged or ask your own question.