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

Why is the same code not running now?

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python
領域
embedded-iot

調査の方向性

まず、指定されたCanableハードウェア、slcanインターフェース、オペレーティングシステム、Pythonのバージョン、python-canのバージョンを使用して、提供されたスクリプトを再現します。can.interface.BusとAsyncBufferedReaderのエントリーポイントを調べ、不足しているトレースバックまたはログを収集します。再現可能な原因を特定して対応可能なレポートにまとめるか、問題が環境に起因するものでpython-canのバグではないことを記録できれば完了です。

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

説明

bug
Describe the bug

I used to be able to successfully obtain data using the following code, but now the data cannot be displayed
The hardware I am using is Canable.

Additional context

OS and version:Windows10/Ubuntu 24.04
Python version:Python3.10/Python3.12
python-can version:4.2.0/4.4.2
python-can interface/s (if applicable):slcan

Traceback and logs

The environment that was once able to run successfully:

cantools==39.3.0
mqtt==0.0.1
paho-mqtt==1.6.1
pyserial==3.5
python-can==4.2.0

this is my code example,It was once able to run successfully.

# This is a sample Python script.
import asyncio
import time
from typing import List

import can
from can.notifier import MessageRecipient
# import cantools
import serial.tools.list_ports

# import paho.mqtt.client as mqtt
# import json

# client = mqtt.Client()
# db = cantools.database.load_file('.\wuling.dbc')


def on_connect(client, userdata, flags, rc):
    print(f"Connected with result code {rc}")


async def main() -> None:
    port = None
    ports_list = list(serial.tools.list_ports.comports())
    if len(ports_list) <= 0:
        print("无串口设备,即将退出...")
        time.sleep(2)
        exit(0)
    else:
        print("可用的串口设备如下:")
        for comport in ports_list:
            print(comport.name + ",描述:" + str(comport.description) + ",设备ID:" + str(comport.vid) + ":" + str(
                comport.pid))

        for comport in ports_list:
            if comport.pid == 4478 and comport.vid == 5840:
                print("选择第一个CAN设备:" + comport.name + " " + str(comport.description))
                port = comport
                break

    if port is None:
        print("未发现CAN设备,即将退出...")
        time.sleep(2)
        exit(0)

    # client.on_connect = on_connect
    # client.username_pw_set(username="user", password="user")
    # client.connect("127.0.0.1", 1883, 60)
    """The main function that runs in the loop."""

    with can.interface.Bus(bustype='slcan', channel=str(port.name), bitrate=500000, ) as bus:
        reader = can.AsyncBufferedReader()
        listeners: List[MessageRecipient] = [
            reader,
        ]
        loop = asyncio.get_running_loop()
        notifier = can.Notifier(bus, listeners, loop=loop)
        while True:
            msg = await reader.get_message()
            try:
                print(msg)
            except Exception as ex:
                print(ex)
                pass
            pass


if __name__ == "__main__":
    asyncio.run(main())

主要言語
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 を短くまとめたダイジェスト。