CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
cos_sdo.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 (see cos_dict.h).

The functions in this module are called by the CANopen slave manager on reception of a SDO request.

+ Include dependency graph for cos_sdo.h:

Functions

uint8_t CosSdoBlkDownFinal (uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulObjectSizeV)
 
uint8_t CosSdoBlkDownObjectSize (uint16_t uwIndexV, uint8_t ubSubIndexV, uint32_t ulObjectSizeV)
 
uint32_t CosSdoBlkUpObjectSize (uint16_t uwIndexV, uint8_t ubSubIndexV)
 
void CosSdoCopyMessageToValue (void *pValueV, uint8_t ubDataTypeV)
 
void CosSdoCopyValueToMessage (void *pValueV, uint8_t ubDataTypeV)
 
void CosSdoResponse (uint8_t ubResponseV)
 
uint8_t CosSdoSegFinal (uint8_t ubReqCodeV, uint16_t uwIndexV, uint8_t ubSubIndexV)
 
void CosSdoSegSetup (void *pvdDataV, uint32_t ulSizeV)
 
void CosSdoSendAbort (uint32_t ulErrCodeV)
 

Function Documentation

◆ CosSdoBlkDownFinal()

uint8_t CosSdoBlkDownFinal ( uint16_t  uwIndexV,
uint8_t  ubSubIndexV,
uint32_t  ulObjectSizeV 
)
Parameters
[in]uwIndexVIndex of object
[in]ubSubIndexVSub-index of object
[in]ulObjectSizeVObject size in number of byte
Returns
Return code for SDO callbacks

This function is called by the stack when all data during a SDO block transfer has been written to the device. The application can check for valid data before a final SDO response is sent. The function is located in the file cos_user.c. If the data size is accepted by the application the function shall return eCosSdo_WRITE_OK.

◆ CosSdoBlkDownObjectSize()

uint8_t CosSdoBlkDownObjectSize ( uint16_t  uwIndexV,
uint8_t  ubSubIndexV,
uint32_t  ulObjectSizeV 
)
Parameters
[in]uwIndexVIndex of object
[in]ubSubIndexVSub-index of object
[in]ulObjectSizeVObject size in number of byte
Returns
Return code for SDO callbacks

This function is called by the stack when a SDO block download is initiated. The application can validate the size of the object defined by parameter ulObjectSizeV before the data transfer starts. The function is located in the file cos_user.c. If the data is checked by the application the function shall return eCosSdo_WRITE_OK.

◆ CosSdoBlkUpObjectSize()

uint32_t CosSdoBlkUpObjectSize ( uint16_t  uwIndexV,
uint8_t  ubSubIndexV 
)

Retrieve Object Size.

Parameters
uwIndexV- Index of object
ubSubIndexV- Sub-index of object
Returns
Number of bytes for upload
Todo:
Adopt to application

This function is called by protocol stack in order to determine the size (in bytes) of the object to be uploaded (read data from device with SDO block protocol). The function has to be adopted to the application.

◆ CosSdoCopyMessageToValue()

void CosSdoCopyMessageToValue ( void *  pValueV,
uint8_t  ubDataTypeV 
)

Copy data field from SDO message into value.

Parameters
pValueVPointer to value
ubDataTypeVDefines the value data type

This function copies the SDO data field into the location defined by pValueV. Depending on the data type the byte order is assigned according to CiA 301.

◆ CosSdoCopyValueToMessage()

void CosSdoCopyValueToMessage ( void *  pValueV,
uint8_t  ubDataTypeV 
)

Copy value into SDO message.

Parameters
pValueVPointer to value
ubDataTypeVDefines the data type

This function copies the given value into the data field of a SDO message. Depending on the data type the byte order is assigned according to CiA 301.

◆ CosSdoResponse()

void CosSdoResponse ( uint8_t  ubResponseV)

Evaluate SDO messages.

Parameters
ubResponseV- SDO response code

This function selects the correct SDO response upon the value of the parameter ubResponseV. The function calls one of the following functions with the appropriate parameter:

◆ CosSdoSegFinal()

uint8_t CosSdoSegFinal ( uint8_t  ubReqCodeV,
uint16_t  uwIndexV,
uint8_t  ubSubIndexV 
)

Handler for segmented SDO write.

Parameters
ubReqCodeV- Request Code of SDO
uwIndexV- Index of object
ubSubIndexV- Sub-index of object
Returns
Return code for SDO callbacks

This function is called by the stack when all data during a segmented transfer has been written to the device. The application can now check for valid data before a final SDO response is sent. The function is located in cos_user.c. If no data is checked by the application the function shall return eCosSdo_WRITE_OK.

◆ CosSdoSegSetup()

void CosSdoSegSetup ( void *  pvdDataV,
uint32_t  ulSizeV 
)

Initialise segmented data transfer.

Parameters
pvdDataV- Pointer to data
ulSizeV- Size of data be transferred

This function is used to initialise the Segmented SDO data transfer.

◆ CosSdoSendAbort()

void CosSdoSendAbort ( uint32_t  ulErrCodeV)

Send SDO abort message.

Parameters
ulErrCodeVAbort code

This function is sends a SDO abort message. The abort code is taken from the file canopen.h (SDO_ERR_XXX).