Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

SeeedBus: Crash occsionally.

オープン
#2,024 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
networking

調査の方向性

can/interfaces/seeedstudio/seeedstudio.py の 279 行目付近から始めます。ここで _recv_internal はシリアルデバイスから読み取っています。高速な open ループと recv(0.0) を使って失敗を再現してください。既存の SeeedStudio インターフェーステストがあれば確認し、ノンブロッキング受信パスが空の読み取りを「メッセージなし」という期待される結果として処理し、TypeError を発生させないようにしてください。

索引モデルが issue の本文から書いたものです。

説明

bug
Describe the bug

python-can crashes rarely with the error:

    msg = self.bus.recv(0.0)
  File "/nix/store/0amvifzhc5sv3p1b29dzwxd53njs74z3-python3.13-python-can-4.6.1/lib/python3.13/site-packages/can/bus.py", line 121, in recv
    msg, already_filtered = self._recv_internal(timeout=time_left)
                            ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/nix/store/0amvifzhc5sv3p1b29dzwxd53njs74z3-python3.13-python-can-4.6.1/lib/python3.13/site-packages/can/interfaces/seeedstudio/seeedstudio.py", line 279, in _recv_internal
    end_packet = ord(self.ser.read())
TypeError: ord() expected a character, but string of length 0 found
To Reproduce

Use a while true loop to open the device quickly.
For my use-case, I needed to implement a flush_rx_buffer() function on user-level:
Please ignore my comments in the code, they may be outdated.

    def flush_rx_buffer(self):
        """Discarding the received buffer."""
        # As python-can does not implement any discarding of old messages, see:
        # https://github.com/hardbyte/python-can/issues/1721
        # The recv(0.0) is probably a non-blocking function, see:
        # https://python-can.readthedocs.io/en/3.3.2/interfaces/socketcan.html
        # That non-blocking function should return immediately.
        while True:
            msg = self.bus.recv(0.0)
            if msg is None:
                return

Expected behavior

Instead of a TypeError I expected to receive a None.

Additional context

OS and version: NixOS
Python version: 3.13
python-can version: 4.6.1
python-can interface/s (if applicable): seeedstudio

I'm using an asus nuc 15, so quite a fast CPU. I don't remember this error to appear on the slow raspberry pi pico.

Traceback and logs
def func():
    return "hello, world!"
主要言語
Python
スター
1.6k
フォーク
697
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hardbyte/python-can のほかの issue

hardbyte/python-can の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。