简体   繁体   中英

Tell Slave Port Name of Pseudo Terminal

I am coding a linux process that will read input from a serial stream (a GPS module) and perform some actions based on this input.

When developing the program I intend to use a Pseudo Terminal (BSD API) so I can send 'dummy' GPS ascii data to my process and test it. So my master will be my 'GPS Device' and my slave will be my actual linux process that handles the GPS data.

I don't want to fork my process but have 2 different programs (the master and the slave). This way I can separate the code nicely. How can I tell me slave what port name to connect to? Ie; /dev/ttp0 or etc?

Maybe I am using Pseudo Terminal's wrong and should fork them?

ways to pass info (the port number) between processes.

1) use msgsnd()
2) use a pipe()
3) use a mmap area

there are several other methods. I prefer the msgsnd

4) Link to it with a soft link with a fixed name.

For example: /tmp/gpsdevice -> /dev/pts/2 . This is trivial to do in the master with symlink.

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