CANopen Heartbeat consumer protocol.
More...
|
CO_ReturnError_t | CO_HBconsumer_init (CO_HBconsumer_t *HBcons, CO_EM_t *em, CO_HBconsNode_t *monitoredNodes, uint8_t monitoredNodesCount, OD_entry_t *OD_1016_HBcons, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdxStart, uint32_t *errInfo) |
| Initialize Heartbeat consumer object.
|
|
void | CO_HBconsumer_initCallbackPre (CO_HBconsumer_t *HBcons, void *object, void(*pFunctSignal)(void *object)) |
| Initialize Heartbeat consumer callback function.
|
|
void | CO_HBconsumer_initCallbackNmtChanged (CO_HBconsumer_t *HBcons, uint8_t idx, void *object, void(*pFunctSignal)(uint8_t nodeId, uint8_t idx, CO_NMT_internalState_t NMTstate, void *object)) |
| Initialize Heartbeat consumer NMT changed callback function.
|
|
void | CO_HBconsumer_initCallbackHeartbeatStarted (CO_HBconsumer_t *HBcons, uint8_t idx, void *object, void(*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object)) |
| Initialize Heartbeat consumer started callback function.
|
|
void | CO_HBconsumer_initCallbackTimeout (CO_HBconsumer_t *HBcons, uint8_t idx, void *object, void(*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object)) |
| Initialize Heartbeat consumer timeout callback function.
|
|
void | CO_HBconsumer_initCallbackRemoteReset (CO_HBconsumer_t *HBcons, uint8_t idx, void *object, void(*pFunctSignal)(uint8_t nodeId, uint8_t idx, void *object)) |
| Initialize Heartbeat consumer remote reset detected callback function.
|
|
void | CO_HBconsumer_process (CO_HBconsumer_t *HBcons, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, uint32_t *timerNext_us) |
| Process Heartbeat consumer object.
|
|
int8_t | CO_HBconsumer_getIdxByNodeId (CO_HBconsumer_t *HBcons, uint8_t nodeId) |
| Get the heartbeat producer object index by node ID.
|
|
CO_HBconsumer_state_t | CO_HBconsumer_getState (CO_HBconsumer_t *HBcons, uint8_t idx) |
| Get the current state of a heartbeat producer by the index in OD 0x1016.
|
|
int8_t | CO_HBconsumer_getNmtState (CO_HBconsumer_t *HBcons, uint8_t idx, CO_NMT_internalState_t *nmtState) |
| Get the current NMT state of a heartbeat producer by the index in OD 0x1016.
|
|
CANopen Heartbeat consumer protocol.
Heartbeat consumer monitors Heartbeat messages from remote nodes. If any monitored node don't send his Heartbeat in specified time, Heartbeat consumer sends emergency message. If all monitored nodes are operational, then variable allMonitoredOperational inside CO_HBconsumer_t is set to true. Monitoring starts after the reception of the first HeartBeat (not bootup).
Heartbeat set up is done by writing to the OD registers 0x1016. To setup heartbeat consumer by application, use
static ODR_t OD_set_u32(const OD_entry_t *entry, uint8_t subIndex, uint32_t val, bool_t odOrig)
Set uint32_t variable in Object Dictionary, see OD_set_value.
Definition CO_ODinterface.h:605
ODR_t
Return codes from OD access functions.
Definition CO_ODinterface.h:129
- See also
- NMT and Heartbeat
◆ CO_HBconsumer_state_t
Heartbeat state of a node.
Enumerator |
---|
CO_HBconsumer_UNCONFIGURED | Consumer entry inactive.
|
CO_HBconsumer_UNKNOWN | Consumer enabled, but no heartbeat received yet.
|
CO_HBconsumer_ACTIVE | Heartbeat received within set time.
|
CO_HBconsumer_TIMEOUT | No heatbeat received for set time.
|
◆ CO_HBconsumer_init()
Initialize Heartbeat consumer object.
Function must be called in the communication reset section.
- Parameters
-
| HBcons | This object will be initialized. |
| em | Emergency object. |
| monitoredNodes | Array of monitored nodes, must be defined externally. |
| monitoredNodesCount | Size of the above array, usually equal to number of array elements in OD 0x1016, valid values are 1 to 127 |
| OD_1016_HBcons | OD entry for 0x1016 - "Consumer heartbeat time", entry is required, IO extension will be applied. |
| CANdevRx | CAN device for Heartbeat reception. |
| CANdevRxIdxStart | Starting index of receive buffer in the above CAN device. Number of used indexes is equal to monitoredNodesCount. |
[out] | errInfo | Additional information in case of error, may be NULL. |
- Returns
- CO_ReturnError_t CO_ERROR_NO in case of success.
◆ CO_HBconsumer_initCallbackPre()
void CO_HBconsumer_initCallbackPre |
( |
CO_HBconsumer_t * | HBcons, |
|
|
void * | object, |
|
|
void(* | pFunctSignal )(void *object) ) |
Initialize Heartbeat consumer callback function.
Function initializes optional callback function, which should immediately start processing of CO_HBconsumer_process() function. Callback is called after HBconsumer message is received from the CAN bus.
- Parameters
-
HBcons | This object. |
object | Pointer to object, which will be passed to pFunctSignal(). Can be NULL |
pFunctSignal | Pointer to the callback function. Not called if NULL. |
◆ CO_HBconsumer_initCallbackNmtChanged()
Initialize Heartbeat consumer NMT changed callback function.
Function initializes optional callback function, which is called when NMT state from the remote node changes.
- Parameters
-
HBcons | This object. |
idx | index of the node in HBcons object (only when CO_CONFIG_HB_CONS_CALLBACK_MULTI is enabled) |
object | Pointer to object, which will be passed to pFunctSignal(). Can be NULL. |
pFunctSignal | Pointer to the callback function. Not called if NULL. |
◆ CO_HBconsumer_initCallbackHeartbeatStarted()
Initialize Heartbeat consumer started callback function.
Function initializes optional callback function, which is called for the first received heartbeat after activating hb consumer or timeout. Function may wake up external task, which handles this event.
- Parameters
-
HBcons | This object. |
idx | index of the node in HBcons object |
object | Pointer to object, which will be passed to pFunctSignal(). Can be NULL |
pFunctSignal | Pointer to the callback function. Not called if NULL. |
◆ CO_HBconsumer_initCallbackTimeout()
Initialize Heartbeat consumer timeout callback function.
Function initializes optional callback function, which is called when the node state changes from active to timeout. Function may wake up external task, which handles this event.
- Parameters
-
HBcons | This object. |
idx | index of the node in HBcons object |
object | Pointer to object, which will be passed to pFunctSignal(). Can be NULL |
pFunctSignal | Pointer to the callback function. Not called if NULL. |
◆ CO_HBconsumer_initCallbackRemoteReset()
Initialize Heartbeat consumer remote reset detected callback function.
Function initializes optional callback function, which is called when a bootup message is received from the remote node. Function may wake up external task, which handles this event.
- Parameters
-
HBcons | This object. |
idx | index of the node in HBcons object |
object | Pointer to object, which will be passed to pFunctSignal(). Can be NULL |
pFunctSignal | Pointer to the callback function. Not called if NULL. |
◆ CO_HBconsumer_process()
Process Heartbeat consumer object.
Function must be called cyclically.
- Parameters
-
| HBcons | This object. |
| NMTisPreOrOperational | True if this node is NMT_PRE_OPERATIONAL or NMT_OPERATIONAL. |
| timeDifference_us | Time difference from previous function call in [microseconds]. |
[out] | timerNext_us | info to OS - see CO_process(). |
◆ CO_HBconsumer_getIdxByNodeId()
Get the heartbeat producer object index by node ID.
- Parameters
-
HBcons | This object. |
nodeId | producer node ID |
- Returns
- index. -1 if not found
◆ CO_HBconsumer_getState()
Get the current state of a heartbeat producer by the index in OD 0x1016.
- Parameters
-
HBcons | This object. |
idx | object sub index |
- Returns
- CO_HBconsumer_state_t
◆ CO_HBconsumer_getNmtState()
Get the current NMT state of a heartbeat producer by the index in OD 0x1016.
NMT state is only available when heartbeat is enabled for this index!
- Parameters
-
| HBcons | This object. |
| idx | object sub index |
[out] | nmtState | of this index |
- Return values
-
0 | NMT state has been received and is valid |
-1 | not valid |