python / python/cpython

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

Open
#127,335 3 comments 3 reactions 0 assignees View on GitHub

@rruuaanng is already working on this.

Since Nov 27, 2024.

extension-modules type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

This issue suggests adding new termios constants.

TIOCM_LOOP
TIOCM_OUT1
TIOCM_OUT2

example:

import array
import fcntl
import termios

f = open('/dev/ttyS0', 'r')
buf = array.array('h', [0])

# return a mask
fcntl.ioctl(f, termios.TIOCMGET, buf)

# some mask operation
# check if the target device has this flag activated
if buf[0] & TIOCM_OUT1: ...
if /* more compare */: ...

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
  • gh-127336

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the issue's termios example and the referenced Linux termios header, then inspect linked PR gh-127336 for the work already underway. Done means the three constants are available through Python's termios interface for the described ioctl mask checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python
Domain
operating-systems
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.