Skip to content

[components][serial] fix serial v2 rx indicate setup#11539

Open
Old-Ding wants to merge 1 commit into
RT-Thread:masterfrom
Old-Ding:codex/fix-serial-v2-rx-indicate
Open

[components][serial] fix serial v2 rx indicate setup#11539
Old-Ding wants to merge 1 commit into
RT-Thread:masterfrom
Old-Ding:codex/fix-serial-v2-rx-indicate

Conversation

@Old-Ding

@Old-Ding Old-Ding commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move the POSIX serial v2 rx indication callback setup until after the close/open sequence in serial_fops_open().
  • Keep rt_serial_close() cleanup behavior unchanged.
  • Avoid leaving serial_fops_rx_ind cleared by the internal rt_device_close() call, so poll/select waiters can be woken after opening the serial device through DFS.

Closes #11538

Validation

  • git diff --check
  • Rechecked open PRs for duplicate serial_fops_open / rx_indicate fixes.
  • Reviewed the call chain: serial_fops_open() -> rt_device_close() -> rt_serial_close() clears rx_indicate, then rt_device_open() returns.

Build not run locally: this Windows environment does not have scons or gcc in PATH.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:codex/fix-serial-v2-rx-indicate
  • 设置PR number为 \ Set the PR number to:11539
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 codex/fix-serial-v2-rx-indicate 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the codex/fix-serial-v2-rx-indicate branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

📌 Code Review Assignment

🏷️ Tag: components

Reviewers: @Maihuanyi

Changed Files (Click to expand)
  • components/drivers/serial/dev_serial_v2.c

🏷️ Tag: components_driver_serial_v2

Reviewers: @Ryan-CW-Code

Changed Files (Click to expand)
  • components/drivers/serial/dev_serial_v2.c

📊 Current Review Status (Last Updated: 2026-07-01 09:34 CST)


📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Old-Ding Old-Ding marked this pull request as ready for review July 1, 2026 01:34
@Ryan-CW-Code

Copy link
Copy Markdown
Contributor

对posix这方面了解甚少,大佬可以增加 components/drivers/serial/utest 跑一遍试试吗?

@Old-Ding

Old-Ding commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

我看了 components/drivers/serial/utest/v2 这组用例:它是 RT-Thread 目标侧测试,需要在 BSP 中启用 RT_UTEST_SERIAL_V2,按 README 在 MSH 里运行对应 utest_run ...;多数普通串口用例还要求测试串口 TX/RX 做回环,POSIX 用例需要启用 RT_UTEST_SERIAL_POSIX

这个 PR 的改动只在 serial_fops_open() 中把 rt_device_set_rx_indicate() 移到 rt_device_open() 成功之后,避免 open 失败时提前设置 rx callback。

我当前本地 Windows 环境没有可运行这组目标侧 utest 的工具链/运行环境:缺 sconsqemu-system-*arm-none-eabi-gcc/aarch64-none-elf-gcc/riscv64-unknown-elf-gcc,也没有可做 TX/RX 回环的串口硬件。所以这边没法给出真实的 serial utest 运行日志。

已核对当前 PR CI:format/license、static analysis、BSP static build、MemBrowse、现有 utest_auto_run 矩阵均没有失败;不过上游 .github/utest/configs 里目前没有 serial v2 专项配置,现有 utest 矩阵没有覆盖这组 serial 用例。

如果你们有推荐的 BSP/config 用来跑 serial v2 POSIX 用例,我可以按那个配置继续补验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] serial_fops_open 顺序错误导致 rx_indicate 被清空

2 participants