Headerfile for ethercatmain.c. More...
Go to the source code of this file.
Classes | |
struct | ec_adapter |
struct | ec_alstatus |
struct | ec_eepromFMMU |
struct | ec_eepromPDO |
struct | ec_eepromSM |
struct | ec_ering |
struct | ec_fmmu |
struct | ec_group |
struct | ec_idxstack |
struct | ec_mbxheader |
struct | ec_PDOassign |
struct | ec_PDOdesc |
struct | ec_slave |
struct | ec_sm |
struct | ec_SMcommtype |
struct | ec_state_status |
struct | ecx_context |
Macros | |
#define | EC_MAX_MAPT 1 |
#define | EC_MAXEEPDO 0x200 |
#define | EC_MAXELIST 64 |
#define | EC_MAXFMMU 4 |
#define | EC_MAXGROUP 2 |
#define | EC_MAXIOSEGMENTS 64 |
#define | EC_MAXLEN_ADAPTERNAME 128 |
#define | EC_MAXMBX 1486 |
#define | EC_MAXNAME 40 |
#define | EC_MAXSLAVE 200 |
#define | EC_MAXSM 8 |
#define | EC_SMENABLEMASK 0xfffeffff |
#define | ECT_COEDET_PDOASSIGN 0x04 |
#define | ECT_COEDET_PDOCONFIG 0x08 |
#define | ECT_COEDET_SDO 0x01 |
#define | ECT_COEDET_SDOCA 0x20 |
#define | ECT_COEDET_SDOINFO 0x02 |
#define | ECT_COEDET_UPLOAD 0x10 |
#define | ECT_MBXPROT_AOE 0x0001 |
#define | ECT_MBXPROT_COE 0x0004 |
#define | ECT_MBXPROT_EOE 0x0002 |
#define | ECT_MBXPROT_FOE 0x0008 |
#define | ECT_MBXPROT_SOE 0x0010 |
#define | ECT_MBXPROT_VOE 0x0020 |
Typedefs | |
typedef struct ec_adapter | ec_adaptert |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_alstatus | ec_alstatust |
typedef struct ec_eepromFMMU | ec_eepromFMMUt |
typedef struct ec_eepromPDO | ec_eepromPDOt |
typedef struct ec_eepromSM | ec_eepromSMt |
typedef struct ec_ering | ec_eringt |
typedef PACKED_BEGIN struct PACKED ec_fmmu | ec_fmmut |
typedef struct ec_group | ec_groupt |
typedef PACKED_END struct ec_idxstack | ec_idxstackT |
typedef uint8 | ec_mbxbuft[EC_MAXMBX+1] |
typedef PACKED_BEGIN struct PACKED ec_mbxheader | ec_mbxheadert |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_PDOassign | ec_PDOassignt |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesc | ec_PDOdesct |
typedef struct ec_slave | ec_slavet |
typedef PACKED_BEGIN struct PACKED ec_SMcommtype | ec_SMcommtypet |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_sm | ec_smt |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_state_status | ec_state_status |
typedef struct ecx_context | ecx_contextt |
Headerfile for ethercatmain.c.
Definition in file ethercatmain.h.
#define EC_MAX_MAPT 1 |
define maximum number of concurrent threads in mapping
Definition at line 41 of file ethercatmain.h.
#define EC_MAXEEPDO 0x200 |
max. eeprom PDO entries
Definition at line 33 of file ethercatmain.h.
#define EC_MAXELIST 64 |
max. entries in EtherCAT error list
Definition at line 21 of file ethercatmain.h.
#define EC_MAXFMMU 4 |
max. FMMU used
Definition at line 37 of file ethercatmain.h.
#define EC_MAXGROUP 2 |
max. number of groups
Definition at line 27 of file ethercatmain.h.
#define EC_MAXIOSEGMENTS 64 |
max. number of IO segments per group
Definition at line 29 of file ethercatmain.h.
#define EC_MAXLEN_ADAPTERNAME 128 |
max. Adapter
Definition at line 39 of file ethercatmain.h.
#define EC_MAXMBX 1486 |
max. mailbox size
Definition at line 31 of file ethercatmain.h.
#define EC_MAXNAME 40 |
max. length of readable name in slavelist and Object Description List
Definition at line 23 of file ethercatmain.h.
#define EC_MAXSLAVE 200 |
max. number of slaves in array
Definition at line 25 of file ethercatmain.h.
#define EC_MAXSM 8 |
max. SM used
Definition at line 35 of file ethercatmain.h.
#define EC_SMENABLEMASK 0xfffeffff |
Definition at line 101 of file ethercatmain.h.
#define ECT_COEDET_PDOASSIGN 0x04 |
Definition at line 96 of file ethercatmain.h.
#define ECT_COEDET_PDOCONFIG 0x08 |
Definition at line 97 of file ethercatmain.h.
#define ECT_COEDET_SDO 0x01 |
Definition at line 94 of file ethercatmain.h.
#define ECT_COEDET_SDOCA 0x20 |
Definition at line 99 of file ethercatmain.h.
#define ECT_COEDET_SDOINFO 0x02 |
Definition at line 95 of file ethercatmain.h.
#define ECT_COEDET_UPLOAD 0x10 |
Definition at line 98 of file ethercatmain.h.
#define ECT_MBXPROT_AOE 0x0001 |
Definition at line 87 of file ethercatmain.h.
#define ECT_MBXPROT_COE 0x0004 |
Definition at line 89 of file ethercatmain.h.
#define ECT_MBXPROT_EOE 0x0002 |
Definition at line 88 of file ethercatmain.h.
#define ECT_MBXPROT_FOE 0x0008 |
Definition at line 90 of file ethercatmain.h.
#define ECT_MBXPROT_SOE 0x0010 |
Definition at line 91 of file ethercatmain.h.
#define ECT_MBXPROT_VOE 0x0020 |
Definition at line 92 of file ethercatmain.h.
typedef struct ec_adapter ec_adaptert |
Definition at line 43 of file ethercatmain.h.
typedef PACKED_END PACKED_BEGIN struct PACKED ec_alstatus ec_alstatust |
ALstatus and ALstatus code
typedef struct ec_eepromFMMU ec_eepromFMMUt |
SII FMMU structure
typedef struct ec_eepromPDO ec_eepromPDOt |
record to store rxPDO and txPDO table from eeprom
typedef struct ec_eepromSM ec_eepromSMt |
SII SM structure
typedef PACKED_BEGIN struct PACKED ec_fmmu ec_fmmut |
record for FMMU
typedef PACKED_END struct ec_idxstack ec_idxstackT |
stack structure to store segmented LRD/LWR/LRW constructs
mailbox buffer array
Definition at line 312 of file ethercatmain.h.
typedef PACKED_BEGIN struct PACKED ec_mbxheader ec_mbxheadert |
standard ethercat mailbox header
typedef PACKED_END PACKED_BEGIN struct PACKED ec_PDOassign ec_PDOassignt |
SDO assign structure for CA
typedef PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesc ec_PDOdesct |
SDO description structure for CA
typedef PACKED_BEGIN struct PACKED ec_SMcommtype ec_SMcommtypet |
SyncManager Communication Type structure for CA
typedef PACKED_END PACKED_BEGIN struct PACKED ec_sm ec_smt |
record for sync manager
typedef PACKED_END PACKED_BEGIN struct PACKED ec_state_status ec_state_status |
typedef struct ecx_context ecx_contextt |
Definition at line 103 of file ethercatmain.h.
void ec_clearmbx | ( | ec_mbxbuft * | Mbx | ) |
Clear mailbox buffer.
[out] | Mbx | = Mailbox buffer to clear |
Definition at line 921 of file ethercatmain.c.
ec_adaptert* ec_find_adapters | ( | void | ) |
Create list over available network adapters.
Definition at line 131 of file ethercatmain.c.
void ec_free_adapters | ( | ec_adaptert * | adapter | ) |
Free dynamically allocated list over available network adapters.
[in] | adapter | = Struct holding adapter name, description and pointer to next. |
Definition at line 144 of file ethercatmain.c.
Get index of next mailbox counter value. Used for Mailbox Link Layer.
[in] | cnt | = Mailbox counter value [0..7] |
Definition at line 907 of file ethercatmain.c.
void ecx_close | ( | ecx_contextt * | context | ) |
int ecx_eeprom2master | ( | ecx_contextt * | context, |
uint16 | slave | ||
) |
Set eeprom control to master. Only if set to PDI.
[in] | context | = context struct |
[in] | slave | = Slave number |
Definition at line 1189 of file ethercatmain.c.
int ecx_eeprom2pdi | ( | ecx_contextt * | context, |
uint16 | slave | ||
) |
Set eeprom control to PDI. Only if set to master.
[in] | context | = context struct |
[in] | slave | = Slave number |
Definition at line 1222 of file ethercatmain.c.
void ecx_esidump | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint8 * | esibuf | ||
) |
Dump complete EEPROM data from slave in buffer.
[in] | context | = context struct |
[in] | slave | = Slave number |
[out] | esibuf | = EEPROM data buffer, make sure it is big enough. |
Definition at line 1114 of file ethercatmain.c.
int ecx_init | ( | ecx_contextt * | context, |
const char * | ifname | ||
) |
Initialise lib in single NIC mode
[in] | context | = context struct |
[in] | ifname | = Dev name, f.e. "eth0" |
Definition at line 288 of file ethercatmain.c.
int ecx_init_redundant | ( | ecx_contextt * | context, |
ecx_redportt * | redport, | ||
const char * | ifname, | ||
char * | if2name | ||
) |
Initialise lib in redundant NIC mode
[in] | context | = context struct |
[in] | redport | = pointer to redport, redundant port data |
[in] | ifname | = Primary Dev name, f.e. "eth0" |
[in] | if2name | = Secondary Dev name, f.e. "eth1" |
Definition at line 300 of file ethercatmain.c.
boolean ecx_iserror | ( | ecx_contextt * | context | ) |
Check if error list has entries.
[in] | context | = context struct |
Definition at line 206 of file ethercatmain.c.
int ecx_mbxempty | ( | ecx_contextt * | context, |
uint16 | slave, | ||
int | timeout | ||
) |
Check if IN mailbox of slave is empty.
[in] | context | = context struct |
[in] | slave | = Slave number |
[in] | timeout | = Timeout in us |
Definition at line 932 of file ethercatmain.c.
int ecx_mbxreceive | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_mbxbuft * | mbx, | ||
int | timeout | ||
) |
Read OUT mailbox from slave. Supports Mailbox Link Layer with repeat requests.
[in] | context | = context struct |
[in] | slave | = Slave number |
[out] | mbx | = Mailbox data |
[in] | timeout | = Timeout in us |
Definition at line 1001 of file ethercatmain.c.
int ecx_mbxsend | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_mbxbuft * | mbx, | ||
int | timeout | ||
) |
Write IN mailbox to slave.
[in] | context | = context struct |
[in] | slave | = Slave number |
[out] | mbx | = Mailbox data |
[in] | timeout | = Timeout in us |
Definition at line 968 of file ethercatmain.c.
void ecx_packeterror | ( | ecx_contextt * | context, |
uint16 | Slave, | ||
uint16 | Index, | ||
uint8 | SubIdx, | ||
uint16 | ErrorCode | ||
) |
Report packet error
[in] | context | = context struct |
[in] | Slave | = Slave number |
[in] | Index | = Index that generated error |
[in] | SubIdx | = Subindex that generated error |
[in] | ErrorCode | = Error code |
Definition at line 219 of file ethercatmain.c.
boolean ecx_poperror | ( | ecx_contextt * | context, |
ec_errort * | Ec | ||
) |
Pops an error from the list.
[in] | context | = context struct |
[out] | Ec | = Struct describing the error. |
Definition at line 180 of file ethercatmain.c.
void ecx_pusherror | ( | ecx_contextt * | context, |
const ec_errort * | Ec | ||
) |
Pushes an error on the error list.
[in] | context | = context struct |
[in] | Ec | pointer describing the error. |
Definition at line 154 of file ethercatmain.c.
uint32 ecx_readeeprom | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
[in] | context | = context struct |
[in] | slave | = Slave number |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | timeout | = Timeout in us. |
Definition at line 1157 of file ethercatmain.c.
void ecx_readeeprom1 | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | eeproma | ||
) |
Read EEPROM from slave bypassing cache. Parallel read step 1, make request to slave.
[in] | context | = context struct |
[in] | slave | = Slave number |
[in] | eeproma | = (WORD) Address in the EEPROM |
Definition at line 1585 of file ethercatmain.c.
uint32 ecx_readeeprom2 | ( | ecx_contextt * | context, |
uint16 | slave, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache. Parallel read step 2, actual read from slave.
[in] | context | = context struct |
[in] | slave | = Slave number |
[in] | timeout | = Timeout in us. |
Definition at line 1618 of file ethercatmain.c.
uint64 ecx_readeepromAP | ( | ecx_contextt * | context, |
uint16 | aiadr, | ||
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache. APRD method.
[in] | context | = context struct |
[in] | aiadr | = auto increment address of slave |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | timeout | = Timeout in us. |
Definition at line 1275 of file ethercatmain.c.
uint64 ecx_readeepromFP | ( | ecx_contextt * | context, |
uint16 | configadr, | ||
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache. FPRD method.
[in] | context | = context struct |
[in] | configadr | = configured address of slave |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | timeout | = Timeout in us. |
Definition at line 1444 of file ethercatmain.c.
int ecx_readstate | ( | ecx_contextt * | context | ) |
Read all slave states in ec_slave.
[in] | context | = context struct |
Definition at line 723 of file ethercatmain.c.
int ecx_receive_processdata | ( | ecx_contextt * | context, |
int | timeout | ||
) |
Definition at line 1998 of file ethercatmain.c.
int ecx_receive_processdata_group | ( | ecx_contextt * | context, |
uint8 | group, | ||
int | timeout | ||
) |
Receive processdata from slaves. Second part from ec_send_processdata(). Received datagrams are recombined with the processdata with help from the stack. If a datagram contains input processdata it copies it to the processdata structure.
[in] | context | = context struct |
[in] | group | = group number |
[in] | timeout | = Timeout in us. |
Definition at line 1910 of file ethercatmain.c.
int ecx_send_overlap_processdata | ( | ecx_contextt * | context | ) |
Definition at line 1993 of file ethercatmain.c.
int ecx_send_overlap_processdata_group | ( | ecx_contextt * | context, |
uint8 | group | ||
) |
Transmit processdata to slaves. Uses LRW, or LRD/LWR if LRW is not allowed (blockLRW). Both the input and output processdata are transmitted in the overlapped IOmap. The outputs with the actual data, the inputs replace the output data in the returning frame. The inputs are gathered with the receive processdata function. In contrast to the base LRW function this function is non-blocking. If the processdata does not fit in one datagram, multiple are used. In order to recombine the slave response, a stack is used.
[in] | context | = context struct |
[in] | group | = group number |
Definition at line 1879 of file ethercatmain.c.
int ecx_send_processdata | ( | ecx_contextt * | context | ) |
Definition at line 1988 of file ethercatmain.c.
int ecx_send_processdata_group | ( | ecx_contextt * | context, |
uint8 | group | ||
) |
Transmit processdata to slaves. Uses LRW, or LRD/LWR if LRW is not allowed (blockLRW). Both the input and output processdata are transmitted. The outputs with the actual data, the inputs have a placeholder. The inputs are gathered with the receive processdata function. In contrast to the base LRW function this function is non-blocking. If the processdata does not fit in one datagram, multiple are used. In order to recombine the slave response, a stack is used.
[in] | context | = context struct |
[in] | group | = group number |
Definition at line 1896 of file ethercatmain.c.
int16 ecx_siifind | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | cat | ||
) |
Find SII section header in slave EEPROM.
[in] | context | = context struct |
[in] | slave | = slave number |
[in] | cat | = section category |
Definition at line 405 of file ethercatmain.c.
uint16 ecx_siiFMMU | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_eepromFMMUt * | FMMU | ||
) |
Get FMMU data from SII FMMU section in slave EEPROM.
[in] | context | = context struct |
[in] | slave | = slave number |
[out] | FMMU | = FMMU struct from SII, max. 4 FMMU's |
Definition at line 503 of file ethercatmain.c.
uint8 ecx_siigetbyte | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | address | ||
) |
Read one byte from slave EEPROM via cache. If the cache location is empty then a read request is made to the slave. Depending on the slave capabilities the request is 4 or 8 bytes.
[in] | context | = context struct |
[in] | slave | = slave number |
[in] | address | = eeprom address in bytes (slave uses words) |
Definition at line 334 of file ethercatmain.c.
int ecx_siiPDO | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_eepromPDOt * | PDO, | ||
uint8 | t | ||
) |
Get PDO data from SII PDO section in slave EEPROM.
[in] | context | = context struct |
[in] | slave | = slave number |
[out] | PDO | = PDO struct from SII |
[in] | t | = 0=RXPDO 1=TXPDO |
Definition at line 614 of file ethercatmain.c.
uint16 ecx_siiSM | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_eepromSMt * | SM | ||
) |
Get SM data from SII SM section in slave EEPROM.
[in] | context | = context struct |
[in] | slave | = slave number |
[out] | SM | = first SM struct from SII |
Definition at line 543 of file ethercatmain.c.
uint16 ecx_siiSMnext | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_eepromSMt * | SM, | ||
uint16 | n | ||
) |
Get next SM data from SII SM section in slave EEPROM.
[in] | context | = context struct |
[in] | slave | = slave number |
[out] | SM | = first SM struct from SII |
[in] | n | = SM number |
Definition at line 580 of file ethercatmain.c.
void ecx_siistring | ( | ecx_contextt * | context, |
char * | str, | ||
uint16 | slave, | ||
uint16 | Sn | ||
) |
Get string from SII string section in slave EEPROM.
[in] | context | = context struct |
[out] | str | = requested string, 0x00 if not found |
[in] | slave | = slave number |
[in] | Sn | = string number |
Definition at line 445 of file ethercatmain.c.
uint16 ecx_statecheck | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | reqstate, | ||
int | timeout | ||
) |
Check actual slave state. This is a blocking function. To refresh the state of all slaves ecx_readstate()should be called
[in] | context | = context struct |
[in] | slave | = Slave number, 0 = all slaves (only the "slavelist[0].state" is refreshed) |
[in] | reqstate | = Requested state |
[in] | timeout | = Timeout value in us |
Definition at line 862 of file ethercatmain.c.
int ecx_writeeeprom | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache.
[in] | context | = context struct |
[in] | slave | = Slave number |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | data | = 16bit data |
[in] | timeout | = Timeout in us. |
Definition at line 1175 of file ethercatmain.c.
int ecx_writeeepromAP | ( | ecx_contextt * | context, |
uint16 | aiadr, | ||
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache. APWR method.
[in] | context | = context struct |
[in] | aiadr | = configured address of slave |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | data | = 16bit data |
[in] | timeout | = Timeout in us. |
Definition at line 1355 of file ethercatmain.c.
int ecx_writeeepromFP | ( | ecx_contextt * | context, |
uint16 | configadr, | ||
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache. FPWR method.
[in] | context | = context struct |
[in] | configadr | = configured address of slave |
[in] | eeproma | = (WORD) Address in the EEPROM |
[in] | data | = 16bit data |
[in] | timeout | = Timeout in us. |
Definition at line 1524 of file ethercatmain.c.
int ecx_writestate | ( | ecx_contextt * | context, |
uint16 | slave | ||
) |
Write slave state, if slave = 0 then write to all slaves. The function does not check if the actual state is changed.
[in] | context | = context struct |
[in] | slave | = Slave number, 0 = master |
Definition at line 832 of file ethercatmain.c.