Creating Virtual Serial Ports in Ubuntu

  1. Install
    sudo apt-get install socat
    
  2. Create two virtual serial ports
    $ socat -d -d pty,raw,echo=0 pty,raw,echo=0
    2012/05/31 12:41:56 socat[28162] N PTY is /dev/pts/6
    2012/05/31 12:41:56 socat[28162] N PTY is /dev/pts/7
    2012/05/31 12:41:56 socat[28162] N starting data transfer loop with FDs [3,3] and [5,5]
    
To Test, open two terminals
  • Terminal 1:
    cat < /dev/pts/6
    
  • Terminal 2
    echo "hello" > /dev/pts/7
    
You should see hello echo-ed on terminal 1

0 comments: