Socat virtual serial port not recognized

2019-04-11 22:39发布

I'm using socat to create a couple virtual serial ports. One I connect to with a simple C program (using termios), and the other I'd like to connect to using a program called Ardupilot Mega Planner (for RC stuff). However, the Planner does not recognize the virtual port (listed under /dev/pts), only the tty devices and /dev/serial devices. Do I need to do some sort of special mount for this to work? Or is there a workaround I could try? I tried "linking" an existing serial port (ttyS0, for example), but I'm getting an "inappropriate ioctl" error if I try anything of the kind (virtual port to real port, real port to real port). Any ideas?

edit: After viewing the source code for the program (Mission Planner), it seems that it only "recognizes" (or adds the ports of) all the /dev/ttyS* devices, the /dev/serial/by-id/* devices, /dev/USB0, and /dev/ACM0. So either I need to edit the source code or find a way to "validate" a ttyS* port. It still appears that the Mission Planner just won't connect to any ttyS* devices other than S1 or S0. Any ideas? I have a feeling it's because they're not configured correctly, somehow.

edit 2: I finally got a hold of the ArdupilotMega Planner source code and changed it so that it includes devices from /dev/pts/. However, I'm still getting the same problem. The Planner gets some sort of problem when it opens the port. Is there some setting that needs to be checked/changed right off the bat for a program to be able to connect to it? Going to research and try to understand serial port communication more thoroughly...

3条回答
不美不萌又怎样
2楼-- · 2019-04-11 23:14

Have you tried linking to higher ttyS's, for example ttyS10 or higher. These are not usually assigned to anything. EDIT: Also what command are you using to create the serial ports

查看更多
等我变得足够好
3楼-- · 2019-04-11 23:16

Right, just found I couldn't comment on my answer since I didn't have an account. Anyway, try this command:

socat PTY,link=/dev/ttyS10 PTY,link=/dev/ttyS11

and link your programs to ttyS10 and ttyS11.

查看更多
叛逆
4楼-- · 2019-04-11 23:19

I have had the same problem and solved it with sending the serial stuff over tcp:

socat tcp-l:5760 /dev/YOURPORT,raw,echo=0,bHEREBAUDRATE

Then in Misson planner choose "TCP", Server: 127.0.0.1, Port: 5760

I can successfully connect in this way to an emulated serial port.

查看更多
登录 后发表回答