Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 427
gsscoder Avatar asked Nov 08 '11 17:11

gsscoder


1 Answers

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?

like image 71
Ignacio Soler Garcia Avatar answered Sep 17 '22 12:09

Ignacio Soler Garcia