can数据的缓存管理是如何的?也就是连续灌多少数据,会导致接收端丢包?

​​linux的socket CAN驱动介绍(code)_good - Red_Point -

​ 一口气从零读懂CAN总线, - 知乎 (zhihu.com)​​      

​CAN protocol: Understanding the controller area network (engineersgarage.com)​

========

 ​​(21条消息) CAN总线详解_羊脂球的博客-博客_can总线​​

硬件信号 和收发讲的比较好。

================

​​STM32之CAN通讯接收过滤器过滤分析 - 羊羊得亿

过滤示例比较明确

can总线介绍_知乎

屏蔽设置为1,则从外面进到can控制器的报文,其ID对应的位不会被做丢包处理。

例如,屏蔽设置为0xffff,则 进入报文的ID中的 低16位不管是什么值可以进入到CAN控制器中进行处理。 

linux can 驱动的总体框架

​Linux CAN编程详解 - 知乎 (zhihu.com)​

这里主要关心 过滤规则的设定:

//定义接收规则,只接收表示符等于 0x11 的报文​​
​​​26​​​ ​​rfilter[0].can_id = 0x11;​​​​27​​ ​​rfilter[0].can_mask = CAN_SFF_MASK;​​​​28​​ ​​//设置过滤规则​​​​29​​ ​​setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, &rfilter,​​ ​​sizeof(rfilter));​

这个socket的 对报文的过滤实现最终是软件实现的还是硬件实现的?

raw.c    net\can    22420    2021/10/26    608
 

raw_enable_filters---》can_rx_register(af_can.c    net\can   )int can_rx_register(struct net *net, struct net_device *dev, canid_t can_id,
            canid_t mask,

can总线介绍_linux_02

 收到报文时,需要查询这个rcv_list,如果没有对应的can_id,

can总线介绍_Acceptance_03

​Acceptance Filter Implementation for CAN Receive M... - Infineon Developer Community​

Yes, it is possible to receive messages from a group of identifiers in one mailbox.

There are 16 mailboxes. Once a CAN message is received, it is compared with the acceptance filter of the mailboxes and the accepted message is stored in the corresponding mailbox. The acceptance filter is configured by the Acceptance Mask Register (AMR) and the Acceptance Code Register (ACR). AMR defines whether the respective incoming bit is compared to the respective bit in the ACR. If a bit in the AMR is “0”, then the corresponding bit in the ACR is compared to the corresponding bit that is received. If the bit in AMR is “1”, then the corresponding bit in ACR is not compared to the bit that is received.

      mask  定义了 被接收到的数据包 是否和 ACR 寄存器中的ID进行匹配。如果mask中的相应位为0,那么acr中相应的位则需要和接收到的ID中的位进行匹配。否则,如果mask中的相应位为1,则不需要进行匹配,不匹配则直接就进入到CAN控制器了,也就是都接收了。

    如果我ACR 配置为1,为了只接收1,那么我需要将 AMR中的bit 0配置为0.

Linux 中can编程,涉及数据结构的定义级过滤规则

​Linux CAN编程详解 - 知乎 (zhihu.com)​