简体   繁体   中英

virtual socat serial port and c# on ubuntu linux

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM