Bug: Can't run on Termux

未关闭 适合新手
#969 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@sqbi-q 已经在做这个了。

开始于 2026年8月10日。

  • #970 来自 @sqbi-q —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python
领域
cli

调研方向

首先阅读 meshtastic/util.py,其中导入了 serial.tools.list_ports,并通过 meshtastic/__main__.py 追踪 CLI 入口点。在 Termux 或类似环境中复现不受支持的平台导入问题,然后调整导入处理方式,使库仍可使用且不会出现枚举异常。验证在 Termux 上导入 Meshtastic 和运行 CLI 时不再崩溃,并添加或运行与特定平台的串口行为相关的测试。

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

描述

Importing serial.tools.list_ports causes an exception when the platform is unsupported. This stops both CLI and import of Meshtastic as a library. One of those unsupported platforms is Termux (detected as posix). Termux should be able to run Meshtastic as the documentation provides install instructions for this platform, though.

~ $ meshtastic
don't know how to enumerate ttys on this system.
! I you know how the serial ports are named send this information to
! the author of this module:

sys.platform = 'android'
os.name = 'posix'
pySerial version = 3.5

also add the naming scheme of the serial ports and with a bit luck you can get
this module running...
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/meshtastic", line 3, in <module>
    from meshtastic.__main__ import main
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/meshtastic/__init__.py", line 88, in <module>
    from meshtastic.node import Node
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/meshtastic/node.py", line 11, in <module>
    from meshtastic.util import (
    ...<10 lines>...
    )
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/meshtastic/util.py", line 22, in <module>
    import serial.tools.list_ports # type: ignore[import-untyped]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/serial/tools/list_ports.py", line 31, in <module>
    from serial.tools.list_ports_posix import comports
  File "/data/data/com.termux/files/usr/lib/python3.14/site-packages/serial/tools/list_ports_posix.py", line 114, in <module>
    raise ImportError("Sorry: no implementation for your platform ('{}') available".format(os.name))
ImportError: Sorry: no implementation for your platform ('posix') available

My suggested fix is to wrap import between try-except block:

import serial
try:
    import serial.tools.list_ports
except ImportError as e:
    print("Error: ", e)
    print("Error: Cannot list ports on this platform")
    print("Warning: Skipping import serial.tools.list_ports")

in meshtastic/util.py.

主要语言
Python
星标
855
派生
355
平均合并
3 天 3 小时
30 天内合并 PR
12

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

meshtastic/python 的其他 Issue

查看 meshtastic/python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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