IgH EtherCAT Master  1.6.9
slave.h File Reference

EtherCAT slave structure. More...

Go to the source code of this file.

Data Structures

struct  ec_slave_port_t
 Slave port. More...
struct  ec_sii_t
 Slave information interface data. More...
struct  ec_slave
 EtherCAT slave. More...

Macros

#define EC_SLAVE_INFO(slave, fmt, args...)
 Convenience macro for printing slave-specific information to syslog.
#define EC_SLAVE_ERR(slave, fmt, args...)
 Convenience macro for printing slave-specific errors to syslog.
#define EC_SLAVE_WARN(slave, fmt, args...)
 Convenience macro for printing slave-specific warnings to syslog.
#define EC_SLAVE_DBG(slave, level, fmt, args...)
 Convenience macro for printing slave-specific debug messages to syslog.

Functions

void ec_slave_init (ec_slave_t *, ec_master_t *, ec_device_index_t, uint16_t, uint16_t)
 Slave constructor.
void ec_slave_clear (ec_slave_t *)
 Slave destructor.
void ec_slave_clear_sync_managers (ec_slave_t *)
 Clear the sync manager array.
void ec_slave_request_state (ec_slave_t *, ec_slave_state_t)
 Request a slave state and resets the error flag.
void ec_slave_set_state (ec_slave_t *, ec_slave_state_t)
 Sets the application state of a slave.
int ec_slave_fetch_sii_strings (ec_slave_t *, const uint8_t *, size_t)
 Fetches data from a STRING category.
int ec_slave_fetch_sii_general (ec_slave_t *, const uint8_t *, size_t)
 Fetches data from a GENERAL category.
int ec_slave_fetch_sii_syncs (ec_slave_t *, const uint8_t *, size_t)
 Fetches data from a SYNC MANAGER category.
int ec_slave_fetch_sii_pdos (ec_slave_t *, const uint8_t *, size_t, ec_direction_t)
 Fetches data from a [RT]xPDO category.
ec_sync_tec_slave_get_sync (ec_slave_t *, uint8_t)
 Get the sync manager given an index.
void ec_slave_sdo_dict_info (const ec_slave_t *, unsigned int *, unsigned int *)
 Counts the total number of SDOs and entries in the dictionary.
ec_sdo_tec_slave_get_sdo (ec_slave_t *, uint16_t)
 Get an SDO from the dictionary.
const ec_sdo_tec_slave_get_sdo_const (const ec_slave_t *, uint16_t)
 Get an SDO from the dictionary.
const ec_sdo_tec_slave_get_sdo_by_pos_const (const ec_slave_t *, uint16_t)
 Get an SDO from the dictionary, given its position in the list.
uint16_t ec_slave_sdo_count (const ec_slave_t *)
 Get the number of SDOs in the dictionary.
const ec_pdo_tec_slave_find_pdo (const ec_slave_t *, uint16_t)
 Finds a mapped PDO.
void ec_slave_attach_pdo_names (ec_slave_t *)
 Attach PDO names.
void ec_slave_calc_port_delays (ec_slave_t *)
 Calculates the port transmission delays.
void ec_slave_calc_transmission_delays_rec (ec_slave_t *, uint32_t *)
 Recursively calculates transmission delays.

Detailed Description

EtherCAT slave structure.

Definition in file slave.h.

Macro Definition Documentation

◆ EC_SLAVE_INFO

#define EC_SLAVE_INFO ( slave,
fmt,
args... )
Value:
printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
slave->ring_position, ##args)

Convenience macro for printing slave-specific information to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and POSITION is the slave's ring position.

Parameters
slaveEtherCAT slave
fmtformat string (like in printf())
argsarguments (optional)

Definition at line 54 of file slave.h.

◆ EC_SLAVE_ERR

#define EC_SLAVE_ERR ( slave,
fmt,
args... )
Value:
printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
slave->ring_position, ##args)

Convenience macro for printing slave-specific errors to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and POSITION is the slave's ring position.

Parameters
slaveEtherCAT slave
fmtformat string (like in printf())
argsarguments (optional)

Definition at line 68 of file slave.h.

◆ EC_SLAVE_WARN

#define EC_SLAVE_WARN ( slave,
fmt,
args... )
Value:
printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
slave->master->index, slave->ring_position, ##args)

Convenience macro for printing slave-specific warnings to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and POSITION is the slave's ring position.

Parameters
slaveEtherCAT slave
fmtformat string (like in printf())
argsarguments (optional)

Definition at line 82 of file slave.h.

◆ EC_SLAVE_DBG

#define EC_SLAVE_DBG ( slave,
level,
fmt,
args... )
Value:
do { \
if (slave->master->debug_level >= level) { \
printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
slave->master->index, slave->ring_position, ##args); \
} \
} while (0)

Convenience macro for printing slave-specific debug messages to syslog.

This will print the message in fmt with a prefixed "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and POSITION is the slave's ring position.

Parameters
slaveEtherCAT slave
levelDebug level. Master's debug level must be >= level for output.
fmtformat string (like in printf())
argsarguments (optional)

Definition at line 98 of file slave.h.

Function Documentation

◆ ec_slave_init()

void ec_slave_init ( ec_slave_t * slave,
ec_master_t * master,
ec_device_index_t dev_idx,
uint16_t ring_position,
uint16_t station_address )

Slave constructor.

Returns
0 in case of success, else < 0
Parameters
slaveEtherCAT slave
masterEtherCAT master
dev_idxDevice index.
ring_positionring position
station_addressstation address to configure

Definition at line 60 of file slave.c.

◆ ec_slave_clear()

void ec_slave_clear ( ec_slave_t * slave)

Slave destructor.

Clears and frees a slave object.

Parameters
slaveEtherCAT slave

Definition at line 169 of file slave.c.

◆ ec_slave_clear_sync_managers()

void ec_slave_clear_sync_managers ( ec_slave_t * slave)

Clear the sync manager array.

Parameters
slaveEtherCAT slave.

Definition at line 265 of file slave.c.

◆ ec_slave_request_state()

void ec_slave_request_state ( ec_slave_t * slave,
ec_slave_state_t state )

Request a slave state and resets the error flag.

Parameters
slaveEtherCAT slave
statenew state

Definition at line 306 of file slave.c.

◆ ec_slave_set_state()

void ec_slave_set_state ( ec_slave_t * slave,
ec_slave_state_t new_state )

Sets the application state of a slave.

Parameters
slaveEtherCAT slave
new_statenew application state

Definition at line 284 of file slave.c.

◆ ec_slave_fetch_sii_strings()

int ec_slave_fetch_sii_strings ( ec_slave_t * slave,
const uint8_t * data,
size_t data_size )

Fetches data from a STRING category.

Todo
range checking
Returns
0 in case of success, else < 0
Parameters
slaveEtherCAT slave
datacategory data
data_sizenumber of bytes

Definition at line 322 of file slave.c.

◆ ec_slave_fetch_sii_general()

int ec_slave_fetch_sii_general ( ec_slave_t * slave,
const uint8_t * data,
size_t data_size )

Fetches data from a GENERAL category.

Returns
0 in case of success, else < 0
Parameters
slaveEtherCAT slave
datacategory data
data_sizesize in bytes

Definition at line 378 of file slave.c.

◆ ec_slave_fetch_sii_syncs()

int ec_slave_fetch_sii_syncs ( ec_slave_t * slave,
const uint8_t * data,
size_t data_size )

Fetches data from a SYNC MANAGER category.

Appends the sync managers described in the category to the existing ones.

Returns
0 in case of success, else < 0
Parameters
slaveEtherCAT slave.
dataCategory data.
data_sizeNumber of bytes.

Definition at line 429 of file slave.c.

◆ ec_slave_fetch_sii_pdos()

int ec_slave_fetch_sii_pdos ( ec_slave_t * slave,
const uint8_t * data,
size_t data_size,
ec_direction_t dir )

Fetches data from a [RT]xPDO category.

Returns
0 in case of success, else < 0
Parameters
slaveEtherCAT slave
datacategory data
data_sizenumber of bytes
dirPDO direction.

Definition at line 495 of file slave.c.

◆ ec_slave_get_sync()

ec_sync_t * ec_slave_get_sync ( ec_slave_t * slave,
uint8_t sync_index )

Get the sync manager given an index.

Returns
pointer to sync manager, or NULL.
Parameters
slaveEtherCAT slave.
sync_indexSync manager index.

Definition at line 600 of file slave.c.

◆ ec_slave_sdo_dict_info()

void ec_slave_sdo_dict_info ( const ec_slave_t * slave,
unsigned int * sdo_count,
unsigned int * entry_count )

Counts the total number of SDOs and entries in the dictionary.

Parameters
slaveEtherCAT slave
sdo_countnumber of SDOs
entry_counttotal number of entries

Definition at line 618 of file slave.c.

◆ ec_slave_get_sdo()

ec_sdo_t * ec_slave_get_sdo ( ec_slave_t * slave,
uint16_t index )

Get an SDO from the dictionary.

Returns
The desired SDO, or NULL.
Parameters
slaveEtherCAT slave
indexSDO index

Definition at line 646 of file slave.c.

◆ ec_slave_get_sdo_const()

const ec_sdo_t * ec_slave_get_sdo_const ( const ec_slave_t * slave,
uint16_t index )

Get an SDO from the dictionary.

const version.

Returns
The desired SDO, or NULL.
Parameters
slaveEtherCAT slave
indexSDO index

Definition at line 672 of file slave.c.

◆ ec_slave_get_sdo_by_pos_const()

const ec_sdo_t * ec_slave_get_sdo_by_pos_const ( const ec_slave_t * slave,
uint16_t sdo_position )

Get an SDO from the dictionary, given its position in the list.

Returns
The desired SDO, or NULL.
Parameters
slaveEtherCAT slave.
sdo_positionSDO list position.

Definition at line 694 of file slave.c.

◆ ec_slave_sdo_count()

uint16_t ec_slave_sdo_count ( const ec_slave_t * slave)

Get the number of SDOs in the dictionary.

Returns
SDO count.
Parameters
slaveEtherCAT slave.

Definition at line 716 of file slave.c.

◆ ec_slave_find_pdo()

const ec_pdo_t * ec_slave_find_pdo ( const ec_slave_t * slave,
uint16_t index )

Finds a mapped PDO.

Returns
The desired PDO object, or NULL.
Parameters
slaveSlave.
indexPDO index to find.

Definition at line 735 of file slave.c.

◆ ec_slave_attach_pdo_names()

void ec_slave_attach_pdo_names ( ec_slave_t * slave)

Attach PDO names.

Definition at line 791 of file slave.c.

◆ ec_slave_calc_port_delays()

void ec_slave_calc_port_delays ( ec_slave_t * slave)

Calculates the port transmission delays.

Parameters
slaveEtherCAT slave.

Definition at line 932 of file slave.c.

◆ ec_slave_calc_transmission_delays_rec()

void ec_slave_calc_transmission_delays_rec ( ec_slave_t * slave,
uint32_t * delay )

Recursively calculates transmission delays.

Parameters
slaveCurrent slave.
delaySum of delays.

Definition at line 978 of file slave.c.