摘要
在CAN节点的开发中,提取解析CAN信号和赋值封装CAN信号是一个繁重且易出错的工作,传统的位操作方式无法应对需要读取和赋值的CAN信号多达数十个甚至上百个的情形,为了简单有效地提取和封装CAN信号,根据CAN网络矩阵表定义的信号、位置和长度信息设计相应报文的信号组结构体,然后以信号组结构体和字节数组为成员变量设计相应报文的联合体,信号组结构体存储信号组形式的报文数据,字节数组存储字节形式的报文数据,将信号组结构体和字节数组通过联合体的方式分配到同一个地址空间上,方便地实现了CAN报文接收对应的底层通信以及上层应用中的CAN信号提取和封装。
In the development of CAN nodes,extracting CAN signals and assigning encapsulated CAN signals is a tedious and error-prone task.Traditional bit manipulation methods cannot cope with as many as tens or even hundreds of CAN signals that need to be read and assigned.In order to extract and encapsulate the CAN signal simply and efficiently,the signal group structure of the corresponding message is designed based on the signal,position and length information defined in the CAN network matrix table.Then the union of the corresponding message is designed with the signal group structure and byte array as its member variables,the signal group structure stores the message data in the form of signal groups,and the byte array stores the message data in the form of bytes.Through the union type,the signal group structure and the byte array are allocated to the same address space,and the underlying communication corresponding to CAN message reception is conveniently implemented,and the CAN signal extraction and packaging in the upper application is realized.
作者
马建辉
慕永云
胡代荣
Ma Jianhui;Mu Yongyun;Hu Dairong(University of Technology(Shandong Academy of Sciences),Jinan 250353,China;Automatic Institute of Shan Dong Academy,Jinan 250014,China;Shandong Provincial Key Laboratory of Automotive Electronics Technology,Jinan 250014,China)
出处
《电子测量技术》
2018年第17期110-113,共4页
Electronic Measurement Technology