virtual socat serial port and c# on ubuntu linux

倖福魔咒の 提交于 2019-12-10 17:52:02

问题


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

getting this output:

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();

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

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?


回答1:


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?



来源:https://stackoverflow.com/questions/8054652/virtual-socat-serial-port-and-c-sharp-on-ubuntu-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!