Files | |
file | CO_SDOclient.h |
CANopen Service Data Object - client protocol. | |
Data Structures | |
struct | CO_SDOclient_t |
SDO client object. More... | |
Functions | |
CO_ReturnError_t | CO_SDOclient_init (CO_SDOclient_t *SDO_C, const OD_t *OD, const OD_entry_t *OD_1280_SDOcliPar, uint8_t nodeId, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx) |
Initialize SDO client object. More... | |
void | CO_SDOclient_initCallbackPre (CO_SDOclient_t *SDOclient, void *object, void(*pFunctSignal)(void *object)) |
Initialize SDOclient callback function. More... | |
CO_SDO_return_t | CO_SDOclient_setup (CO_SDOclient_t *SDO_C, uint32_t COB_IDClientToServer, uint32_t COB_IDServerToClient, uint8_t nodeIDOfTheSDOServer) |
Setup SDO client object. More... | |
CO_SDO_return_t | CO_SDOclientDownloadInitiate (CO_SDOclient_t *SDO_C, uint16_t index, uint8_t subIndex, size_t sizeIndicated, uint16_t SDOtimeoutTime_ms, bool_t blockEnable) |
Initiate SDO download communication. More... | |
void | CO_SDOclientDownloadInitiateSize (CO_SDOclient_t *SDO_C, size_t sizeIndicated) |
Initiate SDO download communication - update size. More... | |
size_t | CO_SDOclientDownloadBufWrite (CO_SDOclient_t *SDO_C, const char *buf, size_t count) |
Write data into SDO client buffer. More... | |
CO_SDO_return_t | CO_SDOclientDownload (CO_SDOclient_t *SDO_C, uint32_t timeDifference_us, bool_t abort, bool_t bufferPartial, CO_SDO_abortCode_t *SDOabortCode, size_t *sizeTransferred, uint32_t *timerNext_us) |
Process SDO download communication. More... | |
CO_SDO_return_t | CO_SDOclientUploadInitiate (CO_SDOclient_t *SDO_C, uint16_t index, uint8_t subIndex, uint16_t SDOtimeoutTime_ms, bool_t blockEnable) |
Initiate SDO upload communication. More... | |
CO_SDO_return_t | CO_SDOclientUpload (CO_SDOclient_t *SDO_C, uint32_t timeDifference_us, bool_t abort, CO_SDO_abortCode_t *SDOabortCode, size_t *sizeIndicated, size_t *sizeTransferred, uint32_t *timerNext_us) |
Process SDO upload communication. More... | |
size_t | CO_SDOclientUploadBufRead (CO_SDOclient_t *SDO_C, char *buf, size_t count) |
Read data from SDO client buffer. More... | |
void | CO_SDOclientClose (CO_SDOclient_t *SDO_C) |
Close SDO communication temporary. More... | |
CANopen Service Data Object - client protocol (master functionality).
CO_ReturnError_t CO_SDOclient_init | ( | CO_SDOclient_t * | SDO_C, |
const OD_t * | OD, | ||
const OD_entry_t * | OD_1280_SDOcliPar, | ||
uint8_t | nodeId, | ||
CO_CANmodule_t * | CANdevRx, | ||
uint16_t | CANdevRxIdx, | ||
CO_CANmodule_t * | CANdevTx, | ||
uint16_t | CANdevTxIdx | ||
) |
Initialize SDO client object.
Function must be called in the communication reset section.
SDO_C | This object will be initialized. |
OD | Object Dictionary. It is used in case, if client is accessing object dictionary from its own device. If NULL, it will be ignored. |
OD_1280_SDOcliPar | OD entry for SDO client parameter (0x1280+). It may have IO extension enabled to allow dynamic configuration (see also CO_CONFIG_FLAG_OD_DYNAMIC). Entry is required. |
nodeId | CANopen Node ID of this device. It is used in case, if client is accessing object dictionary from its own device. If 0, it will be ignored. |
CANdevRx | CAN device for SDO client reception. |
CANdevRxIdx | Index of receive buffer in the above CAN device. |
CANdevTx | CAN device for SDO client transmission. |
CANdevTxIdx | Index of transmit buffer in the above CAN device. |
void CO_SDOclient_initCallbackPre | ( | CO_SDOclient_t * | SDOclient, |
void * | object, | ||
void(*)(void *object) | pFunctSignal | ||
) |
Initialize SDOclient callback function.
Function initializes optional callback function, which should immediately start processing of CO_SDOclientDownload() or CO_SDOclientUpload() function. Callback is called after SDOclient message is received from the CAN bus or when new call without delay is necessary (exchange data with own SDO server or SDO block transfer is in progress).
SDOclient | This object. |
object | Pointer to object, which will be passed to pFunctSignal(). Can be NULL. |
pFunctSignal | Pointer to the callback function. Not called if NULL. |
CO_SDO_return_t CO_SDOclient_setup | ( | CO_SDOclient_t * | SDO_C, |
uint32_t | COB_IDClientToServer, | ||
uint32_t | COB_IDServerToClient, | ||
uint8_t | nodeIDOfTheSDOServer | ||
) |
Setup SDO client object.
Function is called in from CO_SDOclient_init() and each time when "SDO client parameter" is written. Application can call this function before new SDO communication. If parameters to this function are the same as before, then CAN is not reconfigured.
SDO_C | This object. |
COB_IDClientToServer | See CO_SDOclient_t. |
COB_IDServerToClient | See CO_SDOclient_t. |
nodeIDOfTheSDOServer | Node-ID of the SDO server. If it is the same as node-ID of this node, then data will be exchanged with this node (without CAN communication). |
CO_SDO_return_t CO_SDOclientDownloadInitiate | ( | CO_SDOclient_t * | SDO_C, |
uint16_t | index, | ||
uint8_t | subIndex, | ||
size_t | sizeIndicated, | ||
uint16_t | SDOtimeoutTime_ms, | ||
bool_t | blockEnable | ||
) |
Initiate SDO download communication.
Function initiates SDO download communication with server specified in CO_SDOclient_init() function. Data will be written to remote node. Function is non-blocking.
SDO_C | This object. |
index | Index of object in object dictionary in remote node. |
subIndex | Subindex of object in object dictionary in remote node. |
sizeIndicated | Optionally indicate size of data to be downloaded. Actual data are written with one or multiple CO_SDOclientDownloadBufWrite() calls.
|
SDOtimeoutTime_ms | Timeout time for SDO communication in milliseconds. |
blockEnable | Try to initiate block transfer. |
void CO_SDOclientDownloadInitiateSize | ( | CO_SDOclient_t * | SDO_C, |
size_t | sizeIndicated | ||
) |
Initiate SDO download communication - update size.
This is optional function, which updates sizeIndicated, if it was not known in the CO_SDOclientDownloadInitiate() function call. This function can be used after CO_SDOclientDownloadBufWrite(), but must be used before CO_SDOclientDownload().
SDO_C | This object. |
sizeIndicated | Same as in CO_SDOclientDownloadInitiate(). |
size_t CO_SDOclientDownloadBufWrite | ( | CO_SDOclient_t * | SDO_C, |
const char * | buf, | ||
size_t | count | ||
) |
Write data into SDO client buffer.
This function copies data from buf into internal SDO client fifo buffer. Function returns number of bytes successfully copied. If there is not enough space in destination, not all bytes will be copied. Additional data can be copied in next cycles. If there is enough space in destination and sizeIndicated is different than zero, then all data must be written at once.
This function is basically a wrapper for CO_fifo_write() function. As alternative, other functions from CO_fifo can be used directly, for example CO_fifo_cpyTok2U8() or similar.
SDO_C | This object. |
buf | Buffer which will be copied |
count | Number of bytes in buf |
CO_SDO_return_t CO_SDOclientDownload | ( | CO_SDOclient_t * | SDO_C, |
uint32_t | timeDifference_us, | ||
bool_t | abort, | ||
bool_t | bufferPartial, | ||
CO_SDO_abortCode_t * | SDOabortCode, | ||
size_t * | sizeTransferred, | ||
uint32_t * | timerNext_us | ||
) |
Process SDO download communication.
Function must be called cyclically until it returns <=0. It Proceeds SDO download communication initiated with CO_SDOclientDownloadInitiate(). Function is non-blocking.
If function returns CO_SDO_RT_blockDownldInProgress and OS has buffer for CAN tx messages, then this function may be called multiple times within own loop. This can speed-up SDO block transfer.
SDO_C | This object. | |
timeDifference_us | Time difference from previous function call in [microseconds]. | |
abort | If true, SDO client will send abort message from SDOabortCode and transmission will be aborted. | |
bufferPartial | True indicates, not all data were copied to internal buffer yet. Buffer will be refilled later with CO_SDOclientDownloadBufWrite. | |
[out] | SDOabortCode | In case of error in communication, SDO abort code contains reason of error. Ignored if NULL. |
[out] | sizeTransferred | Actual size of data transferred. Ignored if NULL |
[out] | timerNext_us | info to OS - see CO_process(). Ignored if NULL. |
CO_SDO_return_t CO_SDOclientUploadInitiate | ( | CO_SDOclient_t * | SDO_C, |
uint16_t | index, | ||
uint8_t | subIndex, | ||
uint16_t | SDOtimeoutTime_ms, | ||
bool_t | blockEnable | ||
) |
Initiate SDO upload communication.
Function initiates SDO upload communication with server specified in CO_SDOclient_init() function. Data will be read from remote node. Function is non-blocking.
SDO_C | This object. |
index | Index of object in object dictionary in remote node. |
subIndex | Subindex of object in object dictionary in remote node. |
SDOtimeoutTime_ms | Timeout time for SDO communication in milliseconds. |
blockEnable | Try to initiate block transfer. |
CO_SDO_return_t CO_SDOclientUpload | ( | CO_SDOclient_t * | SDO_C, |
uint32_t | timeDifference_us, | ||
bool_t | abort, | ||
CO_SDO_abortCode_t * | SDOabortCode, | ||
size_t * | sizeIndicated, | ||
size_t * | sizeTransferred, | ||
uint32_t * | timerNext_us | ||
) |
Process SDO upload communication.
Function must be called cyclically until it returns <=0. It Proceeds SDO upload communication initiated with CO_SDOclientUploadInitiate(). Function is non-blocking.
If this function returns CO_SDO_RT_uploadDataBufferFull, then data must be read from fifo buffer to make it empty. This function can then be called once again immediately to speed-up block transfer. Note also, that remaining data must be read after function returns CO_SDO_RT_ok_communicationEnd. Data must not be read, if function returns CO_SDO_RT_blockUploadInProgress.
SDO_C | This object. | |
timeDifference_us | Time difference from previous function call in [microseconds]. | |
abort | If true, SDO client will send abort message from SDOabortCode and reception will be aborted. | |
[out] | SDOabortCode | In case of error in communication, SDO abort code contains reason of error. Ignored if NULL. |
[out] | sizeIndicated | If larger than 0, then SDO server has indicated size of data transfer. Ignored if NULL. |
[out] | sizeTransferred | Actual size of data transferred. Ignored if NULL |
[out] | timerNext_us | info to OS - see CO_process(). Ignored if NULL. |
size_t CO_SDOclientUploadBufRead | ( | CO_SDOclient_t * | SDO_C, |
char * | buf, | ||
size_t | count | ||
) |
Read data from SDO client buffer.
This function copies data from internal fifo buffer of SDO client into buf. Function returns number of bytes successfully copied. It can be called in multiple cycles, if data length is large.
This function is basically a wrapper for CO_fifo_read() function. As alternative, other functions from CO_fifo can be used directly, for example CO_fifo_readU82a() or similar.
SDO_C | This object. |
buf | Buffer into which data will be copied |
count | Copy up to count bytes into buffer |
void CO_SDOclientClose | ( | CO_SDOclient_t * | SDO_C | ) |
Close SDO communication temporary.
Function must be called after finish of each SDO client communication cycle. It disables reception of SDO client CAN messages. It is necessary, because CO_SDOclient_receive function may otherwise write into undefined SDO buffer.
SDO_C | This object. |