Why is the same code not running now?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- embedded-iot
Direzione di ricerca
Inizia riproducendo lo script fornito con l’hardware Canable indicato, l’interfaccia slcan, il sistema operativo, la versione di Python e la versione di python-can. Esamina i punti di ingresso can.interface.Bus e AsyncBufferedReader e raccogli il traceback o i log mancanti. Il lavoro è completato quando viene identificata una causa riproducibile con un report attuabile, oppure viene documentato che il problema è ambientale e non un bug di python-can.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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())
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 697
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hardbyte/python-can
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
hardbyte/python-can#2103 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
hardbyte/python-can#2077 · 1 commento · 1 reazione ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
hardbyte/python-can#1922 · 1 reazione ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
hardbyte/python-can#2102 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
hardbyte/python-can#2092 ·
Tutte le issue di hardbyte/python-can
Issue simili
-
area: harness bug status: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Human-Agent-Society/reef#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
learningequality/kolibri#15351 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Name consistency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eellak/triplestore#65 · 1 commento ·