RTR和SRR是缩写吗?
我知道两者都是位,但是当系统中没有 29 位标识符时,我对 RTR 所扮演的角色感到困惑,因为我相信仅标识符就足以发送消息。或者 CAN 是否自动假设我们在系统中具有不同的标识符长度,并且只有 SRR 位和 RTR 位才重要?
接收节点 (CAN-BUS) 如何知道位填充不是数据的实际位部分?
检查下面的这个例子。两者都是有效的流,但它们的内容不同:
VALID - 位填充流(我用粗体填充零)
11111 0 10101
VALID - 不是位填充流
11111010101
我正在尝试使用微控制器板与使用 CAN-BUS 的外部设备通信。但是现在,我不太清楚CAN-BUS的机制以及如何在我的硬件上使用它。
据我了解,它是一条总线,多个设备可以在其中广播它们的消息,并且优先级由每个节点的 ID 决定。
有人能告诉我为了完成我的任务我还应该注意什么吗?
谢谢,朱涵
我有两个略有不同的结构,我想以某种方式链接以获得最快的结果.
这是两个结构:
/**
* @brief CAN Tx message structure definition
*/
typedef struct
{
uint32_t StdId; /*!< Specifies the standard identifier.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF */
uint32_t ExtId; /*!< Specifies the extended identifier.
This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF */
uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted.
This parameter can be a value of …Run Code Online (Sandbox Code Playgroud) 我试图通过套接字发送 29 位 EFF CAN 消息,但由于某种原因,它使用 11 位标识符发送它们,从 ID 中删除 5 个字节。使用环回模式,通过 candump 我可以看到消息以 11 位形式接收。
我没有收到任何错误,什么也没有,这就是我感到困惑的原因
我正在使用树莓派 3b+,如果这有什么区别的话。和 Can-utils 库。
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <net/if.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/can.h>
#include <linux/can/raw.h>
#include </home/pi/can-utils/lib.h>
int main(int argc, char **argv)
{
int s,loop = 1;
int nbytes;
struct sockaddr_can addr;
struct can_frame frame;
struct ifreq ifr;
//can interface
if((s=socket(PF_CAN, SOCK_RAW, CAN_RAW))<0){
perror("socket");
return 1;
}
strcpy(ifr.ifr_name, "can0");
if(ioctl(s, SIOCGIFINDEX, &ifr) …Run Code Online (Sandbox Code Playgroud) 我想了解以下功能模式定义的含义,库中有解释。但我不明白,因为解释很短而且不够。我在网上搜索我找不到任何有关的信息。
CAN_InitStructure.CAN_TTCM = DISABLE;
CAN_InitStructure.CAN_ABOM = DISABLE;
CAN_InitStructure.CAN_AWUM = DISABLE;
CAN_InitStructure.CAN_NART = ENABLE;
CAN_InitStructure.CAN_RFLM = DISABLE;
CAN_InitStructure.CAN_TXFP = ENABLE;
Run Code Online (Sandbox Code Playgroud)