python-can 不断获取相同的消息(id)

发布于 2025-01-14 18:33:31 字数 479 浏览 1 评论 0原文

我更像是一名硬件工程师,目前正在尝试在工作中使用 Python。我想通过 Python 完成的任务是读取 DUT 的 CAN-FD 输出,并将其用于测量设置中的监控目的。但是,我认为我没有得到正确的结果。因为它显示相同的消息(id),甚至还有更多。根据我对其他示例的理解,这应该显示所有消息的流,因为没有过滤器。有没有人可以帮我解决这个问题或者有类似的经历?

import can

def _get_message(msg):
    return msg

bus = can.interface.Bus(bustype='vector',app_name ='app', channel=1, bitrate=500000)    
buffer = can.BufferedReader()
can.Notifier(bus,[_get_message,buffer])    
while True:
    msgs = bus.recv(None)
    print(msgs)

I'm more of a HW engineer who's currently trying to use Python at work. What I want to accomplish via Python is read the CAN-FD output from the DUT and use it for monitoring purposes in the measurement setup. But, I think I didn't get the correct result. Because it shows the same message(id) even there so much more. Based on my understanding from other examples, this should shows the stream of all the messages since there was no filters. Is there anyone who can help me solve this issue or have the similar experience?

import can

def _get_message(msg):
    return msg

bus = can.interface.Bus(bustype='vector',app_name ='app', channel=1, bitrate=500000)    
buffer = can.BufferedReader()
can.Notifier(bus,[_get_message,buffer])    
while True:
    msgs = bus.recv(None)
    print(msgs)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2025-01-21 18:33:31

你没有说你希望在公交车上看到什么,但我猜公交车上有很多不同的信息。

首先简化您的问题 - 设置一条总线,该总线上只有一条低速率的消息。您可能需要为此编写一些代码,或者您可能会获得一些可以发送带有计数器的定期消息的工具。首先确保您可以正确捕获该内容。然后以更快的速度添加第二条消息。

您可能会从这些练习中学到一些有用的东西,这意味着当您返回完整系统时,您会取得更大的成功,或者至少对调试内容有更多想法:)

You don't say what you expected to see on your bus, but I assume there are a lot of different messages on it.

Simplify your problem to start with - set up a bus which has only a single message on it at a low rate. You might have to write some code for that, or you might get some tools which can send periodic messages with counters in for example. Make sure you can capture that correctly first. Then add a second message at a faster rate.

You will proably learn a selection of useful things from these exercises which mean that when you go back to your full-system you have more success, or at least have more ideas on what to debug :)

§普罗旺斯的薰衣草 2025-01-21 18:33:31

首先,感谢您的回答和评论。根本原因是接口的硬件配置不正确。我认为如果硬件配置一开始就错误,那么根本不会有任何输出。但事实证明并非如此。正确配置后,我可以看到我期望的输出流。

First of all, thanks for the answers and comments. the root cause was the incorrect HW configuration for the interface. I thought if HW configuration is wrong in the first place, there will be no output at all. But it turned out it is not. After proper configuration, I could see the output stream I expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文