怎么添加新的CAN卡
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,这篇文章主要介绍怎么添加新的CAN卡,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!简介控制器区域网络(CAN)是在许多微控制器和设备中密集使用的网络,用于在没有主计算机帮助的情
千家信息网最后更新 2025年12月03日怎么添加新的CAN卡
这篇文章主要介绍怎么添加新的CAN卡,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
简介
控制器区域网络(CAN)是在许多微控制器和设备中密集使用的网络,用于在没有主计算机帮助的情况下在设备之间传输数据。
Apollo中使用的默认CAN卡是 ESD CAN-PCIe卡。您可以使用以下步骤添加新的CAN卡:
添加新的CAN卡
添加新的CAN卡需要完成以下几个步骤:
实现新CAN卡的
CanClient类。在
CanClientFactory中注册新的CAN卡。更新配置文件。
以下步骤展示了如何添加新的CAN卡 - 示例添加CAN卡到您的工程。
步骤1
实现新CAN卡的CanClient类,下面的代码展示了如何实现 CANClient 类:
#include#include #include "hermes_can/include/bcan.h"#include "modules/canbus/can_client/can_client.h"#include "modules/canbus/common/canbus_consts.h"#include "modules/common/proto/error_code.pb.h"/** * @namespace apollo::canbus::can * @brief apollo::canbus::can */namespace apollo {namespace canbus {namespace can {/** * @class ExampleCanClient * @brief The class which defines a Example CAN client which inherits CanClient. */class ExampleCanClient : public CanClient { public: /** * @brief Initialize the Example CAN client by specified CAN card parameters. * @param parameter CAN card parameters to initialize the CAN client. * @return If the initialization is successful. */ bool Init(const CANCardParameter& parameter) override; /** * @brief Destructor */ virtual ~ExampleCanClient() = default; /** * @brief Start the Example CAN client. * @return The status of the start action which is defined by * apollo::common::ErrorCode. */ apollo::common::ErrorCode Start() override; /** * @brief Stop the Example CAN client. */ void Stop() override; /** * @brief Send messages * @param frames The messages to send. * @param frame_num The amount of messages to send. * @return The status of the sending action which is defined by * apollo::common::ErrorCode. */ apollo::common::ErrorCode Send(const std::vector & frames, int32_t* const frame_num) override; /** * @brief Receive messages * @param frames The messages to receive. * @param frame_num The amount of messages to receive. * @return The status of the receiving action which is defined by * apollo::common::ErrorCode. */ apollo::common::ErrorCode Receive(std::vector * const frames, int32_t* const frame_num) override; /** * @brief Get the error string. * @param status The status to get the error string. */ std::string GetErrorString(const int32_t status) override; private: ... ...};} // namespace can} // namespace canbus} // namespace apollo
步骤2
在CanClientFactory中注册新CAN卡, 在 CanClientFactory中添加如下代码:
void CanClientFactory::RegisterCanClients() { Register(CANCardParameter::ESD_CAN, []() -> CanClient* { return new can::EsdCanClient(); }); // register the new CAN card here. Register(CANCardParameter::EXAMPLE_CAN, []() -> CanClient* { return new can::ExampleCanClient(); }); }步骤3
接下来,需要更新配置文件 在/modules/canbus/proto/can_card_parameter.proto添加 EXAMPLE_CAN;
message CANCardParameter { enum CANCardBrand { FAKE_CAN = 0; ESD_CAN = 1; EXAMPLE_CAN = 2; // add new CAN card here. } ... ... }Update /modules/canbus/conf/canbus_conf.pb.txt
can_card_parameter { brand:EXAMPLE_CAN type: PCI_CARD // suppose the new can card is PCI_CARD channel_id: CHANNEL_ID_ZERO // suppose the new can card has CHANNEL_ID_ZERO}... ...以上是"怎么添加新的CAN卡"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
步骤
代码
内容
文件
篇文章
网络
设备
帮助
更新
配置
接下来
之间
价值
兴趣
制器
区域
可以使
小伙
小伙伴
工程
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
京颐软件开发工资
2019北京网络安全展
如何攻击网吧服务器
网络安全教育禁止图片
山东联通软件开发
山西太原显示屏触摸软件开发公司
邮件服务器上有备份吗
临沧互联网科技园
戴尔服务器电源启动
软件开发服务器在哪里买
关于数据库中表的基本定义题
软件开发工具结构
销售软件开发的税率多少钱
支付宝网络技术短信费
网络安全渗透手机
上海同能网络技术
企业网站服务器带宽
杭州星船互联网科技
福清市酒窝网络技术有限公司
网络安全和网络绘画图片大全
方象erp连不上数据库怎么办
网络安全具体几条上网
邮件服务器怎么查询
数据库parallel 数字
目录服务器是干什么的
数据库系统工程师 教程
戴尔服务器电源启动
图解大学网络安全管理
鲲鹏裸金属服务器的主要型号
数据库等值连接怎么加查询条件