CANopenNode
CO_SDOclient.h
Go to the documentation of this file.
1 
27 #ifndef CO_SDO_CLIENT_H
28 #define CO_SDO_CLIENT_H
29 
30 #include "301/CO_driver.h"
31 #include "301/CO_ODinterface.h"
32 #include "301/CO_SDOserver.h"
33 #include "301/CO_fifo.h"
34 
35 /* default configuration, see CO_config.h */
36 #ifndef CO_CONFIG_SDO_CLI
37 #define CO_CONFIG_SDO_CLI (0)
38 #endif
39 #ifndef CO_CONFIG_SDO_CLI_BUFFER_SIZE
40  #if (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK
41  #define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000
42  #else
43  #define CO_CONFIG_SDO_CLI_BUFFER_SIZE 32
44  #endif
45 #endif
46 
47 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE) || defined CO_DOXYGEN
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
67 typedef struct {
68 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_LOCAL) || defined CO_DOXYGEN
69 
70  const OD_t *OD;
77 #endif
78 
88 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_OD_DYNAMIC) || defined CO_DOXYGEN
89 
96 #endif
97 
99  /* If true, SDO channel is valid */
100  bool_t valid;
105  /* If true, then data transfer is finished */
106  bool_t finished;
109  size_t sizeInd;
111  size_t sizeTran;
125  volatile void *CANrxNew;
127  uint8_t CANrxData[8];
128 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
129 
130  void (*pFunctSignal)(void *object);
133 #endif
134 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_SEGMENTED) || defined CO_DOXYGEN
135 
137 #endif
138 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_BLOCK) || defined CO_DOXYGEN
139 
152  uint8_t block_dataUploadLast[7];
155 #endif
157 
158 
180  const OD_t *OD,
181  const OD_entry_t *OD_1280_SDOcliPar,
182  uint8_t nodeId,
183  CO_CANmodule_t *CANdevRx,
184  uint16_t CANdevRxIdx,
185  CO_CANmodule_t *CANdevTx,
186  uint16_t CANdevTxIdx);
187 
188 
189 #if ((CO_CONFIG_SDO_CLI) & CO_CONFIG_FLAG_CALLBACK_PRE) || defined CO_DOXYGEN
190 
205  void *object,
206  void (*pFunctSignal)(void *object));
207 #endif
208 
209 
229  uint32_t COB_IDClientToServer,
230  uint32_t COB_IDServerToClient,
231  uint8_t nodeIDOfTheSDOServer);
232 
233 
259  uint16_t index,
260  uint8_t subIndex,
261  size_t sizeIndicated,
262  uint16_t SDOtimeoutTime_ms,
263  bool_t blockEnable);
264 
265 
278  size_t sizeIndicated);
279 
280 
301  const char *buf,
302  size_t count);
303 
304 
334  uint32_t timeDifference_us,
335  bool_t abort,
336  bool_t bufferPartial,
337  CO_SDO_abortCode_t *SDOabortCode,
338  size_t *sizeTransferred,
339  uint32_t *timerNext_us);
340 
341 
358  uint16_t index,
359  uint8_t subIndex,
360  uint16_t SDOtimeoutTime_ms,
361  bool_t blockEnable);
362 
363 
395  uint32_t timeDifference_us,
396  bool_t abort,
397  CO_SDO_abortCode_t *SDOabortCode,
398  size_t *sizeIndicated,
399  size_t *sizeTransferred,
400  uint32_t *timerNext_us);
401 
402 
424  char *buf,
425  size_t count);
426 
427 
437 void CO_SDOclientClose(CO_SDOclient_t *SDO_C);
438  /* CO_SDOclient */
440 
441 #ifdef __cplusplus
442 }
443 #endif /*__cplusplus*/
444 
445 #endif /* (CO_CONFIG_SDO_CLI) & CO_CONFIG_SDO_CLI_ENABLE */
446 
447 #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