CO_SDOclient.h
Go to the documentation of this file.
#ifndef CO_SDO_CLIENT_H
#define CO_SDO_CLIENT_H
#include "301/CO_driver.h"
#include "301/CO_ODinterface.h"
#include "301/CO_SDOserver.h"
#include "301/CO_fifo.h"
/* default configuration, see CO_config.h */
#ifndef CO_CONFIG_SDO_CLI
#define CO_CONFIG_SDO_CLI (0)
#endif
#ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE
#if (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000
#else
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
#endif
#endif
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE) || defined CO_DOXYGEN
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_LOCAL) || defined CO_DOXYGEN
const OD_t *OD;
uint8_t nodeId;
OD_IO_t OD_IO;
OD_attr_t attribute;
#endif
CO_CANmodule_t *CANdevRx;
uint16_t CANdevRxIdx;
CO_CANmodule_t *CANdevTx;
uint16_t CANdevTxIdx;
CO_CANtx_t *CANtxBuff;
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_OD_DYNAMIC) || defined CO_DOXYGEN
uint32_t COB_IDClientToServer;
uint32_t COB_IDServerToClient;
#endif
uint8_t nodeIDOfTheSDOServer;
/* If true, SDO channel is valid */
bool_t valid;
uint16_t index;
uint8_t subIndex;
/* If true, then data transfer is finished */
bool_t finished;
size_t sizeInd;
size_t sizeTran;
volatile CO_SDO_state_t state;
uint32_t SDOtimeoutTime_us;
uint32_t timeoutTimer;
CO_fifo_t bufFifo;
char buf[CO_CONFIG_SDO_CLI_BUFFER_SIZE + 1];
volatile void *CANrxNew;
uint8_t CANrxData[8];
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void (*pFunctSignal)(void *object);
void *functSignalObject;
#endif
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_SEGMENTED) || defined CO_DOXYGEN
uint8_t toggle;
#endif
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK) || defined CO_DOXYGEN
uint32_t block_SDOtimeoutTime_us;
uint32_t block_timeoutTimer;
uint8_t block_seqno;
uint8_t block_blksize;
uint8_t block_noData;
bool_t block_crcEnabled;
uint8_t block_dataUploadLast[7];
uint16_t block_crc;
#endif
} CO_SDOclient_t;
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);
#if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
void CO_SDOclient_initCallbackPre(CO_SDOclient_t *SDOclient,
void *object,
void (*pFunctSignal)(void *object));
#endif
CO_SDO_return_t CO_SDOclient_setup(CO_SDOclient_t *SDO_C,
uint32_t COB_IDClientToServer,
uint32_t COB_IDServerToClient,
uint8_t nodeIDOfTheSDOServer);
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);
void CO_SDOclientDownloadInitiateSize(CO_SDOclient_t *SDO_C,
size_t sizeIndicated);
size_t CO_SDOclientDownloadBufWrite(CO_SDOclient_t *SDO_C,
const char *buf,
size_t count);
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);
CO_SDO_return_t CO_SDOclientUploadInitiate(CO_SDOclient_t *SDO_C,
uint16_t index,
uint8_t subIndex,
uint16_t SDOtimeoutTime_ms,
bool_t blockEnable);
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);
size_t CO_SDOclientUploadBufRead(CO_SDOclient_t *SDO_C,
char *buf,
size_t count);
void CO_SDOclientClose(CO_SDOclient_t *SDO_C);
/* CO_SDOclient */
#ifdef __cplusplus
}
#endif /*__cplusplus*/
#endif /* (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE */
#endif /* CO_SDO_CLIENT_H */
uint32_t
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition: CO_driver.h:155
CO_driver.h
Interface between CAN hardware and CANopenNode.
CO_SDOclient_t::CANrxNew
volatile void * CANrxNew
Indicates, if new SDO message received from CAN bus.
Definition: CO_SDOclient.h:125
CO_SDOclient_t::attribute
OD_attr_t attribute
Attribute for locally transferred OD sub-object, see OD_attributes_t.
Definition: CO_SDOclient.h:76
CO_SDO_return_t
CO_SDO_return_t
Return values from SDO server or client functions.
Definition: CO_SDOserver.h:410
CO_SDOclient_t::block_crcEnabled
bool_t block_crcEnabled
Server CRC support in block transfer.
Definition: CO_SDOclient.h:150
CO_SDOclient_t
SDO client object.
Definition: CO_SDOclient.h:67
CO_SDOclient_setup
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.
uint16_t
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition: CO_driver.h:153
CO_SDOclient_t::COB_IDClientToServer
uint32_t COB_IDClientToServer
Copy of CANopen COB_ID Client -> Server, meaning of the specific bits:
Definition: CO_SDOclient.h:93
CO_CONFIG_SDO_CLI_BUFFER_SIZE
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE
Size of the internal data buffer for the SDO client.
Definition: CO_config.h:386
CO_SDOclient_t::sizeInd
size_t sizeInd
Size of data, which will be transferred.
Definition: CO_SDOclient.h:109
CO_ReturnError_t
CO_ReturnError_t
Return values of some CANopen functions.
Definition: CO_driver.h:488
CO_SDOclient_t::OD_IO
OD_IO_t OD_IO
Object dictionary interface for locally transferred object.
Definition: CO_SDOclient.h:74
CO_SDOclientUpload
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.
CO_SDOclient_t::bufFifo
CO_fifo_t bufFifo
CO_fifo_t object for data buffer (not pointer)
Definition: CO_SDOclient.h:119
bool_t
unsigned char bool_t
Boolean data type for general use.
Definition: CO_driver.h:141
CO_SDOclient_init
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.
CO_SDOclient_t::block_timeoutTimer
uint32_t block_timeoutTimer
Timeout timer for SDO sub-block upload.
Definition: CO_SDOclient.h:142
CO_SDOclient_t::subIndex
uint8_t subIndex
Subindex of current object in Object Dictionary.
Definition: CO_SDOclient.h:104
CO_SDOclient_t::OD
const OD_t * OD
From CO_SDOclient_init()
Definition: CO_SDOclient.h:70
CO_SDOclient_t::index
uint16_t index
Index of current object in Object Dictionary.
Definition: CO_SDOclient.h:102
CO_SDOclient_initCallbackPre
void CO_SDOclient_initCallbackPre(CO_SDOclient_t *SDOclient, void *object, void(*pFunctSignal)(void *object))
Initialize SDOclient callback function.
CO_SDOclient_t::nodeIDOfTheSDOServer
uint8_t nodeIDOfTheSDOServer
Node-ID of the SDO server.
Definition: CO_SDOclient.h:98
CO_SDOserver.h
CANopen Service Data Object - server protocol.
CO_SDOclient_t::CANdevRx
CO_CANmodule_t * CANdevRx
From CO_SDOclient_init()
Definition: CO_SDOclient.h:79
CO_SDOclientDownloadInitiateSize
void CO_SDOclientDownloadInitiateSize(CO_SDOclient_t *SDO_C, size_t sizeIndicated)
Initiate SDO download communication - update size.
CO_SDOclientDownload
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.
CO_SDOclient_t::COB_IDServerToClient
uint32_t COB_IDServerToClient
Copy of CANopen COB_ID Server -> Client, similar as above.
Definition: CO_SDOclient.h:95
CO_SDOclient_t::CANdevTxIdx
uint16_t CANdevTxIdx
From CO_SDOclient_init()
Definition: CO_SDOclient.h:85
CO_SDOclient_t::toggle
uint8_t toggle
Toggle bit toggled in each segment in segmented transfer.
Definition: CO_SDOclient.h:136
CO_SDOclient_t::CANtxBuff
CO_CANtx_t * CANtxBuff
CAN transmit buffer inside CANdevTx for CAN tx message.
Definition: CO_SDOclient.h:87
CO_SDOclient_t::block_SDOtimeoutTime_us
uint32_t block_SDOtimeoutTime_us
Timeout time for SDO sub-block upload, half of SDOtimeoutTime_us.
Definition: CO_SDOclient.h:140
CO_SDOclient_t::block_seqno
uint8_t block_seqno
Sequence number of segment in block, 1..127.
Definition: CO_SDOclient.h:144
CO_SDOclientUploadInitiate
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.
CO_SDO_abortCode_t
CO_SDO_abortCode_t
SDO abort codes.
Definition: CO_SDOserver.h:333
CO_SDOclientDownloadInitiate
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.
CO_SDOclient_t::block_crc
uint16_t block_crc
Calculated CRC checksum.
Definition: CO_SDOclient.h:154
CO_SDO_state_t
CO_SDO_state_t
Internal states of the SDO state machine.
Definition: CO_SDOserver.h:102
CO_fifo_t
Fifo object.
Definition: CO_fifo.h:60
CO_SDOclientUploadBufRead
size_t CO_SDOclientUploadBufRead(CO_SDOclient_t *SDO_C, char *buf, size_t count)
Read data from SDO client buffer.
CO_SDOclient_t::nodeId
uint8_t nodeId
From CO_SDOclient_init()
Definition: CO_SDOclient.h:72
CO_SDOclient_t::state
volatile CO_SDO_state_t state
Internal state of the SDO client.
Definition: CO_SDOclient.h:113
CO_ODinterface.h
CANopen Object Dictionary interface.
CO_SDOclientDownloadBufWrite
size_t CO_SDOclientDownloadBufWrite(CO_SDOclient_t *SDO_C, const char *buf, size_t count)
Write data into SDO client buffer.
CO_SDOclient_t::sizeTran
size_t sizeTran
Size of data which is actually transferred.
Definition: CO_SDOclient.h:111
OD_t
Object Dictionary.
Definition: CO_ODinterface.h:352
CO_CANmodule_t
Complete CAN module object.
Definition: CO_driver.h:319
CO_SDOclient_t::CANdevTx
CO_CANmodule_t * CANdevTx
From CO_SDOclient_init()
Definition: CO_SDOclient.h:83
OD_IO_t
Structure for input / output on the OD variable.
Definition: CO_ODinterface.h:263
OD_entry_t
Object Dictionary entry for one OD object.
Definition: CO_ODinterface.h:336
CO_fifo.h
FIFO circular buffer.
CO_SDOclientClose
void CO_SDOclientClose(CO_SDOclient_t *SDO_C)
Close SDO communication temporary.
CO_SDOclient_t::block_blksize
uint8_t block_blksize
Number of segments per block, 1..127.
Definition: CO_SDOclient.h:146
CO_SDOclient_t::block_noData
uint8_t block_noData
Number of bytes in last segment that do not contain data.
Definition: CO_SDOclient.h:148
CO_SDOclient_t::functSignalObject
void * functSignalObject
From CO_SDOclient_initCallbackPre() or NULL.
Definition: CO_SDOclient.h:132
CO_SDOclient_t::SDOtimeoutTime_us
uint32_t SDOtimeoutTime_us
Maximum timeout time between request and response in microseconds.
Definition: CO_SDOclient.h:115
CO_SDOclient_t::timeoutTimer
uint32_t timeoutTimer
Timeout timer for SDO communication.
Definition: CO_SDOclient.h:117
CO_CANtx_t
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition: CO_driver.h:299
uint8_t
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition: CO_driver.h:151
CO_SDOclient_t::CANdevRxIdx
uint16_t CANdevRxIdx
From CO_SDOclient_init()
Definition: CO_SDOclient.h:81
OD_attr_t
#define OD_attr_t
Size of Object Dictionary attribute.
Definition: CO_ODinterface.h:50