http://www.xappsoftware.com/wordpress/2013/10/07/using-virtual-serial-ports-on-linux-ubuntu/?goback=%2Egde_65688_member_5792872722853814274#%21

A virtual serial port is a redirector without network software support which is usually used to create a pair of back-to-back virtual COM ports on the same computer. Two legacy applications can then communicate using virtual serial ports instead of conventional inter-process communication mechanisms such as named pipes.

This type of software is capable of emulating all serial port functionality, including Baud rate, data bits, parity bits, stop bits, etc. Additionally, it allows the data flow to be controlled, emulating all signal lines (DTR/DSR/CTS/RTS/DCD/RI) and customizing pinout.

Often I write software for embedded devices, and they have to exchange data with a PC. Since the devices often, if we don't want to say "always", aren't available during the development phase I have to simulate the connection in other ways. When I have to use UARTs to communicate, I use a tool which generates 2 virtual ports and then joins them back to back.

The software I use on Linux is socat, it is a very complex software and it can do a lot of other things, maybe in another article I'll show other functionalities of socat.

Socat Man Page: "Socat  is  a  command  line based utility that establishes two bidirectional byte streams and transfers data between them. Because the streams can be constructed from a large set of  different  types  of  data  sinks  and  sources (see address types), and because lots of address options may be applied to the streams, socat can be used for many different purposes."

However let's try socat:

Installation on Ubuntu

To install socat on Ubuntu (I'm using 12.04) just run the following command:

# sudo apt-get install socat

Setting up two serial lines

now on a terminal window run socat

# socat -d -d PTY PTY:

The output should look like the following one:

2013/09/20 14:07:10 socat[6871] N PTY is /dev/pts/5
2013/09/20 14:07:10 socat[6871] N PTY is /dev/pts/6
2013/09/20 14:07:10 socat[6871] N starting data transfer loop with FDs [3,3] and [5,5]

Now you have two "serial" ports connected back to back

Testing the ports

open a new terminal and issue the following command

# sudo cat /dev/pts/5

open a new terminal and issue the following command

# sudo echo "Hello World" > /dev/pts/6

On the first terminal you should see the string "Hello World".

That's all, nothing more.

Using Virtual Serial Ports on Linux (Ubuntu)的更多相关文章

  1. Power OFF and ON USB device in linux (ubuntu)

    Power OFF and ON USB device in linux (ubuntu) http://loginroot.com/power-off-and-on-usb-device-in-li ...

  2. [转]Linux Ubuntu上架设FTP

    Linux Ubuntu上架设FTP http://www.blogjava.net/stonestyle/articles/369104.html 操作系统:ubuntu (GNU/Linux) 为 ...

  3. libserialport: cross-platform library for accessing serial ports

    /*********************************************************************************** * libserialport ...

  4. The Guideline of Setting Up Samba Server on linux(Ubuntu)

    The Guideline of Setting Up Samba Server on linux(Ubuntu) From terminate command window, install the ...

  5. golang 跨平台编译——go 在windows上编译Linux平台的程序(Cross Compilation from Windows to Linux/Ubuntu)

    Go Cross Compilation from Windows to Linux/Ubuntu I have GO 1.7 installed on my Windows 10. I create ...

  6. Arch Linux 安装博通 BCM4360 驱动(Arch Linux, Ubuntu, Debian, Fedora...)

    BCM4360 在2010年9月,博通完全开源的硬件驱动[1].该驱动程序 brcm80211已被列入到自2.6.37之后的内核中.随着2.6.39发布,这些驱动程序已被重新命名为 brcmsmac和 ...

  7. 在Linux(Ubuntu)下搭建ASP.NET Core环境并运行 继续跨平台

    最新教程:http://www.cnblogs.com/linezero/p/aspnetcoreubuntu.html 无需安装mono,在Linux(Ubuntu)下搭建ASP.NET Core环 ...

  8. Linux ubuntu 10.10安装OpenCv

    在windows系统下已经成功做出了一个打开摄像头并检测人脸的小程序了. 开始转战linux,因为最终目标是将程序移植到嵌入式开发板上面. 但是,问题接踵而至~ 首先linux上面要安装OpenCv, ...

  9. windows远程连接Linux(Ubuntu)的方法

    需要做的工作: 1.在Linux(Ubuntu)端安装.设置好SSH 2.下载putty,并通过putty的SSH连接登录Linux 一 .如何在Linux(Ubuntu)端安装.设置好SSH,获取I ...

随机推荐

  1. SQLite Database Browser 2.0使用方法

    在网上找一个SQLITE查看器 这个查看器叫做:www.jb51.net/database/118822.html 这个查看器可以新建SQLITE文件数据库,可以建立表索引,写SQL语句,编辑表数据 ...

  2. Java-将字符串转为数字

    package com.tj; public class MyClass implements Cloneable { public static void main(String[] args) { ...

  3. 对比使用Charles和Fiddler两个工具及利用Charles抓取https数据(App)

    对比使用Charles和Fiddler两个工具及利用Charles抓取https数据(App) 实验目的:对比使用Charles和Fiddler两个工具 实验对象:车易通App,易销通App 实验结果 ...

  4. windows和ubuntu14.04双系统设置默认启动项

    首先开机或者重启,在启动项选择菜单处记住win7对应的序号,从上至下的序号从0开始计数,我的win7系统选项处于第5个,那么序号就应该是4,记住后,打开ubuntu系统. 2 按下Ctrl+alt+T ...

  5. LCA+主席树 (求树上路径点权第k大)

      SPOJ 10628. Count on a tree (树上第k大,LCA+主席树) 10628. Count on a tree Problem code: COT You are given ...

  6. Android单个按钮自定义Dialog

    代码改变世界 Android单个按钮自定义Dialog dialog_layout.xml <?xml version="1.0" encoding="utf-8& ...

  7. BZOJ 1875 [SDOI2009]HH去散步 ——动态规划 矩阵乘法

    发现t非常大,所以大概就是快速幂一类的问题了, 然后根据k^3logn算了算,发现k大约是边数的时候复杂度比较合适. 发现比较麻烦的就是前驱的记录,所以直接把边看做点,不能走反向边,但是可以走重边,然 ...

  8. BestCoder Round #32

    问题描述 目前,我们用PM2.5的含量来描述空气质量的好坏.一个城市的PM2.5含量越低,它的空气质量就越好.所以我们经常按照PM2.5的含量从小到大对城市排序.一些时候某个城市的排名可能上升,但是他 ...

  9. PHP文件锁定机制

    <?php //如果多用户访问一个文件,采用文件锁定机制 /* flock()文件锁定 */ header("Content-Type:text/html;charset=utf8&q ...

  10. msp430项目编程37

    msp430中项目---usb接口编程37 1.电路工作原理 2.代码(显示部分) 3.代码(功能实现) 4.项目总结