CANopen Master Documentation
Version 6.06.04
|
The CANopen Network Management (NMT) is used to change the state of a CANopen slave node. This module holds functions for the protocol stack to behave in both ways: as Master or as Slave. If the protocol stack is started in Slave mode (refer to the ComMgrInit() function), the protocol stack must react on NMT messages. If started in Master mode, the protocol stack holds the NMT resource and is allowed to send NMT messages.
The functionality includes also to act as heartbeat consumer for all possible slaves.
Functions | |
void | ComNmtEventActiveMaster (uint8_t ubNetV, uint8_t ubPriorityV, uint8_t ubNodeIdV) |
void | ComNmtEventGuarding (uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubReasonV) |
void | ComNmtEventHeartbeat (uint8_t ubNetV, uint8_t ubNodeIdV) |
void | ComNmtEventStateChange (uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubNmtStateV) |
void | ComNmtEventIdCollision (uint8_t ubNetV) |
void | ComNmtEventMasterDetection (uint8_t ubNetV, uint8_t ubResultV) |
void | ComNmtEventResetNode (uint8_t ubNetV) |
void | ComNmtEventResetCommunication (uint8_t ubNetV) |
ComStatus_tv | ComNmtGetHbConsTime (uint8_t ubNetV, uint8_t ubNodeIdV, uint16_t *puwTimeV) |
ComStatus_tv | ComNmtGetHbProdTime (uint8_t ubNetV, uint16_t *puwTimeV) |
ComStatus_tv | ComNmtGetInhibit (uint8_t ubNetV, uint32_t *pulTimeV) |
ComStatus_tv | ComNmtGetNodeState (uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t *pubStateV) |
ComStatus_tv | ComNmtIsMaster (uint8_t ubNetV) |
ComStatus_tv | ComNmtMasterDetection (uint8_t ubNetV, uint8_t ubBootupV) |
ComStatus_tv | ComNmtFlyingMaster (uint8_t ubNetV) |
ComStatus_tv | ComNmtSetGuardTime (uint8_t ubNetV, uint8_t ubNodeIdV, uint16_t uwGuardTimeV, uint8_t ubLifeTimeFactorV) |
ComStatus_tv | ComNmtSetHbConsTime (uint8_t ubNetV, uint8_t ubNodeIdV, uint16_t uwTimeV) |
ComStatus_tv | ComNmtSetHbProdTime (uint8_t ubNetV, uint16_t uwTimeV) |
ComStatus_tv | ComNmtSetInhibit (uint8_t ubNetV, uint32_t ulTimeV) |
ComStatus_tv | ComNmtSetNodeState (uint8_t ubNetV, uint8_t ubNodeIdV, uint8_t ubStateV) |
enum ComNmtState_e |
NMT state codes.
The enumeration defines the values for setting the NMT state of a CANopen device via ComNmtSetNodeState() as well as for requesting the device state via ComNmtGetNodeState(). The values in this enumeration are not equal to the NMT command specifiers.
void ComNmtEventActiveMaster | ( | uint8_t | ubNetV, |
uint8_t | ubPriorityV, | ||
uint8_t | ubNodeIdV | ||
) |
[in] | ubNetV | CANopen Network channel |
ubPriorityV | - NMT master priority | |
ubNodeIdV | - Node-ID value |
This function is called by the stack on a NMT active master indication.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventGuarding | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint8_t | ubReasonV | ||
) |
ubNetV | - CANopen Network channel |
ubNodeIdV | - Node-ID value |
ubReasonV | - Reason for guarding event |
This function is called by the stack on a NMT node guarding event (i.e. the node did not respond on a CAN remote frame within the configured guard time). The parameter ubReasonV defines the cause for the guarding event (see ComNmtGuard_e enumeration).
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventHeartbeat | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV | ||
) |
[in] | ubNetV | CANopen Network channel |
ubNodeIdV | - Node-ID value |
This function is called by the stack on a NMT heartbeat event.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventIdCollision | ( | uint8_t | ubNetV | ) |
[in] | ubNetV | CANopen Network channel |
This function is called by the stack on a NMT identifier collision.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventMasterDetection | ( | uint8_t | ubNetV, |
uint8_t | ubResultV | ||
) |
NMT master detection callback.
[in] | ubNetV | CANopen Network channel |
ubResultV | - Result of NMT master detection |
This function is called by the stack as result on a NMT master detection procedure. Possible values for the parameter ubResultV are
The value eCOM_NMT_DETECT_SUCCESS
means that a NMT master device is available in the network. The CANopen master stack shall not be used as NMT master in that case. The value eCOM_NMT_DETECT_TIMEOUT
denotes that there was no response from another NMT master in the network and the CANopen master stack may be used as NMT master.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventResetCommunication | ( | uint8_t | ubNetV | ) |
[in] | ubNetV | CANopen Network channel |
This function is called by the stack on a NMT reset communication command.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventResetNode | ( | uint8_t | ubNetV | ) |
NMT reset event callback.
ubNetV | - CANopen Network channel |
This function is called by the stack on a NMT reset remote node command.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
void ComNmtEventStateChange | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint8_t | ubNmtStateV | ||
) |
[in] | ubNetV | CANopen Network channel |
ubNodeIdV | - Node-ID value | |
ubNmtStateV | - New NMT state |
This function is called by the stack on a NMT state change event. Possible values for ubNmtStateV are listed in the ComNmtState_e enumeration.
The action on this function is application specific. The function body is placed inside the file com_user.c
.
ComStatus_tv ComNmtFlyingMaster | ( | uint8_t | ubNetV | ) |
Start NMT Flying Master detection.
ubNetV | - CANopen Network channel |
This function starts the NMT Flying Master process.
ComStatus_tv ComNmtGetHbConsTime | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint16_t * | puwTimeV | ||
) |
[in] | ubNetV | CANopen Network channel |
ubNodeIdV | - Node-ID value | |
puwTimeV | - Pointer to heartbeat timer value |
This function retrieves the heartbeat consumer time for the CANopen Master. The value passed to the pointer puwTimeV is given in multiples of 1 millisecond.
ComStatus_tv ComNmtGetHbProdTime | ( | uint8_t | ubNetV, |
uint16_t * | puwTimeV | ||
) |
Get producer heartbeat time.
[in] | ubNetV | CANopen Network channel |
[out] | puwTimeV | Pointer to heartbeat timer value |
This function retrieves the heartbeat producer time for the CANopen Master. The value passed to the pointer puwTimeV is given in multiples of 1 millisecond.
ComStatus_tv ComNmtGetInhibit | ( | uint8_t | ubNetV, |
uint32_t * | pulTimeV | ||
) |
[in] | ubNetV | CANopen Network channel |
[out] | pulTimeV | Pointer to NMT inhibit time |
This function retrieves the inhibit time between two subsequent NMT messages. The pointer pulTimeV points to a variable that holds the time value in multiples of one microsecond.
ComStatus_tv ComNmtGetNodeState | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint8_t * | pubStateV | ||
) |
[in] | ubNetV | CANopen Network channel |
[in] | ubNodeIdV | Node-ID value |
[out] | pubStateV | Pointer to NMT state variable |
This function retrieves the NMT state of the CANopen device with the Node-ID ubNodeIdV
. Possible values for ubNodeIdV are 1 .. 127. The value passed to the pointer pubStateV is taken from the ComNmtState_e enumeration.
ComStatus_tv ComNmtIsMaster | ( | uint8_t | ubNetV | ) |
Check for NMT master.
ubNetV | - CANopen Network channel |
This function checks if the device is the NMT master or not.
ComStatus_tv ComNmtMasterDetection | ( | uint8_t | ubNetV, |
uint8_t | ubBootupV | ||
) |
Start NMT master detection.
[in] | ubNetV | CANopen Network channel |
ubBootupV | - set to 1 if run upon bootup |
This function starts the NMT master detection.
ComStatus_tv ComNmtSetGuardTime | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint16_t | uwGuardTimeV, | ||
uint8_t | ubLifeTimeFactorV | ||
) |
ubNetV | - CANopen Network channel |
ubNodeIdV | - Node-ID value |
uwGuardTimeV | - Node guard time value |
ubLifeTimeFactorV | - Life time factor |
This function sets the node guard time for the CANopen device with the Node-ID ubNodeIdV. Possible values for ubNodeIdV are 1 .. 127. The value passed to uwGuardTimeV is given in multiples of 1 millisecond.
If the parameter ubNodeIdV is equal to the Node-ID of the CANopen FD Master, the function will return an error (eCOM_ERR_NODE_ID).
The node guard time can only be set if the heartbeat producer time for that node is set to 0 (both error protocols cannot be used at the same time). When node guarding is started for a CANopen node, the CANopen master stack will send RTR frames with the identifier 700h + ubNodeIdV and a cycle time of uwTimeV milliseconds.
ComStatus_tv ComNmtSetHbConsTime | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint16_t | uwTimeV | ||
) |
Set consumer heartbeat time.
ubNetV | - CANopen Network channel |
ubNodeIdV | - Node-ID value |
uwTimeV | - Heartbeat timer value |
This function sets the heartbeat consumer time for the CANopen device with the Node-ID ubNodeIdV. Possible values for ubNodeIdV are 1 .. 127. The value passed to uwTimeV is given in multiples of 1 millisecond.
If the parameter ubNodeIdV is equal to the Node-ID of the CANopen Master, the function will return an error (eCOM_ERR_NODE_ID).
ComStatus_tv ComNmtSetHbProdTime | ( | uint8_t | ubNetV, |
uint16_t | uwTimeV | ||
) |
Set producer heartbeat time.
ubNetV | - CANopen Network channel |
uwTimeV | - Heartbeat timer value |
This function sets the heartbeat producer time for the CANopen Master. The value passed to uwTimeV is given in multiples of 1 millisecond.
ComStatus_tv ComNmtSetInhibit | ( | uint8_t | ubNetV, |
uint32_t | ulTimeV | ||
) |
Set NMT message inhibit time.
ubNetV | - CANopen Network channel |
ulTimeV | - NMT inhibit time |
This function sets the inhibit time between two subsequent NMT messages. The parameter ulTimeV is given in multiples of 1 microsecond.
ComStatus_tv ComNmtSetNodeState | ( | uint8_t | ubNetV, |
uint8_t | ubNodeIdV, | ||
uint8_t | ubStateV | ||
) |
Set NMT state of CANopen device.
ubNetV | - CANopen Network channel |
ubNodeIdV | - Node-ID value |
ubStateV | - New NMT state |
This function changes the NMT state of the CANopen device with the Node-ID ubNodeIdV. Possible values for ubNodeIdV are 0 .. 127. A value of 0 addresses all devices in the network. Passing the address of the CANopen Master to ubNodeIdV will change the NMT state of the Master.
The value passed to ubStateV is taken from the ComNmtState_e enumeration.