Virtual serial port and C # on ubuntu linux

for testing purposes I am trying to write a simple program that connects to a virtual serial port created using socat.

I create a serial port using this command:

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

getting this result:

 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 "file name unknown" System.IO.IOException .

Am I missing to set DataBits, StopBits or other parameters? How can I find properties offered by socat? Or what's wrong with this code?

+4
source share
1 answer

What’s wrong, true, is the name of the device. Can you check on / dev that / dev / pts / 1 exists? Perhaps it has a different name, for example / dev / pts1?

+1
source

Source: https://habr.com/ru/post/1380245/


All Articles