I want to setup virtual serial port emulator in Linux. I want the ports to be permanent, so that I can use them every time I restart. I tried using socat for that purpose as in this way,

socat -d -d pty,raw,echo=0 pty,raw,echo=0

But I often get port busy issues during the usage of these VSPs (Virtual Serial Ports) in my test programs. Also, I find it hard to create permanent/persistent VSPs. I now want to try out tty0tty for my purposes. But, there are rarely any documentation and how to use guide for that. Anyone can enlighten me on this? Please do comment, if there are any solution for socat as well.

up vote 11 down vote accepted

Installation:

  1. Download the tty0tty package from one of these sources:

  2. Extract it

    • tar xf tty0tty-1.2.tgz
  3. Build the kernel module from provided source
    • cd tty0tty-1.2/module
    • make
  4. Copy the new kernel module into the kernel modules directory
    • sudo cp tty0tty.ko /lib/modules/$(uname -r)/kernel/drivers/misc/
  5. Load the module
    • sudo depmod
    • sudo modprobe tty0tty
    • You should see new serial ports in /dev/ (ls /dev/tnt*)
  6. Give appropriate permissions to the new serial ports
    • sudo chmod 666 /dev/tnt*

You can now access the serial ports as /dev/tnt0 (1,2,3,4 etc) Note that the consecutive ports are interconnected. For example, /dev/tnt0 and /dev/tnt1 are connected as if using a direct cable.

Persisting across boot:

edit the file /etc/modules (Debian) or /etc/modules.conf

nano /etc/modules

and add the following line:

tty0tty

Note that this method will not make the module persist over kernel updates so if you ever update your kernel, make sure you build tty0tty again repeat the process.

  • 1
    Thanks mate, that worked pretty fine. Wasn't being able to find this anywhere else. – yuva Feb 23 '15 at 6:26
  • 1
    :) glad I could help! – Ruraj Feb 23 '15 at 6:27

protected by Community Jan 25 '17 at 9:39

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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