python / cpython

The Python programming language
https://www.python.org
Other
63.73k stars 30.53k forks source link

Add `TIOCM_OUT1`, `TIOCM_OUT2`, and `TIOCM_LOOP` constants to `termios` #127335

Open rruuaanng opened 2 days ago

rruuaanng commented 2 days ago

Feature or enhancement

Proposal:

This issue suggests adding new termios constants.

TIOCM_LOOP

example:

int fd = /* /dev/ttyS0 */
int status = /* modulator status */
status |= TIOCM_LOOP;

ioctl(fd, TIOCMSET, &status);
/* subsequent 'write()' will send data to 'fd' instead of the remote terminal device */

It's used to enable the serial port loopback mode, that is, the local tx will send messages to the local rx instead of the external device

TIOCM_OUT1
TIOCM_OUT2

It's suitable for the physical characteristics of the terminal equipment, such as interrupt and chip select output

for example, a library like this uses.

https://github.com/makerbot/pyserial

ref: https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/termios.h

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

erlend-aasland commented 17 hours ago

This issue suggests adding new termios constants.

Which constants? What do they do? Why are you proposing to add these flags? Always explain proposed changes in detail.