CANopen Slave Documentation
Version 7.00.00
Loading...
Searching...
No Matches
cos_sdo_cln.h File Reference

Detailed Description

With Service Data Objects (SDOs) the access to entries of a device Object Dictionary is provided. As these entries may contain data of arbitrary size and data type SDOs can be used to transfer multiple data sets (each containing an arbitrary large block of data) from a client to a server and vice versa. The client can control via a multiplexor (index and sub-index of the Object Dictionary) which data set is to be transferred. The contents of the data set are defined within the Object Dictionary.

This file is part of the optional package "Mini-Master".

+ Include dependency graph for cos_sdo_cln.h:

Data Structures

struct  CoObject_s
 

Enumerations

enum  CosSdoStat_e {
  eCOS_SDO_STAT_EXP_RD = 1 ,
  eCOS_SDO_STAT_SEG_RD ,
  eCOS_SDO_STAT_BLK_RD ,
  eCOS_SDO_STAT_EXP_WR ,
  eCOS_SDO_STAT_SEG_WR ,
  eCOS_SDO_STAT_BLK_WR ,
  eCOS_SDO_STAT_SUCCESS ,
  eCOS_SDO_STAT_ABORT ,
  eCOS_SDO_STAT_TIMEOUT ,
  eCOS_SDO_STAT_ERR ,
  eCOS_SDO_STAT_EMPTY ,
  eCOS_SDO_STAT_SIZE
}
 
enum  CosSdoMarker_e {
  eCOS_SDO_MARKER_USER_END = 200 ,
  eCOS_SDO_MARKER_NODE_SET_HEARTBEAT
}
 
enum  CosSdoConfig_e {
  eCOS_SDO_CONFIG_DEFAULT = 0 ,
  eCOS_SDO_CONFIG_CMD_LEN = 1 ,
  eCOS_SDO_CONFIG_BLOCK = 2
}
 

Functions

void CosSdoClnEventObjectReady (uint8_t ubNodeIdV, CoObject_ts *ptsCoObjV, uint32_t *pulAbortV)
 
void CosSdoClnEventTimeout (uint8_t ubNodeIdV, CoObject_ts *ptsCoObjV)
 
uint8_t CosSdoClnGetStatus (void)
 
uint8_t CosSdoClnReadObject (uint8_t ubNodeIdV, CoObject_ts *ptsCoObjV, uint16_t uwObjCntV, uint32_t *pulErrCodeV)
 
uint8_t CosSdoClnWriteObject (uint8_t ubNodeIdV, CoObject_ts *ptsCoObjV, uint16_t uwObjCntV, uint32_t *pulErrCodeV)
 
void CosSdoClnSendAbort (uint8_t ubNodeIdV, uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulErrCodeV)
 
void CosSdoClnSetConfiguration (uint8_t ubConfigV)
 
void CosSdoClnSetTimeout (uint16_t uwTimeV)
 

Enumeration Type Documentation

◆ CosSdoConfig_e

SDO client configuration.

The enumeration defines configuration values for the SDO client behaviour, which is set via the function CosSdoClnSetConfiguration().

Enumerator
eCOS_SDO_CONFIG_DEFAULT 

Use SDO client default configuration

eCOS_SDO_CONFIG_CMD_LEN 

Set data length for command byte in expedited transfer

eCOS_SDO_CONFIG_BLOCK 

Set SDO block transfer for data length > 4 bytes

◆ CosSdoMarker_e

SDO transfer marker.

The enumeration defines values for the marker field inside the CANopen object structure CoObject_s. The marker field can be evaluated inside the CosSdoClnEventObjectReady() function.

Enumerator
eCOS_SDO_MARKER_USER_END 

Last possible value for user-defined marker

eCOS_SDO_MARKER_NODE_SET_HEARTBEAT 

Marker for CosNmtMasterSetHeartbeat() function call

◆ CosSdoStat_e

SDO transfer status.

The enumeration defines the status of a SDO client connection. It can be requested with the ComSdoGetStatus() function.

Enumerator
eCOS_SDO_STAT_EXP_RD 

Expedited transfer in progress (read)

eCOS_SDO_STAT_SEG_RD 

Segmented transfer in progress (read)

eCOS_SDO_STAT_BLK_RD 

Block transfer in progress (read)

eCOS_SDO_STAT_EXP_WR 

Expedited transfer in progress (write)

eCOS_SDO_STAT_SEG_WR 

Segmented transfer in progress (write)

eCOS_SDO_STAT_BLK_WR 

Block transfer in progress (write)

eCOS_SDO_STAT_SUCCESS 

SDO communication success

eCOS_SDO_STAT_ABORT 

SDO communication aborted

eCOS_SDO_STAT_TIMEOUT 

SDO communication timeout

eCOS_SDO_STAT_ERR 

SDO protocol error

eCOS_SDO_STAT_EMPTY 

SDO client is free, no SDO communication present

eCOS_SDO_STAT_SIZE 

Data size for client/server does not match

Function Documentation

◆ CosSdoClnEventObjectReady()

void CosSdoClnEventObjectReady ( uint8_t ubNodeIdV,
CoObject_ts * ptsCoObjV,
uint32_t * pulAbortV )
Parameters
[in]ubNodeIdVNode-ID value
[in]ptsCoObjVPointer to object structure
[in]pulAbortVPointer to SDO abort code

This handler is called after the SDO data transfer has finished. If the SDO transfer has been initiated by CosSdoClnReadObject() or CosSdoClnWriteObject() the parameter ptsCoObjV points to the last object which has been read or written. Otherwise the pointer ptsCoObjV is 0L. The user defined marker within the structure CoObject_ts can be used to track SDO operations.

In case of a SDO abort, the pointer pulAbortV allows to read the last abort code. The value of pulAbortV is 0L when no SDO error occurred.

◆ CosSdoClnEventTimeout()

void CosSdoClnEventTimeout ( uint8_t ubNodeIdV,
CoObject_ts * ptsCoObjV )
Parameters
[in]ubNodeIdVNode-ID value
[in]ptsCoObjVPointer to object structure
See also
CosSdoClnSetTimeout()

This handler is called if a SDO timer condition occurred. The parameters uwIndexV and ubSubIndexV define the object that was accessed. The SDO communication timeout can be configured by the ComSdoSetTimeout() function.

◆ CosSdoClnGetStatus()

uint8_t CosSdoClnGetStatus ( void )

Get SDO transfer status.

Returns
SDO connection status

This function returns the status of a SDO connection, possible values are given by the enumeration CosSdoStat_e.

◆ CosSdoClnReadObject()

uint8_t CosSdoClnReadObject ( uint8_t ubNodeIdV,
CoObject_ts * ptsCoObjV,
uint16_t uwObjCntV,
uint32_t * pulErrCodeV )
Parameters
[in]ubNodeIdVNode-ID value
[in]ptsCoObjVPointer to object structure
[in]uwObjCntVNumber of objects to read
[in]pulErrCodeVPointer to optional abort code data
Returns
Error code

This function will start a read request for an object that is defined by the pointer ptsCoObjV.

◆ CosSdoClnSendAbort()

void CosSdoClnSendAbort ( uint8_t ubNodeIdV,
uint16_t uwIndexV,
uint8_t ubSubIndexV,
uint32_t ulErrCodeV )
Parameters
[in]ubNodeIdVNode-ID value
[in]uwIndexVIndex of object
[in]ubSubIndexVSub-index of object
[in]ulErrCodeVSDO error code

This function is sends a SDO abort message. The abort code is taken from the file canopen.h (SDO_ERR_XXX). The identifier for the abort message is calculated via the node address ubNodeIdV.

◆ CosSdoClnSetConfiguration()

void CosSdoClnSetConfiguration ( uint8_t ubConfigV)
Parameters
[in]ubConfigVSDO client configuration value

This function is used to change the behaviour of the SDO client. The possible configuration values are defined via the CosSdoConfig_e enumeration.

◆ CosSdoClnSetTimeout()

void CosSdoClnSetTimeout ( uint16_t uwTimeV)
Parameters
[in]uwTimeV- timeout value in milliseconds

This function sets a timeout value for a SDO communication. If the response to a SDO request by the master takes longer than this timeout value, the state of the communication will be changed to eCOS_SDO_STAT_TIMEOUT. The state of the SDO communication can be evaluated by calling the function CosSdoClnGetStatus(). Please note that the timeout value is a multiple of the timer period (COS_TIMER_PERIOD). A value supplied to this function will be rounded towards the next lower value if necessary.

◆ CosSdoClnWriteObject()

uint8_t CosSdoClnWriteObject ( uint8_t ubNodeIdV,
CoObject_ts * ptsCoObjV,
uint16_t uwObjCntV,
uint32_t * pulErrCodeV )
Parameters
[in]ubNodeIdVNode-ID value
[in]ptsCoObjVPointer to object structure
[in]uwObjCntVNumber of objects to read
[in]pulErrCodeVPointer to optional abort code data
Returns
Error code

This function will start a write request for for an object that is defined by the pointer ptsCoObjV.