Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: EasyCAT_LAB_simple EasyCAT_LAB_very_simple EasyCAT_LAB
ethercatmain.h File Reference
Headerfile for ethercatmain.c. More...
Go to the source code of this file.
Data Structures | |
struct | ec_fmmu |
record for FMMU More... | |
struct | ec_sm |
record for sync manager More... | |
struct | ec_slave |
for list of ethercat slaves detected More... | |
struct | ec_group |
for list of ethercat slave groups More... | |
struct | ec_eepromFMMU |
SII FMMU structure. More... | |
struct | ec_eepromSM |
SII SM structure. More... | |
struct | ec_eepromPDO |
record to store rxPDO and txPDO table from eeprom More... | |
struct | ec_mbxheader |
standard ethercat mailbox header More... | |
struct | ec_alstatus |
ALstatus and ALstatus code. More... | |
struct | ec_idxstack |
stack structure to store segmented LRD/LWR/LRW constructs More... | |
struct | ec_ering |
ringbuf for error storage More... | |
struct | ec_SMcommtype |
SyncManager Communication Type structure for CA. More... | |
struct | ec_PDOassign |
SDO assign structure for CA. More... | |
struct | ec_PDOdesc |
SDO description structure for CA. More... | |
Typedefs | |
typedef PACKED_BEGIN struct PACKED ec_fmmu | ec_fmmut |
record for FMMU | |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_sm | ec_smt |
record for sync manager | |
typedef struct ec_slave | ec_slavet |
for list of ethercat slaves detected | |
typedef struct ec_group | ec_groupt |
for list of ethercat slave groups | |
typedef struct ec_eepromFMMU | ec_eepromFMMUt |
SII FMMU structure. | |
typedef struct ec_eepromSM | ec_eepromSMt |
SII SM structure. | |
typedef struct ec_eepromPDO | ec_eepromPDOt |
record to store rxPDO and txPDO table from eeprom | |
typedef uint8 | ec_mbxbuft [EC_MAXMBX+1] |
mailbox buffer array | |
typedef PACKED_BEGIN struct PACKED ec_mbxheader | ec_mbxheadert |
standard ethercat mailbox header | |
typedef PACKED_END PACKED_BEGIN struct PACKED ec_alstatus | ec_alstatust |
ALstatus and ALstatus code. | |
typedef PACKED_END struct ec_idxstack | ec_idxstackT |
stack structure to store segmented LRD/LWR/LRW constructs | |
typedef struct ec_ering | ec_eringt |
ringbuf for error storage | |
typedef PACKED_BEGIN struct PACKED ec_SMcommtype | ec_SMcommtypet |
SyncManager Communication Type structure for CA. | |
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 typedefPACKED_END struct ecx_context | ecx_contextt |
Context structure , referenced by all ecx functions. | |
Functions | |
int | ec_init (const char *ifname) |
Initialise lib in single NIC mode. | |
int | ec_init_redundant (const char *ifname, char *if2name) |
Initialise lib in redundant NIC mode. | |
void | ec_close (void) |
Close lib. | |
uint8 | ec_siigetbyte (uint16 slave, uint16 address) |
Read one byte from slave EEPROM via cache. | |
int16 | ec_siifind (uint16 slave, uint16 cat) |
Find SII section header in slave EEPROM. | |
void | ec_siistring (char *str, uint16 slave, uint16 Sn) |
Get string from SII string section in slave EEPROM. | |
uint16 | ec_siiFMMU (uint16 slave, ec_eepromFMMUt *FMMU) |
Get FMMU data from SII FMMU section in slave EEPROM. | |
uint16 | ec_siiSM (uint16 slave, ec_eepromSMt *SM) |
Get SM data from SII SM section in slave EEPROM. | |
uint16 | ec_siiSMnext (uint16 slave, ec_eepromSMt *SM, uint16 n) |
Get next SM data from SII SM section in slave EEPROM. | |
int | ec_siiPDO (uint16 slave, ec_eepromPDOt *PDO, uint8 t) |
Get PDO data from SII PDO section in slave EEPROM. | |
int | ec_readstate (void) |
Read all slave states in ec_slave. | |
int | ec_writestate (uint16 slave) |
Write slave state, if slave = 0 then write to all slaves. | |
uint16 | ec_statecheck (uint16 slave, uint16 reqstate, int timeout) |
Check actual slave state. | |
int | ec_mbxempty (uint16 slave, int timeout) |
Check if IN mailbox of slave is empty. | |
int | ec_mbxsend (uint16 slave, ec_mbxbuft *mbx, int timeout) |
Write IN mailbox to slave. | |
int | ec_mbxreceive (uint16 slave, ec_mbxbuft *mbx, int timeout) |
Read OUT mailbox from slave. | |
void | ec_esidump (uint16 slave, uint8 *esibuf) |
Dump complete EEPROM data from slave in buffer. | |
uint32 | ec_readeeprom (uint16 slave, uint16 eeproma, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ec_writeeeprom (uint16 slave, uint16 eeproma, uint16 data, int timeout) |
Write EEPROM to slave bypassing cache. | |
int | ec_eeprom2master (uint16 slave) |
Set eeprom control to master. | |
uint64 | ec_readeepromAP (uint16 aiadr, uint16 eeproma, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ec_writeeepromAP (uint16 aiadr, uint16 eeproma, uint16 data, int timeout) |
Write EEPROM to slave bypassing cache. | |
uint64 | ec_readeepromFP (uint16 configadr, uint16 eeproma, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ec_writeeepromFP (uint16 configadr, uint16 eeproma, uint16 data, int timeout) |
Write EEPROM to slave bypassing cache. | |
void | ec_readeeprom1 (uint16 slave, uint16 eeproma) |
Read EEPROM from slave bypassing cache. | |
uint32 | ec_readeeprom2 (uint16 slave, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ec_send_processdata_group (uint8 group) |
Transmit processdata to slaves. | |
int | ec_send_overlap_processdata_group (uint8 group) |
Transmit processdata to slaves. | |
int | ec_receive_processdata_group (uint8 group, int timeout) |
Receive processdata from slaves. | |
ec_adaptert * | ec_find_adapters (void) |
Create list over available network adapters. | |
void | ec_free_adapters (ec_adaptert *adapter) |
Free dynamically allocated list over available network adapters. | |
uint8 | ec_nextmbxcnt (uint8 cnt) |
Get index of next mailbox counter value. | |
void | ec_clearmbx (ec_mbxbuft *Mbx) |
Clear mailbox buffer. | |
void | ecx_pusherror (ecx_contextt *context, const ec_errort *Ec) |
Pushes an error on the error list. | |
boolean | ecx_poperror (ecx_contextt *context, ec_errort *Ec) |
Pops an error from the list. | |
boolean | ecx_iserror (ecx_contextt *context) |
Check if error list has entries. | |
void | ecx_packeterror (ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode) |
Report packet error. | |
int | ecx_init (ecx_contextt *context, const char *ifname) |
Initialise lib in single NIC mode. | |
int | ecx_init_redundant (ecx_contextt *context, ecx_redportt *redport, const char *ifname, char *if2name) |
Initialise lib in redundant NIC mode. | |
void | ecx_close (ecx_contextt *context) |
Close lib. | |
uint8 | ecx_siigetbyte (ecx_contextt *context, uint16 slave, uint16 address) |
Read one byte from slave EEPROM via cache. | |
int16 | ecx_siifind (ecx_contextt *context, uint16 slave, uint16 cat) |
Find SII section header in slave EEPROM. | |
void | ecx_siistring (ecx_contextt *context, char *str, uint16 slave, uint16 Sn) |
Get string from SII string section in slave EEPROM. | |
uint16 | ecx_siiFMMU (ecx_contextt *context, uint16 slave, ec_eepromFMMUt *FMMU) |
Get FMMU data from SII FMMU section in slave EEPROM. | |
uint16 | ecx_siiSM (ecx_contextt *context, uint16 slave, ec_eepromSMt *SM) |
Get SM data from SII SM section in slave EEPROM. | |
uint16 | ecx_siiSMnext (ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n) |
Get next SM data from SII SM section in slave EEPROM. | |
int | ecx_siiPDO (ecx_contextt *context, uint16 slave, ec_eepromPDOt *PDO, uint8 t) |
Get PDO data from SII PDO section in slave EEPROM. | |
int | ecx_readstate (ecx_contextt *context) |
Read all slave states in ec_slave. | |
int | ecx_writestate (ecx_contextt *context, uint16 slave) |
Write slave state, if slave = 0 then write to all slaves. | |
uint16 | ecx_statecheck (ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout) |
Check actual slave state. | |
int | ecx_mbxempty (ecx_contextt *context, uint16 slave, int timeout) |
Check if IN mailbox of slave is empty. | |
int | ecx_mbxsend (ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout) |
Write IN mailbox to slave. | |
int | ecx_mbxreceive (ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout) |
Read OUT mailbox from slave. | |
void | ecx_esidump (ecx_contextt *context, uint16 slave, uint8 *esibuf) |
Dump complete EEPROM data from slave in buffer. | |
uint32 | ecx_readeeprom (ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ecx_writeeeprom (ecx_contextt *context, uint16 slave, uint16 eeproma, uint16 data, int timeout) |
Write EEPROM to slave bypassing cache. | |
int | ecx_eeprom2master (ecx_contextt *context, uint16 slave) |
Set eeprom control to master. | |
int | ecx_eeprom2pdi (ecx_contextt *context, uint16 slave) |
Set eeprom control to PDI. | |
uint64 | ecx_readeepromAP (ecx_contextt *context, uint16 aiadr, uint16 eeproma, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ecx_writeeepromAP (ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout) |
Write EEPROM to slave bypassing cache. | |
uint64 | ecx_readeepromFP (ecx_contextt *context, uint16 configadr, uint16 eeproma, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ecx_writeeepromFP (ecx_contextt *context, uint16 configadr, uint16 eeproma, uint16 data, int timeout) |
Write EEPROM to slave bypassing cache. | |
void | ecx_readeeprom1 (ecx_contextt *context, uint16 slave, uint16 eeproma) |
Read EEPROM from slave bypassing cache. | |
uint32 | ecx_readeeprom2 (ecx_contextt *context, uint16 slave, int timeout) |
Read EEPROM from slave bypassing cache. | |
int | ecx_send_overlap_processdata_group (ecx_contextt *context, uint8 group) |
Transmit processdata to slaves. | |
int | ecx_receive_processdata_group (ecx_contextt *context, uint8 group, int timeout) |
Receive processdata from slaves. | |
int | ecx_send_processdata_group (ecx_contextt *context, uint8 group) |
Transmit processdata to slaves. | |
Variables | |
ecx_contextt | ecx_context |
global struct to hold default master context | |
ec_slavet | ec_slave [EC_MAXSLAVE] |
main slave data structure array | |
int | ec_slavecount |
number of slaves found by configuration function | |
ec_groupt | ec_group [EC_MAXGROUP] |
slave group structure | |
boolean | EcatError |
Global variable TRUE if error available in error stack. |
Detailed Description
Headerfile for ethercatmain.c.
Definition in file ethercatmain.h.
Typedef Documentation
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_END struct ec_idxstack ec_idxstackT |
stack structure to store segmented LRD/LWR/LRW constructs
typedef uint8 ec_mbxbuft[EC_MAXMBX+1] |
mailbox buffer array
Definition at line 308 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 typedefPACKED_END struct ecx_context ecx_contextt |
Context structure , referenced by all ecx functions.
Definition at line 380 of file ethercatmain.h.
Function Documentation
void ec_clearmbx | ( | ec_mbxbuft * | Mbx ) |
Clear mailbox buffer.
- Parameters:
-
[out] Mbx = Mailbox buffer to clear
Definition at line 920 of file ethercatmain.c.
void ec_close | ( | void | ) |
int ec_eeprom2master | ( | uint16 | slave ) |
Set eeprom control to master.
Only if set to PDI.
- Parameters:
-
[in] slave = Slave number
- Returns:
- >0 if OK
- See also:
- ecx_eeprom2master
Definition at line 2240 of file ethercatmain.c.
void ec_esidump | ( | uint16 | slave, |
uint8 * | esibuf | ||
) |
Dump complete EEPROM data from slave in buffer.
- Parameters:
-
[in] slave = Slave number [out] esibuf = EEPROM data buffer, make sure it is big enough.
- See also:
- ecx_esidump
Definition at line 2205 of file ethercatmain.c.
ec_adaptert* ec_find_adapters | ( | void | ) |
Create list over available network adapters.
- Returns:
- First element in list over available network adapters.
Definition at line 130 of file ethercatmain.c.
void ec_free_adapters | ( | ec_adaptert * | adapter ) |
Free dynamically allocated list over available network adapters.
- Parameters:
-
[in] adapter = Struct holding adapter name, description and pointer to next.
Definition at line 143 of file ethercatmain.c.
int ec_init | ( | const char * | ifname ) |
Initialise lib in single NIC mode.
- Parameters:
-
[in] ifname = Dev name, f.e. "eth0"
- Returns:
- >0 if OK
- See also:
- ecx_init
Definition at line 2026 of file ethercatmain.c.
int ec_init_redundant | ( | const char * | ifname, |
char * | if2name | ||
) |
Initialise lib in redundant NIC mode.
- Parameters:
-
[in] ifname = Primary Dev name, f.e. "eth0" [in] if2name = Secondary Dev name, f.e. "eth1"
- Returns:
- >0 if OK
- See also:
- ecx_init_redundant
Definition at line 2037 of file ethercatmain.c.
int ec_mbxempty | ( | uint16 | slave, |
int | timeout | ||
) |
Check if IN mailbox of slave is empty.
- Parameters:
-
[in] slave = Slave number [in] timeout = Timeout in us
- Returns:
- >0 is success
- See also:
- ecx_mbxempty
Definition at line 2170 of file ethercatmain.c.
int ec_mbxreceive | ( | uint16 | slave, |
ec_mbxbuft * | mbx, | ||
int | timeout | ||
) |
Read OUT mailbox from slave.
Supports Mailbox Link Layer with repeat requests.
- Parameters:
-
[in] slave = Slave number [out] mbx = Mailbox data [in] timeout = Timeout in us
- Returns:
- Work counter (>0 is success)
- See also:
- ecx_mbxreceive
Definition at line 2195 of file ethercatmain.c.
int ec_mbxsend | ( | uint16 | slave, |
ec_mbxbuft * | mbx, | ||
int | timeout | ||
) |
Write IN mailbox to slave.
- Parameters:
-
[in] slave = Slave number [out] mbx = Mailbox data [in] timeout = Timeout in us
- Returns:
- Work counter (>0 is success)
- See also:
- ecx_mbxsend
Definition at line 2182 of file ethercatmain.c.
uint8 ec_nextmbxcnt | ( | uint8 | cnt ) |
Get index of next mailbox counter value.
Used for Mailbox Link Layer.
- Parameters:
-
[in] cnt = Mailbox counter value [0..7]
- Returns:
- next mailbox counter value
Definition at line 906 of file ethercatmain.c.
uint32 ec_readeeprom | ( | uint16 | slave, |
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
- Parameters:
-
[in] slave = Slave number [in] eeproma = (WORD) Address in the EEPROM [in] timeout = Timeout in us.
- Returns:
- EEPROM data 32bit
- See also:
- ecx_readeeprom
Definition at line 2217 of file ethercatmain.c.
void ec_readeeprom1 | ( | uint16 | slave, |
uint16 | eeproma | ||
) |
Read EEPROM from slave bypassing cache.
Parallel read step 1, make request to slave.
- Parameters:
-
[in] slave = Slave number [in] eeproma = (WORD) Address in the EEPROM
- See also:
- ecx_readeeprom1
Definition at line 2315 of file ethercatmain.c.
uint32 ec_readeeprom2 | ( | uint16 | slave, |
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
Parallel read step 2, actual read from slave.
- Parameters:
-
[in] slave = Slave number [in] timeout = Timeout in us.
- Returns:
- EEPROM data 32bit
- See also:
- ecx_readeeprom2
Definition at line 2327 of file ethercatmain.c.
uint64 ec_readeepromAP | ( | uint16 | aiadr, |
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
APRD method.
- Parameters:
-
[in] aiadr = auto increment address of slave [in] eeproma = (WORD) Address in the EEPROM [in] timeout = Timeout in us.
- Returns:
- EEPROM data 64bit or 32bit
Definition at line 2261 of file ethercatmain.c.
uint64 ec_readeepromFP | ( | uint16 | configadr, |
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
FPRD method.
- Parameters:
-
[in] configadr = configured address of slave [in] eeproma = (WORD) Address in the EEPROM [in] timeout = Timeout in us.
- Returns:
- EEPROM data 64bit or 32bit
- See also:
- ecx_readeepromFP
Definition at line 2291 of file ethercatmain.c.
int ec_readstate | ( | void | ) |
Read all slave states in ec_slave.
- Returns:
- lowest state found
- See also:
- ecx_readstate
Definition at line 2135 of file ethercatmain.c.
int ec_receive_processdata_group | ( | 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.
- Parameters:
-
[in] group = group number [in] timeout = Timeout in us.
- Returns:
- Work counter.
- See also:
- ecx_receive_processdata_group
Definition at line 2376 of file ethercatmain.c.
int ec_send_overlap_processdata_group | ( | 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.
- Parameters:
-
[in] context = context struct [in] group = group number
- Returns:
- >0 if processdata is transmitted.
- See also:
- ecx_send_overlap_processdata_group
Definition at line 2362 of file ethercatmain.c.
int ec_send_processdata_group | ( | 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.
- Parameters:
-
[in] group = group number
- Returns:
- >0 if processdata is transmitted.
- See also:
- ecx_send_processdata_group
Definition at line 2344 of file ethercatmain.c.
int16 ec_siifind | ( | uint16 | slave, |
uint16 | cat | ||
) |
Find SII section header in slave EEPROM.
- Parameters:
-
[in] slave = slave number [in] cat = section category
- Returns:
- byte address of section at section length entry, if not available then 0
- See also:
- ecx_siifind
Definition at line 2069 of file ethercatmain.c.
uint16 ec_siiFMMU | ( | uint16 | slave, |
ec_eepromFMMUt * | FMMU | ||
) |
Get FMMU data from SII FMMU section in slave EEPROM.
- Parameters:
-
[in] slave = slave number [out] FMMU = FMMU struct from SII, max. 4 FMMU's
- Returns:
- number of FMMU's defined in section
- See also:
- ecx_siiFMMU
Definition at line 2091 of file ethercatmain.c.
uint8 ec_siigetbyte | ( | 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 capabillities the request is 4 or 8 bytes.
- Parameters:
-
[in] slave = slave number [in] address = eeprom address in bytes (slave uses words)
- Returns:
- requested byte, if not available then 0xff
- See also:
- ecx_siigetbyte
Definition at line 2058 of file ethercatmain.c.
int ec_siiPDO | ( | uint16 | slave, |
ec_eepromPDOt * | PDO, | ||
uint8 | t | ||
) |
Get PDO data from SII PDO section in slave EEPROM.
- Parameters:
-
[in] slave = slave number [out] PDO = PDO struct from SII [in] t = 0=RXPDO 1=TXPDO
- Returns:
- mapping size in bits of PDO
- See also:
- ecx_siiPDO
Definition at line 2126 of file ethercatmain.c.
uint16 ec_siiSM | ( | uint16 | slave, |
ec_eepromSMt * | SM | ||
) |
Get SM data from SII SM section in slave EEPROM.
- Parameters:
-
[in] slave = slave number [out] SM = first SM struct from SII
- Returns:
- number of SM's defined in section
- See also:
- ecx_siiSM
Definition at line 2102 of file ethercatmain.c.
uint16 ec_siiSMnext | ( | uint16 | slave, |
ec_eepromSMt * | SM, | ||
uint16 | n | ||
) |
Get next SM data from SII SM section in slave EEPROM.
- Parameters:
-
[in] slave = slave number [out] SM = first SM struct from SII [in] n = SM number
- Returns:
- >0 if OK
- See also:
- ecx_siiSMnext
Definition at line 2114 of file ethercatmain.c.
void ec_siistring | ( | char * | str, |
uint16 | slave, | ||
uint16 | Sn | ||
) |
Get string from SII string section in slave EEPROM.
- Parameters:
-
[out] str = requested string, 0x00 if not found [in] slave = slave number [in] Sn = string number
- See also:
- ecx_siistring
Definition at line 2080 of file ethercatmain.c.
uint16 ec_statecheck | ( | uint16 | slave, |
uint16 | reqstate, | ||
int | timeout | ||
) |
Check actual slave state.
This is a blocking function.
- Parameters:
-
[in] slave = Slave number, 0 = all slaves [in] reqstate = Requested state [in] timeout = Timeout value in us
- Returns:
- Requested state, or found state after timeout.
- See also:
- ecx_statecheck
Definition at line 2159 of file ethercatmain.c.
int ec_writeeeprom | ( | uint16 | slave, |
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache.
- Parameters:
-
[in] slave = Slave number [in] eeproma = (WORD) Address in the EEPROM [in] data = 16bit data [in] timeout = Timeout in us.
- Returns:
- >0 if OK
- See also:
- ecx_writeeeprom
Definition at line 2230 of file ethercatmain.c.
int ec_writeeepromAP | ( | uint16 | aiadr, |
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache.
APWR method.
- Parameters:
-
[in] aiadr = configured address of slave [in] eeproma = (WORD) Address in the EEPROM [in] data = 16bit data [in] timeout = Timeout in us.
- Returns:
- >0 if OK
- See also:
- ecx_writeeepromAP
Definition at line 2274 of file ethercatmain.c.
int ec_writeeepromFP | ( | uint16 | configadr, |
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache.
FPWR method.
- Parameters:
-
[in] configadr = configured address of slave [in] eeproma = (WORD) Address in the EEPROM [in] data = 16bit data [in] timeout = Timeout in us.
- Returns:
- >0 if OK
- See also:
- ecx_writeeepromFP
Definition at line 2304 of file ethercatmain.c.
int ec_writestate | ( | uint16 | slave ) |
Write slave state, if slave = 0 then write to all slaves.
The function does not check if the actual state is changed.
- Parameters:
-
[in] slave = Slave number, 0 = master
- Returns:
- 0
- See also:
- ecx_writestate
Definition at line 2146 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.
- Parameters:
-
[in] context = context struct [in] slave = Slave number
- Returns:
- >0 if OK
Definition at line 1187 of file ethercatmain.c.
int ecx_eeprom2pdi | ( | ecx_contextt * | context, |
uint16 | slave | ||
) |
Set eeprom control to PDI.
Only if set to master.
- Parameters:
-
[in] context = context struct [in] slave = Slave number
- Returns:
- >0 if OK
Definition at line 1220 of file ethercatmain.c.
void ecx_esidump | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint8 * | esibuf | ||
) |
Dump complete EEPROM data from slave in buffer.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [out] esibuf = EEPROM data buffer, make sure it is big enough.
Definition at line 1112 of file ethercatmain.c.
int ecx_init | ( | ecx_contextt * | context, |
const char * | ifname | ||
) |
Initialise lib in single NIC mode.
- Parameters:
-
[in] context = context struct [in] ifname = Dev name, f.e. "eth0"
- Returns:
- >0 if OK
Definition at line 287 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.
- Parameters:
-
[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"
- Returns:
- >0 if OK
Definition at line 299 of file ethercatmain.c.
boolean ecx_iserror | ( | ecx_contextt * | context ) |
Check if error list has entries.
- Parameters:
-
[in] context = context struct
- Returns:
- TRUE if error list contains entries.
Definition at line 205 of file ethercatmain.c.
int ecx_mbxempty | ( | ecx_contextt * | context, |
uint16 | slave, | ||
int | timeout | ||
) |
Check if IN mailbox of slave is empty.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [in] timeout = Timeout in us
- Returns:
- >0 is success
Definition at line 931 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.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [out] mbx = Mailbox data [in] timeout = Timeout in us
- Returns:
- Work counter (>0 is success)
Definition at line 1000 of file ethercatmain.c.
int ecx_mbxsend | ( | ecx_contextt * | context, |
uint16 | slave, | ||
ec_mbxbuft * | mbx, | ||
int | timeout | ||
) |
Write IN mailbox to slave.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [out] mbx = Mailbox data [in] timeout = Timeout in us
- Returns:
- Work counter (>0 is success)
Definition at line 967 of file ethercatmain.c.
void ecx_packeterror | ( | ecx_contextt * | context, |
uint16 | Slave, | ||
uint16 | Index, | ||
uint8 | SubIdx, | ||
uint16 | ErrorCode | ||
) |
Report packet error.
- Parameters:
-
[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 218 of file ethercatmain.c.
boolean ecx_poperror | ( | ecx_contextt * | context, |
ec_errort * | Ec | ||
) |
Pops an error from the list.
- Parameters:
-
[in] context = context struct [out] Ec = Struct describing the error.
- Returns:
- TRUE if an error was popped.
Definition at line 179 of file ethercatmain.c.
void ecx_pusherror | ( | ecx_contextt * | context, |
const ec_errort * | Ec | ||
) |
Pushes an error on the error list.
- Parameters:
-
[in] context = context struct [in] Ec pointer describing the error.
Definition at line 153 of file ethercatmain.c.
uint32 ecx_readeeprom | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [in] eeproma = (WORD) Address in the EEPROM [in] timeout = Timeout in us.
- Returns:
- EEPROM data 32bit
Definition at line 1155 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.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [in] eeproma = (WORD) Address in the EEPROM
Definition at line 1583 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.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [in] timeout = Timeout in us.
- Returns:
- EEPROM data 32bit
Definition at line 1616 of file ethercatmain.c.
uint64 ecx_readeepromAP | ( | ecx_contextt * | context, |
uint16 | aiadr, | ||
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
APRD method.
- Parameters:
-
[in] context = context struct [in] aiadr = auto increment address of slave [in] eeproma = (WORD) Address in the EEPROM [in] timeout = Timeout in us.
- Returns:
- EEPROM data 64bit or 32bit
Definition at line 1273 of file ethercatmain.c.
uint64 ecx_readeepromFP | ( | ecx_contextt * | context, |
uint16 | configadr, | ||
uint16 | eeproma, | ||
int | timeout | ||
) |
Read EEPROM from slave bypassing cache.
FPRD method.
- Parameters:
-
[in] context = context struct [in] configadr = configured address of slave [in] eeproma = (WORD) Address in the EEPROM [in] timeout = Timeout in us.
- Returns:
- EEPROM data 64bit or 32bit
Definition at line 1442 of file ethercatmain.c.
int ecx_readstate | ( | ecx_contextt * | context ) |
Read all slave states in ec_slave.
- Parameters:
-
[in] context = context struct
- Returns:
- lowest state found
Definition at line 722 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.
- Parameters:
-
[in] context = context struct [in] group = group number [in] timeout = Timeout in us.
- Returns:
- Work counter.
Definition at line 1907 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.
- Parameters:
-
[in] context = context struct [in] group = group number
- Returns:
- >0 if processdata is transmitted.
Definition at line 1876 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.
- Parameters:
-
[in] context = context struct [in] group = group number
- Returns:
- >0 if processdata is transmitted.
Definition at line 1893 of file ethercatmain.c.
int16 ecx_siifind | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | cat | ||
) |
Find SII section header in slave EEPROM.
- Parameters:
-
[in] context = context struct [in] slave = slave number [in] cat = section category
- Returns:
- byte address of section at section length entry, if not available then 0
Definition at line 404 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.
- Parameters:
-
[in] context = context struct [in] slave = slave number [out] FMMU = FMMU struct from SII, max. 4 FMMU's
- Returns:
- number of FMMU's defined in section
Definition at line 502 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.
- Parameters:
-
[in] context = context struct [in] slave = slave number [in] address = eeprom address in bytes (slave uses words)
- Returns:
- requested byte, if not available then 0xff
Definition at line 333 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.
- Parameters:
-
[in] context = context struct [in] slave = slave number [out] PDO = PDO struct from SII [in] t = 0=RXPDO 1=TXPDO
- Returns:
- mapping size in bits of PDO
Definition at line 613 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.
- Parameters:
-
[in] context = context struct [in] slave = slave number [out] SM = first SM struct from SII
- Returns:
- number of SM's defined in section
Definition at line 542 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.
- Parameters:
-
[in] context = context struct [in] slave = slave number [out] SM = first SM struct from SII [in] n = SM number
- Returns:
- >0 if OK
Definition at line 579 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.
- Parameters:
-
[in] context = context struct [out] str = requested string, 0x00 if not found [in] slave = slave number [in] Sn = string number
Definition at line 444 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
- Parameters:
-
[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
- Returns:
- Requested state, or found state after timeout.
Definition at line 861 of file ethercatmain.c.
int ecx_writeeeprom | ( | ecx_contextt * | context, |
uint16 | slave, | ||
uint16 | eeproma, | ||
uint16 | data, | ||
int | timeout | ||
) |
Write EEPROM to slave bypassing cache.
- Parameters:
-
[in] context = context struct [in] slave = Slave number [in] eeproma = (WORD) Address in the EEPROM [in] data = 16bit data [in] timeout = Timeout in us.
- Returns:
- >0 if OK
Definition at line 1173 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.
- Parameters:
-
[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.
- Returns:
- >0 if OK
Definition at line 1353 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.
- Parameters:
-
[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.
- Returns:
- >0 if OK
Definition at line 1522 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.
- Parameters:
-
[in] context = context struct [in] slave = Slave number, 0 = master
- Returns:
- Workcounter or EC_NOFRAME
Definition at line 831 of file ethercatmain.c.
Variable Documentation
slave group structure
Definition at line 71 of file ethercatmain.c.
main slave data structure array
main slave data structure array
Each slave found on the network gets its own record. ec_slave[0] is reserved for the master. Structure gets filled in by the configuration function ec_config().
Definition at line 67 of file ethercatmain.c.
int ec_slavecount |
number of slaves found by configuration function
Definition at line 69 of file ethercatmain.c.
boolean EcatError |
Global variable TRUE if error available in error stack.
Definition at line 93 of file ethercatmain.c.
global struct to hold default master context
Definition at line 100 of file ethercatmain.c.
Generated on Tue Jul 12 2022 18:21:14 by
