CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
cos_nmt.h File Reference

Detailed Description

The CANopen Network Management (NMT) is used to change the state of a CANopen slave node. In addition, the network state can be monitored via the Network Management Error Control (NMT-EC) service. This module provides the following functionality:

  • NMT state change
  • NMT Error Control (heartbeat/node-guarding)
  • Send boot-up message
  • Callbacks for NMT state change
+ Include dependency graph for cos_nmt.h:

Macros

#define NODE_STATE_BOOTUP   ((uint8_t)(0x00))
 
#define NODE_STATE_STOPPED   ((uint8_t)(0x04))
 
#define NODE_STATE_OPERATIONAL   ((uint8_t)(0x05))
 
#define NODE_STATE_PREOPERATIONAL   ((uint8_t)(0x7F))
 
#define NODE_STATE_BUS_OFF   ((uint8_t)(0xFF))
 

Functions

void CosNmtChangeNodeState (uint8_t ubFailureV)
 
uint8_t CosNmtCheckNodeReset (void)
 
uint8_t CosNmtGetNodeState (void)
 
void CosNmtServiceOnError (void)
 
void CosNmtServiceOnGuardingEvent (void)
 
void CosNmtServiceOnHeartbeatEvent (void)
 
void CosNmtServiceOnPreOperational (void)
 
void CosNmtServiceOnStart (void)
 
void CosNmtServiceOnStop (void)
 
uint8_t CosNmtSetHeartbeatCons (uint8_t ubEntryV, uint8_t ubNodeIdV, uint16_t uwTimeV)
 
void CosNmtSetHeartbeatProd (uint16_t uwTimeV)
 

Function Documentation

◆ CosNmtChangeNodeState()

void CosNmtChangeNodeState ( uint8_t  ubFailureV)
Parameters
[in]ubFailureVError reason

This function changes the NMT state of the device depending on the contents of object 1029h (error behaviour). The parameter ubFailureV defines the reason for the failure:

  • 1 = communication error
  • 2 .. N = Profile or manufacturer specific error

The maximum value for ubFailureV is defined by the symbol COS_DICT_OBJ_1029. For the failure type 'communication error' the function is called by the stack.

◆ CosNmtCheckNodeReset()

uint8_t CosNmtCheckNodeReset ( void  )
Returns
Reset State

This function returns the node reset state (NODE_RESET_XXX).

◆ CosNmtGetNodeState()

uint8_t CosNmtGetNodeState ( void  )
Returns
NMT node state

This function returns the current NMT state of the node. Possible return values are defined by NMT node state.

◆ CosNmtServiceOnError()

void CosNmtServiceOnError ( void  )

This function is called when the NMT state machine receives an unknown NMT command, i.e. the identifier 0 with a DLC that does not match or data that does not match. The reaction on this event is application specific.

The function implementation is located in the file cos_user.c.

◆ CosNmtServiceOnGuardingEvent()

void CosNmtServiceOnGuardingEvent ( void  )

This functions is called upon the occurrence of a guarding event.

The function implementation is located in the file cos_user.c.

◆ CosNmtServiceOnHeartbeatEvent()

void CosNmtServiceOnHeartbeatEvent ( void  )

This functions is called upon the occurrence of a heartbeat event.

The function implementation is located in the file cos_user.c.

◆ CosNmtServiceOnPreOperational()

void CosNmtServiceOnPreOperational ( void  )

This service routine is called when the NMT state machine changes into NMT pre-operational state. It can be used to perform device specific routines after reception of the NMT command.

The function implementation is located in the file cos_user.c.

◆ CosNmtServiceOnStart()

void CosNmtServiceOnStart ( void  )

This service routine is called when the NMT state machine changes into NMT operational state. It can be used to perform device specific routines after reception of the NMT command.

The function implementation is located in the file cos_user.c.

◆ CosNmtServiceOnStop()

void CosNmtServiceOnStop ( void  )

This service routine is called when the NMT state machine changes into NMT stopped state. It can be used to perform device specific routines after reception of the NMT command.

The function implementation is located in the file cos_user.c.

◆ CosNmtSetHeartbeatCons()

uint8_t CosNmtSetHeartbeatCons ( uint8_t  ubEntryV,
uint8_t  ubNodeIdV,
uint16_t  uwTimeV 
)
Parameters
[in]ubEntryVheartbeat consumer entry (0 .. N)
[in]ubNodeIdVnode-ID to monitor
[in]uwTimeVexpected heartbeat cycle time
Returns
0 on success

This function sets the heartbeat consumer time for the entry ubEntryV. The maximum number of entries is defined via the symbol COS_DICT_OBJ_1016. The parameter uwTimeV denotes the time in milli-seconds. If the heartbeat consumer time is setup for the own node-ID or the supplied node-ID is already in use, the function will return the value 1. On success, the value 0 is returned.

◆ CosNmtSetHeartbeatProd()

void CosNmtSetHeartbeatProd ( uint16_t  uwTimeV)
Parameters
[in]uwTimeVheartbeat cycle time

This function sets the heartbeat producer time. The parameter uwTimeV denotes the time in milli-seconds. By default, the heartbeat producer time is set to 0 during initialization.