CANopenNode

Files

file  CO_SRDO.c
 CANopen Safety Related Data Object protocol.
 
file  CO_SRDO.h
 CANopen Safety Related Data Object protocol.
 

Data Structures

struct  CO_SRDOCommPar_t
 SRDO communication parameter. More...
 
struct  CO_SRDOGuard_t
 Gurad Object for SRDO monitors: More...
 
struct  CO_SRDO_t
 SRDO object. More...
 

Functions

CO_ReturnError_t CO_SRDOGuard_init (CO_SRDOGuard_t *SRDOGuard, CO_SDO_t *SDO, CO_NMT_internalState_t *operatingState, uint8_t *configurationValid, uint16_t idx_SRDOvalid, uint16_t idx_SRDOcrc)
 Initialize SRDOGuard object. More...
 
uint8_t CO_SRDOGuard_process (CO_SRDOGuard_t *SRDOGuard)
 Process operation and valid state changes. More...
 
CO_ReturnError_t CO_SRDO_init (CO_SRDO_t *SRDO, CO_SRDOGuard_t *SRDOGuard, CO_EM_t *em, CO_SDO_t *SDO, uint8_t nodeId, uint16_t defaultCOB_ID, const CO_SRDOCommPar_t *SRDOCommPar, const CO_SRDOMapPar_t *SRDOMapPar, const uint16_t *checksum, uint16_t idx_SRDOCommPar, uint16_t idx_SRDOMapPar, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdxNormal, uint16_t CANdevRxIdxInverted, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdxNormal, uint16_t CANdevTxIdxInverted)
 Initialize SRDO object. More...
 
void CO_SRDO_initCallbackPre (CO_SRDO_t *SRDO, void *object, void(*pFunctSignalPre)(void *object))
 Initialize SRDO callback function. More...
 
void CO_SRDO_initCallbackEnterSafeState (CO_SRDO_t *SRDO, void *object, void(*pFunctSignalSafe)(void *object))
 Initialize SRDO callback function. More...
 
CO_ReturnError_t CO_SRDO_requestSend (CO_SRDO_t *SRDO)
 Send SRDO on event. More...
 
void CO_SRDO_process (CO_SRDO_t *SRDO, uint8_t commands, uint32_t timeDifference_us, uint32_t *timerNext_us)
 Process transmitting/receiving SRDO messages. More...
 

Detailed Description

CANopen Safety Related Data Object protocol.

The functionality is very similar to that of the PDOs. The main differences is every message is send and received twice. The second message must be bitwise inverted. The delay between the two messages and between each message pair is monitored. The distinction between sending and receiving SRDO is made at runtime (for PDO it is compile time). If the security protocol is used, at least one SRDO is mandatory.

Function Documentation

◆ CO_SRDOGuard_init()

CO_ReturnError_t CO_SRDOGuard_init ( CO_SRDOGuard_t SRDOGuard,
CO_SDO_t *  SDO,
CO_NMT_internalState_t operatingState,
uint8_t configurationValid,
uint16_t  idx_SRDOvalid,
uint16_t  idx_SRDOcrc 
)

Initialize SRDOGuard object.

Function must be called in the communication reset section.

Parameters
SRDOGuardThis object will be initialized.
SDOSDO object.
operatingStatePointer to variable indicating CANopen device NMT internal state.
configurationValidPointer to variable with the SR valid flag
idx_SRDOvalidIndex in Object Dictionary
idx_SRDOcrcIndex in Object Dictionary
Returns
CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT.

◆ CO_SRDOGuard_process()

uint8_t CO_SRDOGuard_process ( CO_SRDOGuard_t SRDOGuard)

Process operation and valid state changes.

Parameters
SRDOGuardThis object.
Returns
uint8_t command for CO_SRDO_process().
  • bit 0 entered operational
  • bit 1 validate checksum

◆ CO_SRDO_init()

CO_ReturnError_t CO_SRDO_init ( CO_SRDO_t SRDO,
CO_SRDOGuard_t SRDOGuard,
CO_EM_t em,
CO_SDO_t *  SDO,
uint8_t  nodeId,
uint16_t  defaultCOB_ID,
const CO_SRDOCommPar_t SRDOCommPar,
const CO_SRDOMapPar_t *  SRDOMapPar,
const uint16_t checksum,
uint16_t  idx_SRDOCommPar,
uint16_t  idx_SRDOMapPar,
CO_CANmodule_t CANdevRx,
uint16_t  CANdevRxIdxNormal,
uint16_t  CANdevRxIdxInverted,
CO_CANmodule_t CANdevTx,
uint16_t  CANdevTxIdxNormal,
uint16_t  CANdevTxIdxInverted 
)

Initialize SRDO object.

Function must be called in the communication reset section.

Parameters
SRDOThis object will be initialized.
SRDOGuardSRDOGuard object.
emEmergency object.
SDOSDO object.
nodeIdCANopen Node ID of this device. If default COB_ID is used, value will be added.
defaultCOB_IDDefault COB ID for this SRDO (without NodeId).
SRDOCommParPointer to SRDO communication parameter record from Object dictionary (index 0x1301+).
SRDOMapParPointer to SRDO mapping parameter record from Object dictionary (index 0x1381+).
checksum
idx_SRDOCommParIndex in Object Dictionary
idx_SRDOMapParIndex in Object Dictionary
CANdevRxCAN device used for SRDO reception.
CANdevRxIdxNormalIndex of receive buffer in the above CAN device.
CANdevRxIdxInvertedIndex of receive buffer in the above CAN device.
CANdevTxCAN device used for SRDO transmission.
CANdevTxIdxNormalIndex of transmit buffer in the above CAN device.
CANdevTxIdxInvertedIndex of transmit buffer in the above CAN device.
Returns
CO_ReturnError_t: CO_ERROR_NO or CO_ERROR_ILLEGAL_ARGUMENT.

◆ CO_SRDO_initCallbackPre()

void CO_SRDO_initCallbackPre ( CO_SRDO_t SRDO,
void *  object,
void(*)(void *object)  pFunctSignalPre 
)

Initialize SRDO callback function.

Function initializes optional callback function, which should immediately start processing of CO_SRDO_process() function. Callback is called after SRDO message is received from the CAN bus.

Parameters
SRDOThis object.
objectPointer to object, which will be passed to pFunctSignalPre(). Can be NULL
pFunctSignalPrePointer to the callback function. Not called if NULL.

◆ CO_SRDO_initCallbackEnterSafeState()

void CO_SRDO_initCallbackEnterSafeState ( CO_SRDO_t SRDO,
void *  object,
void(*)(void *object)  pFunctSignalSafe 
)

Initialize SRDO callback function.

Function initializes optional callback function, that is called when SRDO enters a safe state. This happens when a timeout is reached or the data is inconsistent. The safe state itself is not further defined. One measure, for example, would be to go back to the pre-operational state Callback is called from CO_SRDO_process().

Parameters
SRDOThis object.
objectPointer to object, which will be passed to pFunctSignalSafe(). Can be NULL
pFunctSignalSafePointer to the callback function. Not called if NULL.

◆ CO_SRDO_requestSend()

CO_ReturnError_t CO_SRDO_requestSend ( CO_SRDO_t SRDO)

Send SRDO on event.

Sends SRDO before the next refresh timer tiggers. The message itself is send in CO_SRDO_process(). After the transmission the timer is reset to the full refresh time.

Parameters
SRDOThis object.
Returns
CO_ReturnError_t CO_ERROR_NO if request is granted

◆ CO_SRDO_process()

void CO_SRDO_process ( CO_SRDO_t SRDO,
uint8_t  commands,
uint32_t  timeDifference_us,
uint32_t timerNext_us 
)

Process transmitting/receiving SRDO messages.

This function verifies the checksum on demand. This function also configures the SRDO on operation state change to operational

Parameters
SRDOThis object.
commandsresult from CO_SRDOGuard_process().
timeDifference_usTime difference from previous function call in [microseconds].
[out]timerNext_usinfo to OS.