Controlling the Node
The CANopen network is organized in a master/slave communication architecture. One single CANopen device (a master or a slave) is represented within the software with a data structure, called "node". This structure is the central entry point of the application into the specific CANopen node.
The following source line is essential to create a new instance of the node:
CO_NODE demo; /* create the node instance 'demo' */
The service functions starting with CONode...()
are provided for initializing and controlling the node specific aspects. These service functions are requesting the corresponding node pointer as first argument.
For example reading the internal error state of the CANopen Node:
err = CONodeGetErr(&demo); /* get error state of node 'demo' */
The same naming convention is realized with several modules. The following table shows the names of the provided modules and their corresponding arguments:
Service Group | Argument | Example |
---|---|---|
CODir...() | &demo.Dir | CODirFind(&demo.Dir, CO_DEV(0x1234,0x56)); |
COEmcy...() | &demo.Emcy | COEmcyCnt(&demo.Emcy); |
COIf...() | &demo.If | COIfSend(&demo.If, &frm); |
CONmt...() | &demo.Nmt | CONmtGetMode(&demo.Nmt); |
CONode...() | &demo | CONodeGetErr(&demo); |
COTmr...() | &demo.Tmr | COTmrCreate(&demo.Tmr, 0, 10, MyFunc, 0); |
COTPdo...() | &demo.TPdo | COTPdoTrigPdo(&demo.TPdo, 1); |