41#ifndef LIBETHERCAT_COE_H
42#define LIBETHERCAT_COE_H
44#include <libosal/types.h>
45#include <libosal/mutex.h>
81 osal_uint16_t number : 9;
82 osal_uint16_t reserved : 3;
83 osal_uint16_t service : 4;
87 osal_uint8_t size_indicator : 1;
88 osal_uint8_t transfer_type : 1;
89 osal_uint8_t data_set_size : 2;
90 osal_uint8_t complete : 1;
91 osal_uint8_t command : 3;
93 osal_uint8_t sub_index;
94}
PACKED ec_sdo_init_download_header_t;
130 DEFTYPE_NULL = 0x0000,
131 DEFTYPE_BOOLEAN = 0x0001,
132 DEFTYPE_INTEGER8 = 0x0002,
133 DEFTYPE_INTEGER16 = 0x0003,
134 DEFTYPE_INTEGER32 = 0x0004,
135 DEFTYPE_UNSIGNED8 = 0x0005,
136 DEFTYPE_UNSIGNED16 = 0x0006,
137 DEFTYPE_UNSIGNED32 = 0x0007,
138 DEFTYPE_REAL32 = 0x0008,
139 DEFTYPE_VISIBLESTRING = 0x0009,
140 DEFTYPE_OCTETSTRING = 0x000A,
141 DEFTYPE_UNICODE_STRING = 0x000B,
142 DEFTYPE_TIME_OF_DAY = 0x000C,
143 DEFTYPE_TIME_DIFFERENCE = 0x000D,
144 DEFTYPE_INTEGER24 = 0x0010,
145 DEFTYPE_REAL64 = 0x0011,
146 DEFTYPE_INTEGER40 = 0x0012,
147 DEFTYPE_INTEGER48 = 0x0013,
148 DEFTYPE_INTEGER56 = 0x0014,
149 DEFTYPE_INTEGER64 = 0x0015,
150 DEFTYPE_UNSIGNED24 = 0x0016,
151 DEFTYPE_UNSIGNED40 = 0x0018,
152 DEFTYPE_UNSIGNED48 = 0x0019,
153 DEFTYPE_UNSIGNED56 = 0x001A,
154 DEFTYPE_UNSIGNED64 = 0x001B,
155 DEFTYPE_GUID = 0x001D,
156 DEFTYPE_BYTE = 0x001E,
157 DEFTYPE_WORD = 0x001F,
158 DEFTYPE_DWORD = 0x0020,
159 DEFTYPE_PDOMAPPING = 0x0021,
160 DEFTYPE_IDENTITY = 0x0023,
161 DEFTYPE_COMMAND = 0x0025,
162 DEFTYPE_PDOCOMPAR = 0x0027,
163 DEFTYPE_ENUM = 0x0028,
164 DEFTYPE_SMPAR = 0x0029,
165 DEFTYPE_RECORD = 0x002A,
166 DEFTYPE_BACKUP = 0x002B,
167 DEFTYPE_MDP = 0x002C,
168 DEFTYPE_BITARR8 = 0x002D,
169 DEFTYPE_BITARR16 = 0x002E,
170 DEFTYPE_BITARR32 = 0x002F,
171 DEFTYPE_BIT1 = 0x0030,
172 DEFTYPE_BIT2 = 0x0031,
173 DEFTYPE_BIT3 = 0x0032,
174 DEFTYPE_BIT4 = 0x0033,
175 DEFTYPE_BIT5 = 0x0034,
176 DEFTYPE_BIT6 = 0x0035,
177 DEFTYPE_BIT7 = 0x0036,
178 DEFTYPE_BIT8 = 0x0037,
179 DEFTYPE_ARRAY_OF_INT = 0x0260,
180 DEFTYPE_ARRAY_OF_SINT = 0x0261,
181 DEFTYPE_ARRAY_OF_DINT = 0x0262,
182 DEFTYPE_ARRAY_OF_UDINT = 0x0263,
183 DEFTYPE_ERRORHANDLING = 0x0281,
184 DEFTYPE_DIAGHISTORY = 0x0282,
185 DEFTYPE_SYNCSTATUS = 0x0283,
186 DEFTYPE_SYNCSETTINGS = 0x0284,
187 DEFTYPE_FSOEFRAME = 0x0285,
188 DEFTYPE_FSOECOMMPAR = 0x0286,
209#define CANOPEN_MAXNAME (40u)
210#define CANOPEN_MAXDATA (128u)
230#define EC_COE_SDO_VALUE_INFO_ACCESS_RIGHTS (0x01)
231#define EC_COE_SDO_VALUE_INFO_OBJECT_CATEGORY (0x02)
232#define EC_COE_SDO_VALUE_INFO_MAPPABLE (0x04)
233#define EC_COE_SDO_VALUE_INFO_UNIT (0x08)
234#define EC_COE_SDO_VALUE_INFO_DEFAULT_VALUE (0x10)
235#define EC_COE_SDO_VALUE_INFO_MIN_VALUE (0x20)
236#define EC_COE_SDO_VALUE_INFO_MAX_VALUE (0x40)
293 osal_uint8_t sub_index,
int complete, osal_uint8_t *buf, osal_size_t *len,
294 osal_uint32_t *abort_code);
315 osal_uint8_t sub_index,
int complete, osal_uint8_t *buf, osal_size_t *len,
316 osal_uint32_t *abort_code);
341 osal_uint8_t sub_index,
int complete, osal_uint8_t *buf, osal_size_t len,
342 osal_uint32_t *abort_code);
360 osal_uint8_t sub_index,
int complete, osal_uint8_t *buf, osal_size_t len,
361 osal_uint32_t *abort_code);
421 osal_uint32_t *error_code);
439 osal_uint32_t *error_code);
ethercat master common stuff
#define LEC_MAX_COE_EMERGENCY_MSG_LEN
Maximum message length of CoE emergency messages.
Definition common.h:199
#define LEC_MAX_COE_EMERGENCIES
Maximum number of CoE emergency messages.
Definition common.h:191
int ec_coe_master_sdo_desc_read(const ec_t *pec, osal_uint16_t index, ec_coe_sdo_desc_t *desc, osal_uint32_t *error_code)
Read CoE SDO description of master.
int ec_coe_sdo_write(ec_t *pec, osal_uint16_t slave, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t len, osal_uint32_t *abort_code)
Write CoE service data object (SDO)
void ec_coe_deinit(ec_t *pec, osal_uint16_t slave)
deinitialize CoE structure
int ec_coe_emergency_get_next(ec_t *pec, osal_uint16_t slave, ec_coe_emergency_message_t *msg)
Get next CoE emergency message.
#define CANOPEN_MAXDATA
CANOPEN maximum data length.
Definition coe.h:210
int ec_coe_master_odlist_read(ec_t *pec, osal_uint8_t *buf, osal_size_t *len)
Read CoE object dictionary list of master.
int ec_coe_master_sdo_write(ec_t *pec, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t len, osal_uint32_t *abort_code)
Write CoE service data object (SDO) of master.
struct PACKED ec_coe_sdo_entry_desc ec_coe_sdo_entry_desc_t
CoE SDO entry description type.
int ec_coe_odlist_read(ec_t *pec, osal_uint16_t slave, osal_uint8_t *buf, osal_size_t *len)
Read CoE object dictionary list.
#define CANOPEN_MAXNAME
CANOPEN maximum name length.
Definition coe.h:209
struct PACKED ec_coe_sdo_desc ec_coe_sdo_desc_t
CanOpen over EtherCAT sdo descriptor.
struct ec_coe ec_coe_t
CoE type.
int ec_coe_master_sdo_read(ec_t *pec, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t *len, osal_uint32_t *abort_code)
Read CoE service data object (SDO) of master.
void ec_coe_emergency_enqueue(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
queue read mailbox content
int ec_coe_generate_mapping(ec_t *pec, osal_uint16_t slave)
generate sync manager process data mapping via coe
struct ec_coe_emergency_message ec_coe_emergency_message_t
Message queue qentry.
int ec_coe_master_sdo_entry_desc_read(const ec_t *pec, osal_uint16_t index, osal_uint8_t sub_index, osal_uint8_t value_info, ec_coe_sdo_entry_desc_t *desc, osal_uint32_t *error_code)
Read CoE SDO entry description of master.
int ec_coe_sdo_read(ec_t *pec, osal_uint16_t slave, osal_uint16_t index, osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t *len, osal_uint32_t *abort_code)
Read CoE service data object (SDO)
void ec_coe_init(ec_t *pec, osal_uint16_t slave)
Initialize CoE structure.
int ec_coe_sdo_desc_read(ec_t *pec, osal_uint16_t slave, osal_uint16_t index, ec_coe_sdo_desc_t *desc, osal_uint32_t *error_code)
Read CoE SDO description.
void ec_coe_enqueue(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
Enqueue CoE message received from slave.
const osal_char_t * get_sdo_info_error_string(osal_uint32_t errorcode)
Get SDO INFO error string.
int ec_coe_sdo_entry_desc_read(ec_t *pec, osal_uint16_t slave, osal_uint16_t index, osal_uint8_t sub_index, osal_uint8_t value_info, ec_coe_sdo_entry_desc_t *desc, osal_uint32_t *error_code)
Read CoE SDO entry description.
@ EC_COE_SDORES
service data object response
Definition coe.h:101
@ EC_COE_SDOREQ
service data object request
Definition coe.h:100
@ EC_COE_TXPDO
transmit PDO
Definition coe.h:102
@ EC_COE_SDOINFO
service data object information
Definition coe.h:106
@ EC_COE_RXPDO
receive PDO
Definition coe.h:103
@ EC_COE_RXPDO_RR
receive PDO RR
Definition coe.h:105
@ EC_COE_EMERGENCY
emergency message
Definition coe.h:99
@ EC_COE_TXPDO_RR
transmit PDO RR
Definition coe.h:104
@ ACCESS_WRITE_PREOP
Write only in PreOP.
Definition coe.h:204
@ ACCESS_WRITE_OP
Write only in OP.
Definition coe.h:206
@ ACCESS_READ_OP
Read only in OP.
Definition coe.h:202
@ ACCESS_WRITE_SAFEOP
Write only in SafeOP.
Definition coe.h:205
@ ACCESS_READ_PREOP
Read only in PreOP.
Definition coe.h:200
@ ACCESS_WRITE
Write only in all states.
Definition coe.h:203
@ ACCESS_READ
Read only in all states.
Definition coe.h:199
@ ACCESS_READ_SAFEOP
Read only in SafeOP.
Definition coe.h:201
@ ACCESS_READWRITE
Read/write in all states.
Definition coe.h:198
@ EC_COE_SDO_INFO_ERROR_REQUEST
error request
Definition coe.h:125
@ EC_COE_SDO_INFO_ODLIST_RESP
object dict list response
Definition coe.h:120
@ EC_COE_SDO_INFO_ODLIST_REQ
object dict list request
Definition coe.h:119
@ EC_COE_SDO_INFO_GET_OBJECT_DESC_RESP
object description response
Definition coe.h:122
@ EC_COE_SDO_INFO_GET_ENTRY_DESC_REQ
entry description request
Definition coe.h:123
@ EC_COE_SDO_INFO_GET_ENTRY_DESC_RESP
entry description response
Definition coe.h:124
@ EC_COE_SDO_INFO_GET_OBJECT_DESC_REQ
object description request
Definition coe.h:121
@ OBJCODE_REC
Object code RECORD.
Definition coe.h:194
@ OBJCODE_VAR
Object code VARIABLE.
Definition coe.h:192
@ OBJCODE_ARR
Object code ARRAY.
Definition coe.h:193
@ EC_COE_SDO_UPLOAD_REQ
sdo upload request
Definition coe.h:113
@ EC_COE_SDO_ABORT_REQ
sdo abort request
Definition coe.h:114
@ EC_COE_SDO_DOWNLOAD_REQ
sdo download request
Definition coe.h:112
@ EC_COE_SDO_DOWNLOAD_SEQ_REQ
sdo download seq request
Definition coe.h:111
Data pool implementation.
CoE mailbox header.
Definition coe.h:80
Message queue qentry.
Definition coe.h:59
osal_timer_t timestamp
timestamp, when emergency was received
Definition coe.h:60
osal_size_t msg_len
length
Definition coe.h:61
osal_uint8_t msg[LEC_MAX_COE_EMERGENCY_MSG_LEN]
message itself
Definition coe.h:62
CanOpen over EtherCAT sdo descriptor.
Definition coe.h:213
osal_uint8_t obj_code
object type
Definition coe.h:215
osal_uint8_t max_subindices
maximum number of subindices
Definition coe.h:216
osal_size_t name_len
element name len
Definition coe.h:218
osal_uint16_t data_type
element data type
Definition coe.h:214
osal_size_t data_len
length of name
Definition coe.h:227
osal_uint8_t value_info
valueinfo, how to interpret data
Definition coe.h:222
osal_uint16_t data_type
entry data type
Definition coe.h:223
osal_uint16_t bit_length
entry bit length
Definition coe.h:224
osal_uint16_t obj_access
object access
Definition coe.h:225
pool_t recv_pool
receive CoE message pool
Definition coe.h:66
osal_mutex_t lock
CoE mailbox lock.
Definition coe.h:68
uint32_t emergency_next_read
next received emergency message in ring buffer
Definition coe.h:74
ec_coe_emergency_message_t emergencies[LEC_MAX_COE_EMERGENCIES]
emergency message ring buffer.
Definition coe.h:76
uint32_t emergency_next_write
next message in ring buffer to be written.
Definition coe.h:75
ethercat master structure
Definition ec.h:197
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:84