使用 python-can 和 paho-mqtt 在 Python 中构建车辆 HMI 模拟器的多线程/异步架构

发布于 2025-01-16 17:06:54 字数 301 浏览 6 评论 0原文

我正在开发一个应用程序来模拟车辆 HMI,其主要功能是与 ECU 模块交互,ECU 模块主要发送和接收原始 CAN 数据。在应用程序中,我使用 "python-can" 库创建一个 CAN 总线实例,在该实例上发送和接收 CAN 数据。另一个流程是解析接收到的原始 CAN 数据并将其发布到MQTT 代理。应用程序还必须从 MQTT 代理订阅某些主题。

我尝试为所有不同的模块创建一个新线程,并在 asyncio 库的帮助下编写 CAN 模块。如果有一个好的、理想的架构来解决上述问题,那将会有很大的帮助。

I'm developing an application to simulate the vehicle HMI, which has the main functionality of interacting with the ECU module which basically sends and receives the raw CAN data. In the application, I'm using the "python-can" library to create a CAN bus instance on which it sends and receives the CAN data. The other flow is to parse the received raw CAN data and publish it to the MQTT broker. The application has to also subscribe to certain topics from the MQTT broker.

I tried creating a new thread for all different modules and wrote the CAN module with the help of asyncio library. It would be a great help if there is a good and ideal architecture for the above problem.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文