Bug 1642

Summary: PTY (pseudo-tty) support under Linux
Product: libserialport Reporter: alvieboy
Component: PortabilityAssignee: Nobody <nobody>
Status: CONFIRMED ---    
Severity: normal CC: martin-sigrokbugs
Priority: Normal    
Version: unreleased development snapshot   
Target Milestone: ---   
Hardware: All   
OS: Linux   

Description alvieboy 2020-11-25 12:52:59 CET
Hi,

Currently libserialport fails to use PTYs under Linux due to several reasons:
* PTYs do not have entries under /sys/class/tty for each created pts (only /dev/pts/X entries)
* Some TTY operations are not supported by PTYs (TIOCMGET, etc)

Most terminal/serial applications are able to handle PTYs gracefully (minicom, gtkterm), but not sigrok.

PTY support is useful for using hardware emulators and/or to use bridging software when there is no low-level access to the communication channel (only via an external API).

I managed to implement a few changes that do allow PTY support, mostly by modifying get_port_details() and get_config()/set_config(). It uses an extra variable in the sp_port definition, but could as well use a separate transport enumerator entry (alternatively it can ignore TIOCxx return values as other serial applications do)

If there is interest I can provide a patch with minimal support for PTYs (which I believe does not break any other functionality).
Comment 1 Martin Ling 2020-11-25 15:00:38 CET
Hi Alvie,

There's actually already a pull request for PTY support here:

https://github.com/sigrokproject/libserialport/pull/4

I had some issues with it and I think it needs a bit more work, but could you have a look at it and see if it would cover your needs?