- canopen协议和can的id
canopen协议是建立在can总线协议上的协议,can协议的包头id被重新规划了能传送更丰富的信息
其中功能码是
这样在使用canopen协议的can总线上就不能单纯的使用canid来传送消息了,一些固定的canid就有了特殊的用途,从功能码可以看出管理报文优先级最高 , 同步时间戳 紧急 pdo次之,这样canopen的id就是功能码加上缩小的can的id里的设备id,这样can总线就能传送消息给对应的节点,又能传送类似广播的消息给所有节点。
- canopen的字典
既然定义好了通信的目标 传送的消息是什么样的那,就是通信的双方都使用一个预先定义好的字典来通信,以canopennode的数据结构为例
typedef struct {
/** The index of Object from 0x1000 to 0xFFFF */
uint16_t index;
/** Number of (sub-objects - 1). If Object Type is variable, then
maxSubIndex is 0, otherwise maxSubIndex is equal or greater than 1. */
uint8_t maxSubIndex;
/** If Object Type is record, attribute is set to zero. Attribute for
each member is then set in special array with members of type
CO_OD_entryRecord_t. If Object Type is Array, attribute is common for
all array members. See #CO_SDO_OD_attributes_t. */
uint16_t attribute;
/** If Object Type is Variable, length is the length of variable in bytes.
If Object Type is Array, length is the length of one array member.
If Object Type is Record, length is zero. Length for each member is
set in special array with members of type CO_OD_entryRecord_t.
If Object Type is Domain, length is zero. Length is specified
by application in @ref CO_SDO_OD_function. */
uint16_t length;
/** If Object Type is Variable, pData is pointer to data.
If Object Type is Array, pData is pointer to data. Data doesn't
include Sub-Object 0.
If object type is Record, pData is pointer to special array
with members of type CO_OD_entryRecord_t.
If object type is Domain, pData is null. */
void *pData;
}CO_OD_entry_t;
发送接收都按字典的索引index子索引SubIndex和来传送消息,同时字典又不全是要传送消息的索引和值的对应,还有一些乱七八糟的功能包括配置都放在了里面,canopen规定好了一些默认的字典存储位置
- sdo包
上面看到字典索引和对应的数据,最简单的访问方法就是发送对应的设备id加上字典的索引,然后服务端就响应响应的数据,这就是sdo包的通信过程,但是这样就可能造成频繁访问的对象每次都要传送字典索引来通信,对传输数据非常小又要求实时性非常高的场合就还有优化的空间,这就是pdo - pdo包
pdo则不传字典中的索引了,直接发送数据内容,由于实时性要求数据丢了就丢了重传可能已经是没有意义的了,可能因为这方面的需求pdo才被设计成单向的
直接传数据什么时候发送,怎么区分是哪个值那,使用的是规定好的can的id,发送接收都约定好PDO1-PDO4各发送什么数据,根据什么事件来发送
这样就产生了两个配置,例如PDO1发送的canid是多少,和什么时候发送是通信配置放在字典里配置好类似canopennode会直接来使用
PDO1发送字典里的哪个值就是映射参数也放在字典里 canopennode会根据配置字典对应位置的配置来实现
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。