libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
coe.h
Go to the documentation of this file.
1
13/*
14 * This file is part of libethercat.
15 *
16 * libethercat is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 3 of the License, or (at your option) any later version.
20 *
21 * libethercat is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with libethercat (LICENSE.LGPL-V3); if not, write
28 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
29 * Floor, Boston, MA 02110-1301, USA.
30 *
31 * Please note that the use of the EtherCAT technology, the EtherCAT
32 * brand name and the EtherCAT logo is only permitted if the property
33 * rights of Beckhoff Automation GmbH are observed. For further
34 * information please contact Beckhoff Automation GmbH & Co. KG,
35 * Hülshorstweg 20, D-33415 Verl, Germany (www.beckhoff.com) or the
36 * EtherCAT Technology Group, Ostendstraße 196, D-90482 Nuremberg,
37 * Germany (ETG, www.ethercat.org).
38 *
39 */
40
41#ifndef LIBETHERCAT_COE_H
42#define LIBETHERCAT_COE_H
43
44#include <libosal/types.h>
45#include <libosal/mutex.h>
46
47#include "libethercat/common.h"
48#include "libethercat/idx.h"
49#include "libethercat/pool.h"
50
64
78
80enum {
89};
90
92enum {
97};
98
100enum {
108};
109
111enum {
112 DEFTYPE_NULL = 0x0000,
113 DEFTYPE_BOOLEAN = 0x0001,
114 DEFTYPE_INTEGER8 = 0x0002,
115 DEFTYPE_INTEGER16 = 0x0003,
116 DEFTYPE_INTEGER32 = 0x0004,
117 DEFTYPE_UNSIGNED8 = 0x0005,
118 DEFTYPE_UNSIGNED16 = 0x0006,
119 DEFTYPE_UNSIGNED32 = 0x0007,
120 DEFTYPE_REAL32 = 0x0008,
121 DEFTYPE_VISIBLESTRING = 0x0009,
122 DEFTYPE_OCTETSTRING = 0x000A,
123 DEFTYPE_UNICODE_STRING = 0x000B,
124 DEFTYPE_TIME_OF_DAY = 0x000C,
125 DEFTYPE_TIME_DIFFERENCE = 0x000D,
126 DEFTYPE_INTEGER24 = 0x0010,
127 DEFTYPE_REAL64 = 0x0011,
128 DEFTYPE_INTEGER40 = 0x0012,
129 DEFTYPE_INTEGER48 = 0x0013,
130 DEFTYPE_INTEGER56 = 0x0014,
131 DEFTYPE_INTEGER64 = 0x0015,
132 DEFTYPE_UNSIGNED24 = 0x0016,
133 DEFTYPE_UNSIGNED40 = 0x0018,
134 DEFTYPE_UNSIGNED48 = 0x0019,
135 DEFTYPE_UNSIGNED56 = 0x001A,
136 DEFTYPE_UNSIGNED64 = 0x001B,
137 DEFTYPE_GUID = 0x001D,
138 DEFTYPE_BYTE = 0x001E,
139 DEFTYPE_WORD = 0x001F,
140 DEFTYPE_DWORD = 0x0020,
141 DEFTYPE_PDOMAPPING = 0x0021,
142 DEFTYPE_IDENTITY = 0x0023,
143 DEFTYPE_COMMAND = 0x0025,
144 DEFTYPE_PDOCOMPAR = 0x0027,
145 DEFTYPE_ENUM = 0x0028,
146 DEFTYPE_SMPAR = 0x0029,
147 DEFTYPE_RECORD = 0x002A,
148 DEFTYPE_BACKUP = 0x002B,
149 DEFTYPE_MDP = 0x002C,
150 DEFTYPE_BITARR8 = 0x002D,
151 DEFTYPE_BITARR16 = 0x002E,
152 DEFTYPE_BITARR32 = 0x002F,
153 DEFTYPE_BIT1 = 0x0030,
154 DEFTYPE_BIT2 = 0x0031,
155 DEFTYPE_BIT3 = 0x0032,
156 DEFTYPE_BIT4 = 0x0033,
157 DEFTYPE_BIT5 = 0x0034,
158 DEFTYPE_BIT6 = 0x0035,
159 DEFTYPE_BIT7 = 0x0036,
160 DEFTYPE_BIT8 = 0x0037,
161 DEFTYPE_ARRAY_OF_INT = 0x0260,
162 DEFTYPE_ARRAY_OF_SINT = 0x0261,
163 DEFTYPE_ARRAY_OF_DINT = 0x0262,
164 DEFTYPE_ARRAY_OF_UDINT = 0x0263,
165 DEFTYPE_ERRORHANDLING = 0x0281,
166 DEFTYPE_DIAGHISTORY = 0x0282,
167 DEFTYPE_SYNCSTATUS = 0x0283,
168 DEFTYPE_SYNCSETTINGS = 0x0284,
169 DEFTYPE_FSOEFRAME = 0x0285,
170 DEFTYPE_FSOECOMMPAR = 0x0286,
171};
172
173enum {
174 OBJCODE_VAR = 0x07,
175 OBJCODE_ARR = 0x08,
176 OBJCODE_REC = 0x09,
177};
178
179enum {
181 ACCESS_READ = 0x0007,
184 ACCESS_READ_OP = 0x0004,
185 ACCESS_WRITE = 0x0038,
189};
190
191#define CANOPEN_MAXNAME (40u)
192#define CANOPEN_MAXDATA (128u)
193
195typedef struct PACKED ec_coe_sdo_desc {
196 osal_uint16_t data_type;
197 osal_uint8_t obj_code;
198 osal_uint8_t max_subindices;
199 osal_char_t name[CANOPEN_MAXNAME];
200 osal_size_t name_len;
202
203typedef struct PACKED ec_coe_sdo_entry_desc {
204 osal_uint8_t value_info;
205 osal_uint16_t data_type;
206 osal_uint16_t bit_length;
207 osal_uint16_t obj_access;
208 osal_uint8_t data[CANOPEN_MAXDATA];
209 osal_size_t data_len;
211
212#define EC_COE_SDO_VALUE_INFO_ACCESS_RIGHTS (0x01)
213#define EC_COE_SDO_VALUE_INFO_OBJECT_CATEGORY (0x02)
214#define EC_COE_SDO_VALUE_INFO_MAPPABLE (0x04)
215#define EC_COE_SDO_VALUE_INFO_UNIT (0x08)
216#define EC_COE_SDO_VALUE_INFO_DEFAULT_VALUE (0x10)
217#define EC_COE_SDO_VALUE_INFO_MIN_VALUE (0x20)
218#define EC_COE_SDO_VALUE_INFO_MAX_VALUE (0x40)
219
220// forward declarations
221struct ec;
222typedef struct ec ec_t;
223
224#ifdef __cplusplus
225extern "C" {
226#endif
227
229
236void ec_coe_init(ec_t *pec, osal_uint16_t slave);
237
239
246void ec_coe_deinit(ec_t *pec, osal_uint16_t slave);
247
249
274int ec_coe_sdo_read(ec_t *pec, osal_uint16_t slave, osal_uint16_t index,
275 osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t *len,
276 osal_uint32_t *abort_code);
277
279
296int ec_coe_master_sdo_read(ec_t *pec, osal_uint16_t index,
297 osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t *len,
298 osal_uint32_t *abort_code);
299
301
322int ec_coe_sdo_write(ec_t *pec, osal_uint16_t slave, osal_uint16_t index,
323 osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t len,
324 osal_uint32_t *abort_code);
325
327
341int ec_coe_master_sdo_write(ec_t *pec, osal_uint16_t index,
342 osal_uint8_t sub_index, int complete, osal_uint8_t *buf, osal_size_t len,
343 osal_uint32_t *abort_code);
344
346
363int ec_coe_sdo_desc_read(ec_t *pec, osal_uint16_t slave, osal_uint16_t index,
364 ec_coe_sdo_desc_t *desc, osal_uint32_t *error_code);
365
367
378int ec_coe_master_sdo_desc_read(const ec_t *pec, osal_uint16_t index,
379 ec_coe_sdo_desc_t *desc, osal_uint32_t *error_code);
380
382
401int ec_coe_sdo_entry_desc_read(ec_t *pec, osal_uint16_t slave, osal_uint16_t index,
402 osal_uint8_t sub_index, osal_uint8_t value_info, ec_coe_sdo_entry_desc_t *desc,
403 osal_uint32_t *error_code);
404
406
419int ec_coe_master_sdo_entry_desc_read(const ec_t *pec, osal_uint16_t index,
420 osal_uint8_t sub_index, osal_uint8_t value_info, ec_coe_sdo_entry_desc_t *desc,
421 osal_uint32_t *error_code);
422
424
440int ec_coe_odlist_read(ec_t *pec, osal_uint16_t slave, osal_uint8_t *buf, osal_size_t *len);
441
443
454int ec_coe_master_odlist_read(ec_t *pec, osal_uint8_t *buf, osal_size_t *len);
455
457
472int ec_coe_generate_mapping(ec_t *pec, osal_uint16_t slave);
473
475
480void ec_coe_emergency_enqueue(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry);
481
483
490int ec_coe_emergency_get_next(ec_t *pec, osal_uint16_t slave, ec_coe_emergency_message_t *msg);
491
493
505void ec_coe_enqueue(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry);
506
508
512const osal_char_t *get_sdo_info_error_string(osal_uint32_t errorcode);
513
514#ifdef __cplusplus
515}
516#endif
517
520#endif // LIBETHERCAT_COE_H
521
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:192
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:191
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:83
@ EC_COE_SDOREQ
service data object request
Definition coe.h:82
@ EC_COE_TXPDO
transmit PDO
Definition coe.h:84
@ EC_COE_SDOINFO
service data object information
Definition coe.h:88
@ EC_COE_RXPDO
receive PDO
Definition coe.h:85
@ EC_COE_RXPDO_RR
receive PDO RR
Definition coe.h:87
@ EC_COE_EMERGENCY
emergency message
Definition coe.h:81
@ EC_COE_TXPDO_RR
transmit PDO RR
Definition coe.h:86
@ ACCESS_WRITE_PREOP
Write only in PreOP.
Definition coe.h:186
@ ACCESS_WRITE_OP
Write only in OP.
Definition coe.h:188
@ ACCESS_READ_OP
Read only in OP.
Definition coe.h:184
@ ACCESS_WRITE_SAFEOP
Write only in SafeOP.
Definition coe.h:187
@ ACCESS_READ_PREOP
Read only in PreOP.
Definition coe.h:182
@ ACCESS_WRITE
Write only in all states.
Definition coe.h:185
@ ACCESS_READ
Read only in all states.
Definition coe.h:181
@ ACCESS_READ_SAFEOP
Read only in SafeOP.
Definition coe.h:183
@ ACCESS_READWRITE
Read/write in all states.
Definition coe.h:180
@ EC_COE_SDO_INFO_ERROR_REQUEST
error request
Definition coe.h:107
@ EC_COE_SDO_INFO_ODLIST_RESP
object dict list response
Definition coe.h:102
@ EC_COE_SDO_INFO_ODLIST_REQ
object dict list request
Definition coe.h:101
@ EC_COE_SDO_INFO_GET_OBJECT_DESC_RESP
object description response
Definition coe.h:104
@ EC_COE_SDO_INFO_GET_ENTRY_DESC_REQ
entry description request
Definition coe.h:105
@ EC_COE_SDO_INFO_GET_ENTRY_DESC_RESP
entry description response
Definition coe.h:106
@ EC_COE_SDO_INFO_GET_OBJECT_DESC_REQ
object description request
Definition coe.h:103
@ OBJCODE_REC
Object code RECORD.
Definition coe.h:176
@ OBJCODE_VAR
Object code VARIABLE.
Definition coe.h:174
@ OBJCODE_ARR
Object code ARRAY.
Definition coe.h:175
@ EC_COE_SDO_UPLOAD_REQ
sdo upload request
Definition coe.h:95
@ EC_COE_SDO_ABORT_REQ
sdo abort request
Definition coe.h:96
@ EC_COE_SDO_DOWNLOAD_REQ
sdo download request
Definition coe.h:94
@ EC_COE_SDO_DOWNLOAD_SEQ_REQ
sdo download seq request
Definition coe.h:93
ethercat index
Data pool implementation.
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:195
osal_uint8_t obj_code
object type
Definition coe.h:197
osal_uint8_t max_subindices
maximum number of subindices
Definition coe.h:198
osal_size_t name_len
element name len
Definition coe.h:200
osal_uint16_t data_type
element data type
Definition coe.h:196
Definition coe.h:203
osal_size_t data_len
length of name
Definition coe.h:209
osal_uint8_t value_info
valueinfo, how to interpret data
Definition coe.h:204
osal_uint16_t data_type
entry data type
Definition coe.h:205
osal_uint16_t bit_length
entry bit length
Definition coe.h:206
osal_uint16_t obj_access
object access
Definition coe.h:207
Definition coe.h:65
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:188
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:81