21,600
社区成员
发帖
与我相关
我的任务
分享
//## The CAN message structure.
typedef struct {
//flags, indicating or controlling special message properties
int flags;
int cob; //CAN object number, used in Full CAN
unsigned long id; //CAN message ID, 4 bytes
struct timeval timestamp; //time stamp for received messages
short int length; //number of bytes in the CAN message
unsigned char data[CAN_MSG_LENGTH]; //data, 0...8 bytes
} canmsg_t;
typedef struct {
canmsg_t mmsg[83];
int mnum;
}canmsgs_t;
int i = 0;
for (i = 0; i < msgs.mnum; ++i)//循环msgs中有can数据的帧数
{
rx = msgs.mmsg[i]; //将一帧数据赋值给rx
}
if((msgs.mnum = read(fd_CAN, msgs.mmsg, 83))>0 ) // 从CAN1读取数据
{
int i = 0;
for (i = 0; i < msgs.mnum; ++i)//循环msgs中有can数据的帧数
{
rx = msgs.mmsg[i]; //将一帧数据赋值给rx
}
}