CAN API: Functions and Macros#

Contents:

CAN Bus API: Functions and Macros#

CAN Bus API : Functions and Macros

Contents:

CAN_CTRLR_REG()#

Description#

Registers a CAN controller to the platform manager.

Files#

can_bus.h

Prototype#

CAN_CTRLR_REG (name                p_drv_info)

Arguments#

name

Unique name for the CAN controller. It is recommended to follow the standard "canX", where X is a digit.

p_drv_info

Pointer to the CAN Bus driver hardware information structure of type CAN_CTRLR_DRV_INFO.

Returned Value#

None.

Notes / Warnings#

  1. This macro should normally be called from the BSP.

CANopen API: Functions and Macros#

CANopen API : Functions and Macros

Contents:

CANopen Core API: Functions and Macros#

CANopen Core API : Functions and Macros

Contents:

CANopen_ConfigureMemSeg()#

Description#

Configures the memory segment where CANopen module data structures will be allocated.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_ConfigureMemSeg (MEM_SEG   *p_seg)
Arguments#

p_seg

Pointer to memory segment to use when allocating control data. DEF_NULL means general purpose heap segment.

Returned Value#

None.

Notes / Warnings#
  1. Calling this function is optional, if it is not called, the default value will be used.

  2. This function MUST be called after the CANopen_Init() function.

CANopen_ConfigureEventQty()#

Description#

Configures the maximum number of events for all the CANopen busses.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_ConfigureEventQty (CPU_SIZE_T    event_qty)
Arguments#

event_qty

Quantity of events.

Returned Value#

None.

Notes / Warnings#
  1. Calling this function is optional, if it is not called, the default value will be used.

  2. This function MUST be called before the CANopen_Init() function.

CANopen_ConfigureSvcTaskStk()#

Description#

Configures the CANopen service task's stack.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_ConfigureSvcTaskStk (CPU_INT32U    stk_size_elements,
                                   void         *p_stk)
Arguments#

stk_size_elements

Size, in stack elements, of the task's stack.

p_stk

Pointer to base of the task's stack. If DEF_NULL, stack will be allocated from KAL's memory segment.

Returned Value#

None.

Notes / Warnings#
  1. Calling this function is optional, if it is not called, the default value will be used.

  2. This function MUST be called before the CANopen module is initialized via the CANopen_Init() function.

  3. In order to change the priority of the CANopen core task, use the function CANopen_SvcTaskPrioSet().

CANopen_ConfigureTmrPeriod()#

Description#

Configures the hardware timer time base.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_ConfigureTmrPeriod (CPU_INT32U    tmr_period)
Arguments#

tmr_period

Timer period in microsecond.

Returned Value#

None.

Notes / Warnings#
  1. Calling this function is optional, if it is not called, the default value will be used.

  2. This function MUST be called before the CANopen_Init() function.

CANopen_Init()#

Description#

Initializes CANopen resources and service task.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_Init (RTOS_ERR   *p_err)
Arguments#

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SEG_OVF

Returned Value#

None.

Notes / Warnings#

None.

CANopen_NodeAdd()#

Description#

Adds a node to the stack and configures it with the given specifications.

Files#

canopen_core.h/canopen_core.c

Prototype#
CANOPEN_NODE_HANDLE CANopen_NodeAdd (const CPU_CHAR              *p_name,
                                      const CANOPEN_NODE_SPEC     *p_spec,
                                      const CANOPEN_EVENT_FNCTS   *p_event_fctns,
                                            RTOS_ERR              *p_err)
Arguments#

p_name

Pointer to a CAN Bus controller name.

p_spec

Pointer to the node's specifications.

p_event_fncts

Pointer to event functions callback structure.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

  • RTOS_ERR_SEG_OVF

Returned Value#

Handle to the added node, if successful. DEF_NULL, if there was a problem adding the node.

Notes / Warnings#
  1. The node is still in INIT state after this function call. To finalize the initialization phase (e.g., profile-specific or application actions, etc.), see CANopen_NodeStart().

CANopen_NodeStart()#

Description#

Starts a node by starting the CAN controller operations.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_NodeStart (CANOPEN_NODE_HANDLE    node_handle,
                         RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_NodeStop()#

Description#

Stops a node by stopping the CAN controller operations.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_NodeStop (CANOPEN_NODE_HANDLE    node_handle,
                        RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_NodeParamLoad()#

Description#

Loads all parameter groups with the given type.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_NodeParamLoad (CANOPEN_NODE_HANDLE    node_handle,
                             CANOPEN_NMT_RESET      reset_type,
                             RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

reset_type

Reset type:

  • CANOPEN_RESET_COMM

  • CANOPEN_RESET_NODE

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_NOT_FOUND

  • RTOS_ERR_FAIL

Returned Value#

None.

Notes / Warnings#
  1. The single parameter group(s) will be loaded from non-volatile memory by calling the user application callback function set through CANOPEN_EVENT_FNCTS / ParaOnLoad.

  2. This function considers all parameter groups, which are linked to the parameter store index (1010h) within the object directory. Every not linked parameter group is not in the scope of this function and must be handled within the application.

CANopen_NodeLockTimeoutSet()#

Description#

Sets the node object directory lock timeout.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_NodeLockTimeoutSet (CANOPEN_NODE_HANDLE    node_handle,
                                  CPU_INT32U             timeout,
                                  RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

timeout

Timeout value for the object dictionary lock.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_SvcTaskPrioSet()#

Description#

Assigns a new priority to the CANopen service task.

Files#

canopen_core.h/canopen_core.c

Prototype#
void CANopen_SvcTaskPrioSet (CPU_INT08U    prio,
                              RTOS_ERR     *p_err)
Arguments#

prio

New priority of the service task.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_INVALID_ARG

Returned Value#

None.

Notes / Warnings#
  1. This function MUST be called before the CANopen_Init() function.

CANopen_DictByteRd()#

Description#

Reads a 8-bit value from the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictByteRd (CANOPEN_NODE_HANDLE    node_handle,
                          CPU_INT32U             key,
                          CPU_INT08U            *p_val,
                          RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

p_val

Pointer to the value destination.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_OBJ_RD

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the value will be written to the given destination pointer.

CANopen_DictWordRd()#

Description#

Reads a 16-bit value from the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictWordRd (CANOPEN_NODE_HANDLE    node_handle,
                          CPU_INT32U             key,
                          CPU_INT16U            *p_val,
                          RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

p_val

Pointer to the value destination.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_OBJ_RD

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the value will be written to the given destination pointer.

CANopen_DictLongRd()#

Description#

Reads a 32-bit value from the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictLongRd (CANOPEN_NODE_HANDLE    node_handle,
                          CPU_INT32U             key,
                          CPU_INT32U            *p_val,
                          RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

p_val

Pointer to the value destination.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_OBJ_RD

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the value will be written to the given destination pointer.

CANopen_DictByteWr()#

Description#

Writes a 8-bit value to the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictByteWr (CANOPEN_NODE_HANDLE    node_handle,
                          CPU_INT32U             key,
                          CPU_INT08U             val,
                          RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

val

The source value.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_OBJ_WD

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the value will be read from the given source pointer.

CANopen_DictWordWr()#

Description#

Writes a 16-bit value to the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictWordWr (CANOPEN_NODE_HANDLE    node_handle,
                          CPU_INT32U             key,
                          CPU_INT16U             val,
                          RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

val

The source value.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_OBJ_WD

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the value will be read from the given source pointer.

CANopen_DictLongWr()#

Description#

This function writes a 32-bit value to the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictLongWr (CANOPEN_NODE_HANDLE    node_handle,
                          CPU_INT32U             key,
                          CPU_INT32U             val,
                          RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

val

The source value.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_SIZE_INVALID

  • RTOS_ERR_OBJ_WD

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the value will be read from the given source pointer.

CANopen_DictBufRd()#

Description#

Reads a buffer byte stream from the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictBufRd (CANOPEN_NODE_HANDLE    node_handle,
                         CPU_INT32U             key,
                         CPU_INT08U            *p_buf,
                         CPU_INT32U             len,
                         RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

p_buf

Pointer to the destination buffer.

len

Length of destination buffer.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NOT_AVAIL

  • RTOS_ERR_WOULD_OVF

  • RTOS_ERR_OS_OBJ_DEL

  • RTOS_ERR_WOULD_BLOCK

  • RTOS_ERR_IS_OWNER

  • RTOS_ERR_OS_SCHED_LOCKED

  • RTOS_ERR_ABORT

  • RTOS_ERR_TIMEOUT

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the bytes to read will be written to the given destination buffer of the given length.

CANopen_DictBufWr()#

Description#

Writes a buffer byte stream to the given object dictionary.

Files#

canopen_dict.h/canopen_dict.c

Prototype#
void CANopen_DictBufWr (CANOPEN_NODE_HANDLE    node_handle,
                         CPU_INT32U             key,
                         CPU_INT08U            *p_buf,
                         CPU_INT32U             len,
                         RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

key

Object entry key; should be generated with the macro CANOPEN_DEV() .

p_buf

Pointer to the source buffer.

len

Length of source buffer.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NOT_AVAIL

  • RTOS_ERR_WOULD_OVF

  • RTOS_ERR_OS_OBJ_DEL

  • RTOS_ERR_WOULD_BLOCK

  • RTOS_ERR_IS_OWNER

  • RTOS_ERR_OS_SCHED_LOCKED

  • RTOS_ERR_ABORT

  • RTOS_ERR_TIMEOUT

Returned Value#

None.

Notes / Warnings#
  1. The object entry is addressed with the given key and the bytes to write will be read from to the given source buffer of the given length.

CANOPEN_KEY()#

Description#

This macro helps to build the CANopen object member variable 'key'.

Files#

canopen_obj.h

Prototype#
CANOPEN_KEY (idx,
              sub,
              flags)
Arguments#

idx

CANopen object index [0x0000..0xFFFF]

sub

CANopen object subindex [0x00..0xFF]

flags

The additional object property flags

Returned Value#

None.

Notes / Warnings#

The resulting variable is used to hold the unique address of the object entry with index:subindex. Furthermore the lower 8 bits of the key are used to describe the way of accessing this object entry.

CANOPEN_DEV()#

Description#

This macro helps to build the CANopen object member device identifier.

Files#

canopen_obj .h

Prototype#
CANOPEN_DEV (idx              sub)
Arguments#

idx

CANopen object index [0x0000..0xFFFF]

sub

CANopen object subindex [0x00..0xFF]

Returned Value#

None.

Notes / Warnings#

This identifier is used to search the unique address of the object entry (index:subindex).

CANOPEN_OBJ_MAPPING_LINK()#

Description#

This macro helps to build the CANopen object entry for a PDO mapping.

Files#

canopen_obj .h

Prototype#
CANOPEN_OBJ_MAPPING_LINK (idx                           sub                           bit)
Arguments#

idx

CANopen object index [0x0000..0xFFFF]

sub

CANopen object subindex [0x00..0xFF]

bit

Length of mapped signal in bits [8,16 or 32]

Returned Value#

None.

Notes / Warnings#

This entry is used to specify the linked signal within a PDO.

CANOPEN_OBJ_GET_DEV()#

Description#

This macro helps to extract the index and subindex out of the CANopen object entry member 'key'.

Files#

canopen_obj .h

Prototype#
CANOPEN_OBJ_GET_DEV (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_GET_SUBIX()#

Description#

This macro helps to extract the subindex out of the CANopen object entry member 'key'.

Files#

canopen_obj .h

Prototype#
CANOPEN_OBJ_GET_SUBIX (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_GET_IX()#

Description#

This macro helps to extract the index out of the CANopen object entry member 'key'.

Files#

canopen_obj .h

Prototype#
CANOPEN_OBJ_GET_IX (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_GET_SIZE()#

Description#

This macro helps to extract the object entry size in bytes out of the CANopen object entry member 'key'.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_GET_SIZE (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

If this result is 0, the size must be calculated with the function Size(), referenced in the linked type structure.

CANOPEN_OBJ_IS_PDOMAP()#

Description#

This macro helps to determine, if the object entry is PDO mappable.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_IS_PDOMAP (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_IS_NODEID()#

Description#

This macro helps to determine, if the object entry value depends on the node-ID.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_IS_NODEID (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_IS_DIRECT()#

Description#

This macro helps to determine, if the object entry value is a direct value.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_IS_DIRECT (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_IS_RD()#

Description#

This macro helps to determine, if the object entry value is readable.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_IS_RD (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_IS_WR()#

Description#

This macro helps to determine, if the object entry value is writeable.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_IS_WR (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANOPEN_OBJ_IS_RD_ONLY()#

Description#

This macro helps to determine, if the object entry value is read-only.

Files#

canopen_obj.h

Prototype#
CANOPEN_OBJ_IS_RD_ONLY (key)
Arguments#

key

CANopen object member variable 'key'.

Returned Value#

None.

Notes / Warnings#

None.

CANopen Communication Object API: Functions and Macros#

CANopen Communication object API : Functions and Macros

Contents:

CANopen_EmcySet()#

Description#

Sets an emergency message and sends an event to the Service task to trigger emergency processing.

Files#

canopen_emcy.h/canopen_emcy.c

Prototype#
void CANopen_EmcySet (CANOPEN_NODE_HANDLE    node_handle,
                       CPU_INT08U             err_code_ix,
                       CANOPEN_EMCY_USR      *p_user,
                       RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

err_code_ix

EMCY error index in User EMCY table.

p_user

Vendor-specific fields in EMCY history and/or EMCY message.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_EmcyClr()#

Description#

Clears an emergency message and sends an event to the Service task to trigger emergency processing.

Files#

canopen_emcy.h/canopen_emcy.c

Prototype#
void CANopen_EmcyClr (CANOPEN_NODE_HANDLE    node_handle,
                       CPU_INT08U             err_code_ix,
                       RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

err_code_ix

EMCY error index in User EMCY table.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_EmcyGet()#

Description#

Returns the current EMCY error status.

Files#

canopen_emcy.h/canopen_emcy.c

Prototype#
CPU_INT16S CANopen_EmcyGet (CANOPEN_NODE_HANDLE    node_handle,
                             CPU_INT08U             err_code_ix,
                             RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

err_code_ix

EMCY error index in User EMCY table.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NOT_INIT

  • RTOS_ERR_NULL_PTR

Returned Value#

Current EMCY error status.

Notes / Warnings#

None.

CANopen_EmcyCnt()#

Description#

Returns the number of currently detected EMCY errors.

Files#

canopen_emcy.h/canopen_emcy.c

Prototype#
CPU_INT16S CANopen_EmcyCnt (CANOPEN_NODE_HANDLE    node_handle,
                             RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NOT_INIT

  • RTOS_ERR_NULL_PTR

Returned Value#

Number of EMCY errors.

Notes / Warnings#

None.

CANopen_EmcyReset()#

Description#

Clears all EMCY errors.

Files#

canopen_emcy.h/canopen_emcy.c

Prototype#
void CANopen_EmcyReset (CANOPEN_NODE_HANDLE    node_handle,
                         RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NOT_INIT

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_EmcyHistReset()#

Description#

Clears the EMCY history in the object dictionary.

Files#

canopen_emcy.h/canopen_emcy.c

Prototype#
void CANopen_EmcyHistReset (CANOPEN_NODE_HANDLE    node_handle)
Arguments#

node_handle

Handle to CANopen node object.

Returned Value#

None.

Notes / Warnings#

None.

CANopen_NmtReset()#

Description#

Resets the CANopen device with the given type.

Files#

canopen_nmt.h/canopen_nmt.c

Prototype#
void CANopen_NmtReset (CANOPEN_NODE_HANDLE    node_handle,
                        CANOPEN_NMT_RESET      type,
                        RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

type

The requested NMT reset type:

  • CANOPEN_RESET_NODE

  • CANOPEN_RESET_COMM

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_NmtStateSet()#

Description#

Sets the requested CANopen NMT state machine state.

Files#

canopen_nmt.h/canopen_nmt.c

Prototype#
void CANopen_NmtStateSet (CANOPEN_NODE_HANDLE    node_handle,
                           CANOPEN_NODE_STATE     state,
                           RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

state

The requested NMT state:

  • CANOPEN_INIT

  • CANOPEN_PREOP

  • CANOPEN_OPERATIONAL

  • CANOPEN_STOP

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

None.

Notes / Warnings#

None.

CANopen_NmtStateGet()#

Description#

Returns the current CANopen NMT state machine state.

Files#

canopen_nmt.h/canopen_nmt.c

Prototype#
CANOPEN_NODE_STATE CANopen_NmtStateGet (CANOPEN_NODE_HANDLE    node_handle)
Arguments#

node_handle

Handle to CANopen node object.

Returned Value#

NMT state of the parent node.

Notes / Warnings#

None.

CANopen_NmtHbConsEventsGet()#

Description#

Gets the number of missed heartbeat events.

Files#

canopen_nmt.h/canopen_hbcons.c

Prototype#
CPU_INT16S CANopen_NmtHbConsEventsGet (CANOPEN_NODE_HANDLE    node_handle,
                                        CPU_INT08U             node_id.
                                        RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

node_id

node ID of monitored node (or 0 for master node).

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#
  • The number of missed heartbeat events for given node ID.

  • < 0, if error detected (e.g., node ID is not monitored).

Notes / Warnings#

None.

CANopen_NmtHbConsLastStateGet()#

Description#

Returns the last received heartbeat state of a given node.

Files#

canopen_nmt.h/canopen_hbcons.c

Prototype#
CANOPEN_NODE_STATE CANopen_NmtHbConsLastStateGet (CANOPEN_NODE_HANDLE    node_handle,
                                                   CPU_INT08U             node_id,
                                                   RTOS_ERR              *p_err)
Arguments#

node_handle

Handle to CANopen node object.

node_id

Node ID of monitored node.

p_err

Pointer to the variable that will receive one of the following error code(s) from this function:

  • RTOS_ERR_NONE

  • RTOS_ERR_NULL_PTR

Returned Value#

Last detected node state for given node ID:

  • CANOPEN_INVALID

  • CANOPEN_INIT

  • CANOPEN_PREOP

  • CANOPEN_OPERATIONAL

  • CANOPEN_STOP

Notes / Warnings#

None.