Using Virtual Serial Ports on Linux (Ubuntu)
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)的更多相关文章
- 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 ...
- [转]Linux Ubuntu上架设FTP
Linux Ubuntu上架设FTP http://www.blogjava.net/stonestyle/articles/369104.html 操作系统:ubuntu (GNU/Linux) 为 ...
- libserialport: cross-platform library for accessing serial ports
/*********************************************************************************** * libserialport ...
- 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 ...
- 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 ...
- Arch Linux 安装博通 BCM4360 驱动(Arch Linux, Ubuntu, Debian, Fedora...)
BCM4360 在2010年9月,博通完全开源的硬件驱动[1].该驱动程序 brcm80211已被列入到自2.6.37之后的内核中.随着2.6.39发布,这些驱动程序已被重新命名为 brcmsmac和 ...
- 在Linux(Ubuntu)下搭建ASP.NET Core环境并运行 继续跨平台
最新教程:http://www.cnblogs.com/linezero/p/aspnetcoreubuntu.html 无需安装mono,在Linux(Ubuntu)下搭建ASP.NET Core环 ...
- Linux ubuntu 10.10安装OpenCv
在windows系统下已经成功做出了一个打开摄像头并检测人脸的小程序了. 开始转战linux,因为最终目标是将程序移植到嵌入式开发板上面. 但是,问题接踵而至~ 首先linux上面要安装OpenCv, ...
- windows远程连接Linux(Ubuntu)的方法
需要做的工作: 1.在Linux(Ubuntu)端安装.设置好SSH 2.下载putty,并通过putty的SSH连接登录Linux 一 .如何在Linux(Ubuntu)端安装.设置好SSH,获取I ...
随机推荐
- bs4--基本使用
CSS 选择器:BeautifulSoup4 和 lxml 一样,Beautiful Soup 也是一个HTML/XML的解析器,主要的功能也是如何解析和提取 HTML/XML 数据. lxml 只会 ...
- nw335 debian sid x86-64 -- 2 驱动的方式
1 linux内核自带 2 realtek 提供的官方驱动 3 使用xp的驱动 4 第三方驱动(现在成功的,最好的方式)
- Java技术——Java中的内存泄漏
. OOM的常见类型 按照JVM规范,JAVA虚拟机在运行时会管理以下的内存区域: 程序计数器:当前线程执行的字节码的行号指示器,线程私有. JAVA虚拟机栈:Java方法执行的内存模型,每个Java ...
- HDU 2829 斜率优化DP Lawrence
题意:n个数之间放m个障碍,分隔成m+1段.对于每段两两数相乘再求和,然后把这m+1个值加起来,让这个值最小. 设: d(i, j)表示前i个数之间放j个炸弹能得到的最小值 sum(i)为前缀和,co ...
- hibernate 学习
hibernate.cg.xml 可以通过myeclipse自动生成,添加数据库信息: <?xml version='1.0' encoding='UTF-8'?> <!DOCTYP ...
- Oracle中Restore和Recovery的区别
一.参考解释一 在Oracle的备份与恢复的知识点中,经常会出现Restore 和 Recovery两个词. 由于这两个词在字典中的解释很接近,困扰了我很久.直到我在Oracle的官方文档中看到了以下 ...
- iOS转场动画初探
一般我们就用两种转场push和present present /** 1.设置代理 - (instancetype)init { self = [super init]; if (self) { se ...
- [UOJ#127][BZOJ4195][NOI2015]程序自动分析
[UOJ#127][BZOJ4195][NOI2015]程序自动分析 试题描述 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2, ...
- POJ 2187 Beauty Contest ——计算几何
貌似直接求出凸包之后$O(n^2)$暴力就可以了? #include <cstdio> #include <cstring> #include <string> # ...
- CentOS7下安装Docker-Compose No module named 'requests.packages.urllib3'
在使用Docker的时候,有一个工具叫做 docker-compose,安装它的前提是要安装pip工具. 1.首先检查Linux有没有安装Python-pip包,直接执行 yum install p ...