Bug 1642 - PTY (pseudo-tty) support under Linux
Summary: PTY (pseudo-tty) support under Linux
Status: CONFIRMED
Alias: None
Product: libserialport
Classification: Unclassified
Component: Portability (show other bugs)
Version: unreleased development snapshot
Hardware: All Linux
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-25 12:52 CET by alvieboy
Modified: 2020-11-25 15:00 CET (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?