Go to the documentation of this file.
1 /*
2  * Simple Open EtherCAT Master Library
3  *
4  * File : ethercatmain.h
5  * Version : 1.3.0
6  * Date : 24-02-2013
7  * Copyright (C) 2005-2013 Speciaal Machinefabriek Ketels v.o.f.
8  * Copyright (C) 2005-2013 Arthur Ketels
9  * Copyright (C) 2008-2009 TU/e Technische Universiteit Eindhoven
10  *
11  * SOEM is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License version 2 as published by the Free
13  * Software Foundation.
14  *
15  * SOEM is distributed in the hope that it will be useful, but WITHOUT ANY
16  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18  * for more details.
19  *
20  * As a special exception, if other files instantiate templates or use macros
21  * or inline functions from this file, or you compile this file and link it
22  * with other works to produce a work based on this file, this file does not
23  * by itself cause the resulting work to be covered by the GNU General Public
24  * License. However the source code for this file must still be made available
25  * in accordance with section (3) of the GNU General Public License.
26  *
27  * This exception does not invalidate any other reasons why a work based on
28  * this file might be covered by the GNU General Public License.
29  *
30  * The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual
31  * property of, and protected by Beckhoff Automation GmbH. You can use SOEM for
32  * the sole purpose of creating, using and/or selling or otherwise distributing
33  * an EtherCAT network master provided that an EtherCAT Master License is obtained
34  * from Beckhoff Automation GmbH.
35  *
36  * In case you did not receive a copy of the EtherCAT Master License along with
37  * SOEM write to Beckhoff Automation GmbH, Eiserstrasse 5, D-33415 Verl, Germany
38  * (
39  */
46 #ifndef _ethercatmain_
47 #define _ethercatmain_
50 #ifdef __cplusplus
51 extern "C"
52 {
53 #endif
56 #define EC_MAXELIST 64
58 #define EC_MAXNAME 40
60 #define EC_MAXSLAVE 200
62 #define EC_MAXGROUP 2
64 #define EC_MAXIOSEGMENTS 64
66 #define EC_MAXMBX 0x3ff
68 #define EC_MAXEEPDO 0x200
70 #define EC_MAXSM 8
72 #define EC_MAXFMMU 4
76 typedef struct ec_adapter ec_adaptert;
77 struct ec_adapter
78 {
82 };
86 typedef struct PACKED
87 {
98 } ec_fmmut;
103 typedef struct PACKED
104 {
108 } ec_smt;
112 typedef struct PACKED
113 {
120 #define ECT_MBXPROT_AOE 0x0001
121 #define ECT_MBXPROT_EOE 0x0002
122 #define ECT_MBXPROT_COE 0x0004
123 #define ECT_MBXPROT_FOE 0x0008
124 #define ECT_MBXPROT_SOE 0x0010
125 #define ECT_MBXPROT_VOE 0x0020
127 #define ECT_COEDET_SDO 0x01
128 #define ECT_COEDET_SDOINFO 0x02
129 #define ECT_COEDET_PDOASSIGN 0x04
130 #define ECT_COEDET_PDOCONFIG 0x08
131 #define ECT_COEDET_UPLOAD 0x10
132 #define ECT_COEDET_SDOCA 0x20
134 #define EC_SMENABLEMASK 0xfffeffff
137 typedef struct
138 {
176  uint8 SMtype[EC_MAXSM];
200  boolean hasdc;
260  boolean islost;
262  int (*PO2SOconfig)(uint16 slave);
264  char name[EC_MAXNAME + 1];
265 } ec_slavet;
268 typedef struct
269 {
281  boolean hasdc;
299  boolean docheckstate;
302 } ec_groupt;
305 typedef struct
306 {
316 typedef struct
317 {
323  uint8 Sreg; /* dont care */
325  uint8 PDIctrl; /* dont care */
326 } ec_eepromSMt;
329 typedef struct
330 {
336  uint16 BitSize[EC_MAXEEPDO];
337  uint16 SMbitsize[EC_MAXSM];
338 } ec_eepromPDOt;
345 typedef struct PACKED
346 {
351 } ec_mbxheadert;
356 typedef struct PACKED
357 {
361 } ec_alstatust;
365 typedef struct
366 {
370  void *data[EC_MAXBUF];
371  uint16 length[EC_MAXBUF];
372 } ec_idxstackT;
375 typedef struct
376 {
380 } ec_eringt;
384 typedef struct PACKED
385 {
388  uint8 SMtype[EC_MAXSM];
389 } ec_SMcommtypet;
394 typedef struct PACKED
395 {
396  uint8 n;
397  uint8 nu1;
398  uint16 index[256];
399 } ec_PDOassignt;
404 typedef struct PACKED
405 {
406  uint8 n;
407  uint8 nu1;
408  uint32 PDO[256];
409 } ec_PDOdesct;
413 typedef struct
414 {
422  int maxslave;
426  int maxgroup;
438  boolean *ecaterror;
456  int (*FOEhook)(uint16 slave, int packetnumber, int datasize);
457 } ecx_contextt;
459 #ifdef EC_VER1
461 extern ecx_contextt ecx_context;
463 extern ec_slavet ec_slave[EC_MAXSLAVE];
465 extern int ec_slavecount;
467 extern ec_groupt ec_group[EC_MAXGROUP];
468 extern boolean EcatError;
469 extern int64 ec_DCtime;
471 void ec_pusherror(const ec_errort *Ec);
472 boolean ec_poperror(ec_errort *Ec);
473 boolean ec_iserror(void);
474 void ec_packeterror(uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode);
475 int ec_init(char * ifname);
476 int ec_init_redundant(char *ifname, char *if2name);
477 void ec_close(void);
478 uint8 ec_siigetbyte(uint16 slave, uint16 address);
479 int16 ec_siifind(uint16 slave, uint16 cat);
480 void ec_siistring(char *str, uint16 slave, uint16 Sn);
481 uint16 ec_siiFMMU(uint16 slave, ec_eepromFMMUt* FMMU);
482 uint16 ec_siiSM(uint16 slave, ec_eepromSMt* SM);
483 uint16 ec_siiSMnext(uint16 slave, ec_eepromSMt* SM, uint16 n);
484 int ec_siiPDO(uint16 slave, ec_eepromPDOt* PDO, uint8 t);
485 int ec_readstate(void);
486 int ec_writestate(uint16 slave);
487 uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout);
488 int ec_mbxempty(uint16 slave, int timeout);
489 int ec_mbxsend(uint16 slave,ec_mbxbuft *mbx, int timeout);
490 int ec_mbxreceive(uint16 slave, ec_mbxbuft *mbx, int timeout);
491 void ec_esidump(uint16 slave, uint8 *esibuf);
492 uint32 ec_readeeprom(uint16 slave, uint16 eeproma, int timeout);
493 int ec_writeeeprom(uint16 slave, uint16 eeproma, uint16 data, int timeout);
494 int ec_eeprom2master(uint16 slave);
495 int ec_eeprom2pdi(uint16 slave);
496 uint64 ec_readeepromAP(uint16 aiadr, uint16 eeproma, int timeout);
497 int ec_writeeepromAP(uint16 aiadr, uint16 eeproma, uint16 data, int timeout);
498 uint64 ec_readeepromFP(uint16 configadr, uint16 eeproma, int timeout);
499 int ec_writeeepromFP(uint16 configadr, uint16 eeproma, uint16 data, int timeout);
500 void ec_readeeprom1(uint16 slave, uint16 eeproma);
501 uint32 ec_readeeprom2(uint16 slave, int timeout);
502 int ec_send_processdata_group(uint8 group);
503 int ec_receive_processdata_group(uint8 group, int timeout);
504 int ec_send_processdata(void);
505 int ec_receive_processdata(int timeout);
506 #endif
509 void ec_free_adapters(ec_adaptert * adapter);
511 void ec_clearmbx(ec_mbxbuft *Mbx);
512 void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec);
513 boolean ecx_poperror(ecx_contextt *context, ec_errort *Ec);
514 boolean ecx_iserror(ecx_contextt *context);
515 void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode);
516 int ecx_init(ecx_contextt *context, char * ifname);
517 int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, char *ifname, char *if2name);
518 void ecx_close(ecx_contextt *context);
519 uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address);
520 int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat);
521 void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn);
522 uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt* FMMU);
523 uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM);
524 uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM, uint16 n);
525 int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t);
526 int ecx_readstate(ecx_contextt *context);
527 int ecx_writestate(ecx_contextt *context, uint16 slave);
528 uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout);
529 int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout);
530 int ecx_mbxsend(ecx_contextt *context, uint16 slave,ec_mbxbuft *mbx, int timeout);
531 int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout);
532 void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf);
533 uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout);
534 int ecx_writeeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, uint16 data, int timeout);
535 int ecx_eeprom2master(ecx_contextt *context, uint16 slave);
536 int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave);
537 uint64 ecx_readeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, int timeout);
538 int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout);
539 uint64 ecx_readeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, int timeout);
540 int ecx_writeeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, uint16 data, int timeout);
541 void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma);
542 uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout);
543 int ecx_send_processdata_group(ecx_contextt *context, uint8 group);
544 int ecx_receive_processdata_group(ecx_contextt *context, uint8 group, int timeout);
545 int ecx_send_processdata(ecx_contextt *context);
546 int ecx_receive_processdata(ecx_contextt *context, int timeout);
548 #ifdef __cplusplus
549 }
550 #endif
552 #endif
uint8 mbxtype
Definition: ethercatmain.h:350
uint16 mbx_rl
Definition: ethercatmain.h:192
void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn)
Definition: ethercatmain.c:474
#define EC_MAXMBX
Definition: ethercatmain.h:66
uint8 FMMU2func
Definition: ethercatmain.h:184
uint32 Obytes
Definition: ethercatmain.h:160
uint8 eep_pdi
Definition: ethercatmain.h:242
ec_eepromFMMUt * eepFMMU
Definition: ethercatmain.h:454
uint8 FMMUunused
Definition: ethercatmain.h:258
uint16 Ioffset
Definition: ethercatmain.h:293
Definition: ethercatmain.h:74
uint32 eep_id
Definition: ethercatmain.h:150
uint8 FoEdetails
Definition: ethercatmain.h:246
uint16 Plength
Definition: ethercatmain.h:321
ec_slavet * slavelist
Definition: ethercatmain.h:418
uint16 aliasadr
Definition: ethercatmain.h:146
uint16 unused
Definition: ethercatmain.h:359
uint16 unused2
Definition: ethercatmain.h:97
Definition: ethercatmain.h:62
void ecx_close(ecx_contextt *context)
Definition: ethercatmain.c:352
int ecx_receive_processdata(ecx_contextt *context, int timeout)
uint16 Ibits
Definition: ethercatmain.h:166
uint8 unused1
Definition: ethercatmain.h:96
uint8 topology
Definition: ethercatmain.h:204
int16 head
Definition: ethercatmain.h:377
Definition: ethercatmain.h:79
ec_groupt * grouplist
Definition: ethercatmain.h:424
#define EC_MAXBUF
Definition: ethercattype.h:88
int32 pdelay
Definition: ethercatmain.h:224
uint8_t uint8
Definition: osal.h:33
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n)
Definition: ethercatmain.c:609
uint8 * inputs
Definition: ethercatmain.h:170
uint16 mbx_l
Definition: ethercatmain.h:188
uint8 SoEdetails
Definition: ethercatmain.h:250
ec_adaptert * next
Definition: ethercatmain.h:81
int ecx_send_processdata_group(ecx_contextt *context, uint8 group)
void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec)
Definition: ethercatmain.c:188
void ec_clearmbx(ec_mbxbuft *Mbx)
Definition: ethercatmain.c:832
int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
uint32 Obytes
Definition: ethercatmain.h:273
uint16 Startpos
Definition: ethercatmain.h:318
uint8 group
Definition: ethercatmain.h:256
uint8 consumedports
Definition: ethercatmain.h:208
void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
Definition: ethercatmain.c:253
int ecx_init(ecx_contextt *context, char *ifname)
Definition: ethercatmain.c:319
uint16 DCprevious
Definition: ethercatmain.h:228
uint8 FMMU3func
Definition: ethercatmain.h:186
uint16_t uint16
Definition: osal.h:34
uint8 * outputs
Definition: ethercatmain.h:162
boolean ecx_iserror(ecx_contextt *context)
Definition: ethercatmain.c:240
uint16 Dtype
Definition: ethercatmain.h:156
uint8 Istartbit
Definition: ethercatmain.h:172
uint16 DCnext
Definition: ethercatmain.h:283
int ecx_receive_processdata_group(ecx_contextt *context, uint8 group, int timeout)
uint8 priority
Definition: ethercatmain.h:349
uint16 mbx_proto
Definition: ethercatmain.h:196
int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave)
uint16 State
Definition: ethercatmain.h:114
PACKED_END PACKED_BEGIN struct PACKED ec_state_status
Definition: ethercatmain.h:68
uint8 DCactive
Definition: ethercatmain.h:234
uint16 StartAddr
Definition: ethercatmain.h:105
uint64 ecx_readeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, int timeout)
#define EC_MAXSM
Definition: ethercatmain.h:70
uint16 parent
Definition: ethercatmain.h:210
Definition: ethercatmain.h:80
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
Definition: ethercatmain.c:773
boolean * ecaterror
Definition: ethercatmain.h:438
uint8 LogStartbit
Definition: ethercatmain.h:90
int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
Definition: ethercatmain.c:434
uint16 ALstatuscode
Definition: ethercatmain.h:142
uint64 ecx_readeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, int timeout)
uint16 Unused
Definition: ethercatmain.h:115
int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout)
Definition: ethercatmain.c:843
uint32 SMflags
Definition: ethercatmain.h:107
PACKED_BEGIN struct PACKED ec_mbxheadert
int ecx_writeeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, uint16 data, int timeout)
uint8 LogEndbit
Definition: ethercatmain.h:91
boolean islost
Definition: ethercatmain.h:260
int ecx_writestate(ecx_contextt *context, uint16 slave)
Definition: ethercatmain.c:747
uint8 n
Definition: ethercatmain.h:386
uint16 mbx_ro
Definition: ethercatmain.h:194
uint16 nsegments
Definition: ethercatmain.h:289
int32 DCrtA
Definition: ethercatmain.h:216
uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout)
boolean hasdc
Definition: ethercatmain.h:281
void ec_free_adapters(ec_adaptert *adapter)
Definition: ethercatmain.c:178
boolean docheckstate
Definition: ethercatmain.h:299
boolean hasdc
Definition: ethercatmain.h:200
uint16 SIIindex
Definition: ethercatmain.h:238
uint16 alstatus
Definition: ethercatmain.h:358
int64_t int64
Definition: osal.h:36
uint16 Isegment
Definition: ethercatmain.h:291
ecx_portt * port
Definition: ethercatmain.h:416
int ecx_writeeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, uint16 data, int timeout)
uint8 entryport
Definition: ethercatmain.h:214
int32_t int32
Definition: osal.h:32
uint16 Obits
Definition: ethercatmain.h:158
uint8 FMMU0func
Definition: ethercatmain.h:180
int32 DCrtD
Definition: ethercatmain.h:222
int64 * DCtime
Definition: ethercatmain.h:444
int32 DCrtC
Definition: ethercatmain.h:220
int ecx_readstate(ecx_contextt *context)
Definition: ethercatmain.c:714
ec_adaptert * ec_find_adapters(void)
Definition: ethercatmain.c:165
uint8 ec_nextmbxcnt(uint8 cnt)
Definition: ethercatmain.c:818
ec_idxstackT * idxstack
Definition: ethercatmain.h:436
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt *PDO, uint8 t)
Definition: ethercatmain.c:643
void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma)
uint16 SMlength
Definition: ethercatmain.h:106
Definition: ethercatmain.h:56
uint8 nu1
Definition: ethercatmain.h:387
uint64_t uint64
Definition: osal.h:37
uint8 mbx_cnt
Definition: ethercatmain.h:198
uint8 eep_8byte
Definition: ethercatmain.h:240
int ecx_mbxsend(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
Definition: ethercatmain.c:878
uint32 eep_man
Definition: ethercatmain.h:148
ec_PDOassignt * PDOassign
Definition: ethercatmain.h:448
uint16 esislave
Definition: ethercatmain.h:432
ec_eringt * elist
Definition: ethercatmain.h:434
uint8 PhysStartBit
Definition: ethercatmain.h:93
uint16 PhysStart
Definition: ethercatmain.h:92
ec_PDOdesct * PDOdesc
Definition: ethercatmain.h:450
Definition: ethercatmain.h:60
uint16 length
Definition: ethercatmain.h:347
#define EC_MAXNAME
Definition: ethercatmain.h:58
uint32 logstartaddr
Definition: ethercatmain.h:271
uint8 CoEdetails
Definition: ethercatmain.h:244
int ecx_eeprom2master(ecx_contextt *context, uint16 slave)
uint16 outputsWKC
Definition: ethercatmain.h:295
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM)
Definition: ethercatmain.c:572
uint8 FMMUtype
Definition: ethercatmain.h:94
uint8 FMMU1func
Definition: ethercatmain.h:182
void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf)
uint16 mbx_wo
Definition: ethercatmain.h:190
uint32 LogStart
Definition: ethercatmain.h:88
uint8 blockLRW
Definition: ethercatmain.h:287
int16 tail
Definition: ethercatmain.h:378
uint32_t uint32
Definition: osal.h:35
int16 Ebuscurrent
Definition: ethercatmain.h:252
int32 DCrtB
Definition: ethercatmain.h:218
uint16 address
Definition: ethercatmain.h:348
int32 DCshift
Definition: ethercatmain.h:232
uint32 Ibytes
Definition: ethercatmain.h:168
ec_SMcommtypet * SMcommtype
Definition: ethercatmain.h:446
uint32 * esimap
Definition: ethercatmain.h:430
uint8 EoEdetails
Definition: ethercatmain.h:248
uint32 Ibytes
Definition: ethercatmain.h:277
int16_t int16
Definition: osal.h:31
uint16 DCnext
Definition: ethercatmain.h:226
uint16 state
Definition: ethercatmain.h:140
uint16 configindex
Definition: ethercatmain.h:236
uint16 alstatuscode
Definition: ethercatmain.h:360
uint8 * inputs
Definition: ethercatmain.h:279
int ecx_send_processdata(ecx_contextt *context)
uint16 Itype
Definition: ethercatmain.h:154
uint8 FMMUactive
Definition: ethercatmain.h:95
int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, char *ifname, char *if2name)
Definition: ethercatmain.c:331
uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
uint8 parentport
Definition: ethercatmain.h:212
uint16 PhStart
Definition: ethercatmain.h:320
PACKED_BEGIN struct PACKED ec_fmmut
boolean ecx_poperror(ecx_contextt *context, ec_errort *Ec)
Definition: ethercatmain.c:214
uint16 inputsWKC
Definition: ethercatmain.h:297
uint8 activeports
Definition: ethercatmain.h:206
uint8 * outputs
Definition: ethercatmain.h:275
uint16 configadr
Definition: ethercatmain.h:144
Definition: ethercatmain.h:64
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt *FMMU)
Definition: ethercatmain.c:532
int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
Definition: ethercatmain.c:911
uint8 blockLRW
Definition: ethercatmain.h:254
uint32 eep_rev
Definition: ethercatmain.h:152
uint8 ptype
Definition: ethercatmain.h:202
int16 Ebuscurrent
Definition: ethercatmain.h:285
int32 DCcycle
Definition: ethercatmain.h:230
ec_eepromSMt * eepSM
Definition: ethercatmain.h:452
uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
Definition: ethercatmain.c:365
uint8 * esibuf
Definition: ethercatmain.h:428
PACKED_BEGIN struct PACKED ec_SMcommtypet
uint8 ec_mbxbuft[EC_MAXMBX+1]
Definition: ethercatmain.h:341
int * slavecount
Definition: ethercatmain.h:420
uint16 ALstatuscode
Definition: ethercatmain.h:116
#define EC_MAXFMMU
Definition: ethercatmain.h:72
uint8 Ostartbit
Definition: ethercatmain.h:164
uint16 LogLength
Definition: ethercatmain.h:89

Author(s): Jan Paulus
autogenerated on Mon Jun 10 2019 15:46:24