ubuntu linux上的虚拟socat串行端口和c# [英] virtual socat serial port and c# on ubuntu linux

查看:164
本文介绍了ubuntu linux上的虚拟socat串行端口和c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于测试目的,我正在尝试编写一个连接到用socat创建的虚拟串行端口的简单程序.

for testing purpose I'm trying to write a simple program that connect to a virtual serial port created with socat.

我使用以下命令创建串行端口:

I create the serial port with this command:

socat -d -d PTY,b9600 PTY,link=ttyVS1,b9600

获取此输出:

2011/11/08 18:26:31 socat[32708] N PTY is /dev/pts/1
2011/11/08 18:26:31 socat[32708] N PTY is /dev/pts/2
2011/11/08 18:26:31 socat[32708] N starting data transfer loop with FDs [3,3] and [5,5]

当我尝试以这种方式连接时:

When I try to connect in this way:

System.IO.Ports.SerialPort _port;
_port = new SerialPort("/dev/pts/1", 9600);
_port.Open();

我收到一个文件名未知" System.IO.IOException.

I get a "filename unknown" System.IO.IOException.

我是否想设置DataBits,StopBits或其他参数?如何找到socat设定的属性?还是这段代码有什么问题?

Am I missing to set DataBits, StopBits or other parameters? How can I discover the properties sett by socat? Or what is wrong with this code?

推荐答案

这肯定是设备名称的问题.您可以在/dev中检查/dev/pts/1是否存在吗?也许它有另一个名称,例如/dev/pts1?

What is wrong here is for sure the name of the device. Can you check at /dev that /dev/pts/1 exists? Maybe it has another name like /dev/pts1?

这篇关于ubuntu linux上的虚拟socat串行端口和c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆