CANopenNode
CANopen protocol stack
Loading...
Searching...
No Matches
CO_SDOserver.h
Go to the documentation of this file.
1
21#ifndef CO_SDO_SERVER_H
22#define CO_SDO_SERVER_H
23
24#include "301/CO_driver.h"
25#include "301/CO_ODinterface.h"
26
27/* default configuration, see CO_config.h */
28#ifndef CO_CONFIG_SDO_SRV
29#define CO_CONFIG_SDO_SRV \
30 (CO_CONFIG_SDO_SRV_SEGMENTED | CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | CO_CONFIG_GLOBAL_FLAG_TIMERNEXT \
31 | CO_CONFIG_GLOBAL_FLAG_OD_DYNAMIC)
32#endif
33#ifndef CO_CONFIG_SDO_SRV_BUFFER_SIZE
34#define CO_CONFIG_SDO_SRV_BUFFER_SIZE 32U
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
76#define CO_SDO_ST_FLAG_DOWNLOAD 0x10U
77#define CO_SDO_ST_FLAG_UPLOAD 0x20U
78#define CO_SDO_ST_FLAG_BLOCK 0x40U
79
288
296typedef enum {
297 CO_SDO_AB_NONE = 0x00000000UL,
298 CO_SDO_AB_TOGGLE_BIT = 0x05030000UL,
299 CO_SDO_AB_TIMEOUT = 0x05040000UL,
300 CO_SDO_AB_CMD = 0x05040001UL,
301 CO_SDO_AB_BLOCK_SIZE = 0x05040002UL,
302 CO_SDO_AB_SEQ_NUM = 0x05040003UL,
303 CO_SDO_AB_CRC = 0x05040004UL,
304 CO_SDO_AB_OUT_OF_MEM = 0x05040005UL,
306 CO_SDO_AB_WRITEONLY = 0x06010001UL,
307 CO_SDO_AB_READONLY = 0x06010002UL,
308 CO_SDO_AB_NOT_EXIST = 0x06020000UL,
309 CO_SDO_AB_NO_MAP = 0x06040041UL,
310 CO_SDO_AB_MAP_LEN = 0x06040042UL,
312 CO_SDO_AB_PRAM_INCOMPAT = 0x06040043UL,
314 CO_SDO_AB_HW = 0x06060000UL,
315 CO_SDO_AB_TYPE_MISMATCH = 0x06070010UL,
317 CO_SDO_AB_DATA_LONG = 0x06070012UL,
319 CO_SDO_AB_DATA_SHORT = 0x06070013UL,
321 CO_SDO_AB_SUB_UNKNOWN = 0x06090011UL,
322 CO_SDO_AB_INVALID_VALUE = 0x06090030UL,
323 CO_SDO_AB_VALUE_HIGH = 0x06090031UL,
324 CO_SDO_AB_VALUE_LOW = 0x06090032UL,
325 CO_SDO_AB_MAX_LESS_MIN = 0x06090036UL,
326 CO_SDO_AB_NO_RESOURCE = 0x060A0023UL,
327 CO_SDO_AB_GENERAL = 0x08000000UL,
328 CO_SDO_AB_DATA_TRANSF = 0x08000020UL,
329 CO_SDO_AB_DATA_LOC_CTRL = 0x08000021UL,
331 CO_SDO_AB_DATA_DEV_STATE = 0x08000022UL,
333 CO_SDO_AB_DATA_OD = 0x08000023UL,
335 CO_SDO_AB_NO_DATA = 0x08000024UL
337
355
359typedef struct {
369 volatile void* CANrxNew;
371 uint8_t CANrxData[8];
372#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_OD_DYNAMIC) != 0) || defined CO_DOXYGEN
382#endif
383#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_SDO_SRV_SEGMENTED) != 0) || defined CO_DOXYGEN
396#endif
397#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_SDO_SRV_BLOCK) != 0) || defined CO_DOXYGEN
405#endif
406#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN
407 void (*pFunctSignalPre)(void* object);
409#endif
411
433CO_ReturnError_t CO_SDOserver_init(CO_SDOserver_t* SDO, OD_t* OD, OD_entry_t* OD_1200_SDOsrvPar, uint8_t nodeId,
434 uint16_t SDOtimeoutTime_ms, CO_CANmodule_t* CANdevRx, uint16_t CANdevRxIdx,
435 CO_CANmodule_t* CANdevTx, uint16_t CANdevTxIdx, uint32_t* errInfo);
436
437#if (((CO_CONFIG_SDO_SRV)&CO_CONFIG_FLAG_CALLBACK_PRE) != 0) || defined CO_DOXYGEN
449void CO_SDOserver_initCallbackPre(CO_SDOserver_t* SDO, void* object, void (*pFunctSignalPre)(void* object));
450#endif
451
464CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t* SDO, bool_t NMTisPreOrOperational, uint32_t timeDifference_us,
465 uint32_t* timerNext_us);
466
467 /* CO_SDOserver */
468
469#ifdef __cplusplus
470}
471#endif /* __cplusplus */
472
473#endif /* CO_SDO_SERVER_H */
CANopen Object Dictionary interface.
Interface between CAN hardware and CANopenNode.
uint32_t OD_size_t
Variable of type OD_size_t contains data length in bytes of OD variable.
Definition CO_ODinterface.h:40
CO_SDO_state_t
Internal states of the SDO state machine.
Definition CO_SDOserver.h:90
CO_ReturnError_t CO_SDOserver_init(CO_SDOserver_t *SDO, OD_t *OD, OD_entry_t *OD_1200_SDOsrvPar, uint8_t nodeId, uint16_t SDOtimeoutTime_ms, CO_CANmodule_t *CANdevRx, uint16_t CANdevRxIdx, CO_CANmodule_t *CANdevTx, uint16_t CANdevTxIdx, uint32_t *errInfo)
Initialize SDO object.
Definition CO_SDOserver.c:254
CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t *SDO, bool_t NMTisPreOrOperational, uint32_t timeDifference_us, uint32_t *timerNext_us)
Process SDO communication.
Definition CO_SDOserver.c:592
void CO_SDOserver_initCallbackPre(CO_SDOserver_t *SDO, void *object, void(*pFunctSignalPre)(void *object))
Initialize SDOrx callback function.
CO_SDO_abortCode_t
SDO abort codes.
Definition CO_SDOserver.h:296
CO_SDO_return_t
Return values from SDO server or client functions.
Definition CO_SDOserver.h:341
@ CO_SDO_ST_UPLOAD_SEGMENT_RSP
Definition CO_SDOserver.h:173
@ CO_SDO_ST_IDLE
Definition CO_SDOserver.h:95
@ CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_REQ
Definition CO_SDOserver.h:197
@ CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_SREQ
Definition CO_SDOserver.h:257
@ CO_SDO_ST_DOWNLOAD_INITIATE_RSP
Definition CO_SDOserver.h:123
@ CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ
Definition CO_SDOserver.h:236
@ CO_SDO_ST_DOWNLOAD_BLK_INITIATE_REQ
Definition CO_SDOserver.h:181
@ CO_SDO_ST_DOWNLOAD_SEGMENT_REQ
Definition CO_SDOserver.h:130
@ CO_SDO_ST_DOWNLOAD_BLK_SUBBLOCK_RSP
Definition CO_SDOserver.h:210
@ CO_SDO_ST_DOWNLOAD_LOCAL_TRANSFER
Definition CO_SDOserver.h:107
@ CO_SDO_ST_UPLOAD_BLK_END_SREQ
Definition CO_SDOserver.h:277
@ CO_SDO_ST_UPLOAD_LOCAL_TRANSFER
Definition CO_SDOserver.h:143
@ CO_SDO_ST_UPLOAD_INITIATE_RSP
Definition CO_SDOserver.h:159
@ CO_SDO_ST_UPLOAD_INITIATE_REQ
Definition CO_SDOserver.h:150
@ CO_SDO_ST_UPLOAD_BLK_END_CRSP
Definition CO_SDOserver.h:286
@ CO_SDO_ST_DOWNLOAD_INITIATE_REQ
Definition CO_SDOserver.h:115
@ CO_SDO_ST_ABORT
Definition CO_SDOserver.h:101
@ CO_SDO_ST_UPLOAD_BLK_INITIATE_REQ2
Definition CO_SDOserver.h:250
@ CO_SDO_ST_UPLOAD_SEGMENT_REQ
Definition CO_SDOserver.h:165
@ CO_SDO_ST_DOWNLOAD_SEGMENT_RSP
Definition CO_SDOserver.h:137
@ CO_SDO_ST_UPLOAD_BLK_INITIATE_RSP
Definition CO_SDOserver.h:244
@ CO_SDO_ST_DOWNLOAD_BLK_INITIATE_RSP
Definition CO_SDOserver.h:190
@ CO_SDO_ST_DOWNLOAD_BLK_END_RSP
Definition CO_SDOserver.h:225
@ CO_SDO_ST_UPLOAD_BLK_SUBBLOCK_CRSP
Definition CO_SDOserver.h:270
@ CO_SDO_ST_DOWNLOAD_BLK_END_REQ
Definition CO_SDOserver.h:217
@ CO_SDO_AB_TIMEOUT
0x05040000, SDO protocol timed out
Definition CO_SDOserver.h:299
@ CO_SDO_AB_HW
0x06060000, Access failed due to hardware error
Definition CO_SDOserver.h:314
@ CO_SDO_AB_MAP_LEN
0x06040042, Number and length of object to be mapped exceeds PDO length
Definition CO_SDOserver.h:310
@ CO_SDO_AB_MAX_LESS_MIN
0x06090036, Maximum value is less than minimum value.
Definition CO_SDOserver.h:325
@ CO_SDO_AB_CMD
0x05040001, Command specifier not valid or unknown
Definition CO_SDOserver.h:300
@ CO_SDO_AB_UNSUPPORTED_ACCESS
0x06010000, Unsupported access to an object
Definition CO_SDOserver.h:305
@ CO_SDO_AB_NO_DATA
0x08000024, No data available
Definition CO_SDOserver.h:335
@ CO_SDO_AB_SUB_UNKNOWN
0x06090011, Sub index does not exist
Definition CO_SDOserver.h:321
@ CO_SDO_AB_WRITEONLY
0x06010001, Attempt to read a write only object
Definition CO_SDOserver.h:306
@ CO_SDO_AB_DATA_SHORT
0x06070013, Data type does not match, length of service parameter too short
Definition CO_SDOserver.h:319
@ CO_SDO_AB_READONLY
0x06010002, Attempt to write a read only object
Definition CO_SDOserver.h:307
@ CO_SDO_AB_VALUE_HIGH
0x06090031, Value range of parameter written too high
Definition CO_SDOserver.h:323
@ CO_SDO_AB_DATA_LONG
0x06070012, Data type does not match, length of service parameter too high
Definition CO_SDOserver.h:317
@ CO_SDO_AB_GENERAL
0x08000000, General error
Definition CO_SDOserver.h:327
@ CO_SDO_AB_NONE
0x00000000, No abort
Definition CO_SDOserver.h:297
@ CO_SDO_AB_DATA_TRANSF
0x08000020, Data cannot be transferred or stored to application
Definition CO_SDOserver.h:328
@ CO_SDO_AB_NOT_EXIST
0x06020000, Object does not exist in the object dictionary
Definition CO_SDOserver.h:308
@ CO_SDO_AB_NO_MAP
0x06040041, Object cannot be mapped to the PDO
Definition CO_SDOserver.h:309
@ CO_SDO_AB_SEQ_NUM
0x05040003, Invalid sequence number in block mode
Definition CO_SDOserver.h:302
@ CO_SDO_AB_TYPE_MISMATCH
0x06070010, Data type does not match, length of service parameter does not match
Definition CO_SDOserver.h:315
@ CO_SDO_AB_VALUE_LOW
0x06090032, Value range of parameter written too low
Definition CO_SDOserver.h:324
@ CO_SDO_AB_NO_RESOURCE
0x060A0023, Resource not available: SDO connection
Definition CO_SDOserver.h:326
@ CO_SDO_AB_DATA_LOC_CTRL
0x08000021, Data cannot be transferred or stored to application because of local control
Definition CO_SDOserver.h:329
@ CO_SDO_AB_BLOCK_SIZE
0x05040002, Invalid block size in block mode
Definition CO_SDOserver.h:301
@ CO_SDO_AB_DATA_DEV_STATE
0x08000022, Data cannot be transferred or stored to application because of present device state
Definition CO_SDOserver.h:331
@ CO_SDO_AB_PRAM_INCOMPAT
0x06040043, General parameter incompatibility reasons
Definition CO_SDOserver.h:312
@ CO_SDO_AB_DEVICE_INCOMPAT
0x06040047, General internal incompatibility in device
Definition CO_SDOserver.h:313
@ CO_SDO_AB_TOGGLE_BIT
0x05030000, Toggle bit not altered
Definition CO_SDOserver.h:298
@ CO_SDO_AB_OUT_OF_MEM
0x05040005, Out of memory
Definition CO_SDOserver.h:304
@ CO_SDO_AB_DATA_OD
0x08000023, Object dictionary not present or dynamic generation fails
Definition CO_SDOserver.h:333
@ CO_SDO_AB_CRC
0x05040004, CRC error (block mode only)
Definition CO_SDOserver.h:303
@ CO_SDO_AB_INVALID_VALUE
0x06090030, Invalid value for parameter (download only).
Definition CO_SDOserver.h:322
@ CO_SDO_RT_waitingResponse
Waiting server or client response.
Definition CO_SDOserver.h:349
@ CO_SDO_RT_ok_communicationEnd
Success, end of communication.
Definition CO_SDOserver.h:350
@ CO_SDO_RT_endedWithClientAbort
Communication ended with client abort.
Definition CO_SDOserver.h:352
@ CO_SDO_RT_blockDownldInProgress
Block download is in progress.
Definition CO_SDOserver.h:346
@ CO_SDO_RT_waitingLocalTransfer
Waiting in client local transfer.
Definition CO_SDOserver.h:342
@ CO_SDO_RT_transmittBufferFull
CAN transmit buffer is full.
Definition CO_SDOserver.h:345
@ CO_SDO_RT_blockUploadInProgress
Block upload is in progress.
Definition CO_SDOserver.h:347
@ CO_SDO_RT_uploadDataBufferFull
Data buffer is full.
Definition CO_SDOserver.h:343
@ CO_SDO_RT_endedWithServerAbort
Communication ended with server abort.
Definition CO_SDOserver.h:353
@ CO_SDO_RT_wrongArguments
Error in arguments.
Definition CO_SDOserver.h:351
#define CO_CONFIG_SDO_SRV_BUFFER_SIZE
Size of the internal data buffer for the SDO server.
Definition CO_config.h:371
unsigned int uint16_t
UNSIGNED16 in CANopen (0006h), 16-bit unsigned integer.
Definition CO_driver.h:132
unsigned long int uint32_t
UNSIGNED32 in CANopen (0007h), 32-bit unsigned integer.
Definition CO_driver.h:133
uint_fast8_t bool_t
Boolean data type for general use.
Definition CO_driver.h:126
unsigned char uint8_t
UNSIGNED8 in CANopen (0005h), 8-bit unsigned integer.
Definition CO_driver.h:131
CO_ReturnError_t
Return values of some CANopen functions.
Definition CO_driver.h:449
Complete CAN module object.
Definition CO_driver.h:268
Configuration object for CAN transmit message for specific CANopenNode Object.
Definition CO_driver.h:250
SDO server object.
Definition CO_SDOserver.h:359
uint32_t SDOtimeoutTime_us
Maximum timeout time between request and response in microseconds.
Definition CO_SDOserver.h:390
volatile CO_SDO_state_t state
Internal state of the SDO server.
Definition CO_SDOserver.h:365
uint8_t toggle
Toggle bit toggled in each segment in segmented transfer.
Definition CO_SDOserver.h:387
OD_IO_t OD_IO
Object dictionary interface for current object.
Definition CO_SDOserver.h:366
uint16_t block_crc
Calculated CRC checksum.
Definition CO_SDOserver.h:404
CO_CANtx_t * CANtxBuff
CAN transmit buffer inside CANdevTx for CAN tx message.
Definition CO_SDOserver.h:361
uint8_t nodeId
From CO_SDOserver_init()
Definition CO_SDOserver.h:363
OD_t * OD
From CO_SDOserver_init()
Definition CO_SDOserver.h:362
CO_CANmodule_t * CANdevRx
From CO_SDOserver_init()
Definition CO_SDOserver.h:373
uint32_t COB_IDServerToClient
Copy of CANopen COB_ID Server -> Client, similar as above.
Definition CO_SDOserver.h:380
volatile void * CANrxNew
Indicates, if new SDO message received from CAN bus.
Definition CO_SDOserver.h:369
uint8_t subIndex
Subindex of the current object in Object Dictionary.
Definition CO_SDOserver.h:368
uint8_t block_noData
Number of bytes in last segment that do not contain data.
Definition CO_SDOserver.h:402
uint32_t timeoutTimer
Timeout timer for SDO communication.
Definition CO_SDOserver.h:391
OD_size_t bufOffsetWr
Offset of next free data byte available for write in the buffer.
Definition CO_SDOserver.h:394
uint8_t block_blksize
Number of segments per block, 1..127.
Definition CO_SDOserver.h:401
uint32_t COB_IDClientToServer
Copy of CANopen COB_ID Client -> Server, meaning of the specific bits:
Definition CO_SDOserver.h:376
OD_size_t sizeTran
Size of data which is actually transferred.
Definition CO_SDOserver.h:386
uint16_t CANdevRxIdx
From CO_SDOserver_init()
Definition CO_SDOserver.h:374
bool_t finished
If true, then: data transfer is finished (by download) or read from OD variable is finished (by uploa...
Definition CO_SDOserver.h:388
OD_size_t bufOffsetRd
Offset of first data available for read in the buffer.
Definition CO_SDOserver.h:395
OD_size_t sizeInd
Size of data, which will be transferred.
Definition CO_SDOserver.h:384
bool_t block_crcEnabled
Client CRC support in block transfer.
Definition CO_SDOserver.h:403
uint16_t CANdevTxIdx
From CO_SDOserver_init()
Definition CO_SDOserver.h:375
uint32_t block_timeoutTimer
Timeout timer for SDO sub-block download.
Definition CO_SDOserver.h:399
void * functSignalObjectPre
From CO_SDOserver_initCallbackPre() or NULL.
Definition CO_SDOserver.h:408
CO_CANmodule_t * CANdevTx
From CO_SDOserver_init()
Definition CO_SDOserver.h:360
OD_extension_t OD_1200_extension
Extension for OD object.
Definition CO_SDOserver.h:381
uint16_t index
Index of the current object in Object Dictionary.
Definition CO_SDOserver.h:367
uint32_t block_SDOtimeoutTime_us
Timeout time for SDO sub-block download, half of SDOtimeoutTime_us.
Definition CO_SDOserver.h:398
uint8_t block_seqno
Sequence number of segment in block, 1..127.
Definition CO_SDOserver.h:400
bool_t valid
If true, SDO channel is valid.
Definition CO_SDOserver.h:364
Structure for input / output on the OD variable.
Definition CO_ODinterface.h:181
Object Dictionary entry for one OD object.
Definition CO_ODinterface.h:272
Extension of OD object, which can optionally be specified by application in initialization phase with...
Definition CO_ODinterface.h:245
Object Dictionary.
Definition CO_ODinterface.h:284