python / python/cpython

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

未关闭
#127,335 3 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

@rruuaanng 已经在做这个了。

开始于 2024年11月27日。

  • #127336 来自 @rruuaanng —— 未关闭
extension-modules type-feature
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先阅读 issue 中的 termios 示例和所引用的 Linux termios 头文件,然后检查链接的 PR gh-127336,了解已经在进行的工作。当这三个常量可以通过 Python 的 termios 接口用于所描述的 ioctl 掩码检查时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
linux, python
领域
operating-systems
Issue 类型
功能
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。