CANopen Slave Documentation
Version 6.16.04
|
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.
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) |
uint8_t CosSdoBlkDownFinal | ( | uint16_t | uwIndexV, |
uint8_t | ubSubIndexV, | ||
uint32_t | ulObjectSizeV | ||
) |
[in] | uwIndexV | Index of object |
[in] | ubSubIndexV | Sub-index of object |
[in] | ulObjectSizeV | Object size in number of byte |
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.
uint8_t CosSdoBlkDownObjectSize | ( | uint16_t | uwIndexV, |
uint8_t | ubSubIndexV, | ||
uint32_t | ulObjectSizeV | ||
) |
[in] | uwIndexV | Index of object |
[in] | ubSubIndexV | Sub-index of object |
[in] | ulObjectSizeV | Object size in number of byte |
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.
uint32_t CosSdoBlkUpObjectSize | ( | uint16_t | uwIndexV, |
uint8_t | ubSubIndexV | ||
) |
Retrieve Object Size.
uwIndexV | - Index of object |
ubSubIndexV | - Sub-index of object |
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.
void CosSdoCopyMessageToValue | ( | void * | pValueV, |
uint8_t | ubDataTypeV | ||
) |
Copy data field from SDO message into value.
pValueV | Pointer to value |
ubDataTypeV | Defines 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.
void CosSdoCopyValueToMessage | ( | void * | pValueV, |
uint8_t | ubDataTypeV | ||
) |
Copy value into SDO message.
pValueV | Pointer to value |
ubDataTypeV | Defines 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.
void CosSdoResponse | ( | uint8_t | ubResponseV | ) |
Evaluate SDO messages.
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:
uint8_t CosSdoSegFinal | ( | uint8_t | ubReqCodeV, |
uint16_t | uwIndexV, | ||
uint8_t | ubSubIndexV | ||
) |
Handler for segmented SDO write.
ubReqCodeV | - Request Code of SDO |
uwIndexV | - Index of object |
ubSubIndexV | - Sub-index of object |
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.
void CosSdoSegSetup | ( | void * | pvdDataV, |
uint32_t | ulSizeV | ||
) |
Initialise segmented data transfer.
pvdDataV | - Pointer to data |
ulSizeV | - Size of data be transferred |
This function is used to initialise the Segmented SDO data transfer.
void CosSdoSendAbort | ( | uint32_t | ulErrCodeV | ) |
Send SDO abort message.
ulErrCodeV | Abort code |
This function is sends a SDO abort message. The abort code is taken from the file canopen.h (SDO_ERR_XXX).