IgH EtherCAT Master  1.7.0
master.c File Reference

EtherCAT master methods. More...

Go to the source code of this file.

Macros

#define ec_rt_lock_interruptible(lock)   rt_mutex_lock_interruptible(lock)
 
#define DEBUG_INJECT   0
 Set to 1 to enable external datagram injection debugging.
 
#define FORCE_OUTPUT_CORRUPTED   0
 Always output corrupted frames.
 
#define EC_SDO_INJECTION_TIMEOUT   10000
 SDO injection timeout in microseconds. More...
 
#define EC_SII_CACHING_MASK
 SII caching mask (combination of valid flags). More...
 
#define EC_FIND_SLAVE
 Common implementation for ec_master_find_slave() and ec_master_find_slave_const(). More...
 
#define EC_FIND_CONFIG
 Common implementation for ec_master_get_config() and ec_master_get_config_const(). More...
 
#define EC_FIND_DOMAIN
 Common implementation for ec_master_find_domain() and ec_master_find_domain_const(). More...
 

Functions

void ec_master_clear_config (ec_master_t *master)
 Clear the configuration applied by the application. More...
 
void ec_master_clear_sii_cache (ec_master_t *master)
 Clear SII page cache.
 
void ec_master_clear_slave_configs (ec_master_t *master)
 Clear all slave configurations.
 
void ec_master_clear_domains (ec_master_t *master)
 Clear all domains.
 
int ec_master_thread_start (ec_master_t *master, int(*thread_func)(void *), const char *name)
 Starts the master thread. More...
 
void ec_master_thread_stop (ec_master_t *master)
 Stops the master thread. More...
 
void ec_master_inject_external_datagrams (ec_master_t *master)
 Injects external datagrams that fit into the datagram queue. More...
 
ec_datagram_t * ec_master_get_external_datagram (ec_master_t *master)
 Searches for a free datagram in the external datagram ring. More...
 
void ec_master_exec_slave_fsms (ec_master_t *master)
 Execute slave FSMs. More...
 
void ec_master_send_datagrams (ec_master_t *master, ec_device_index_t device_index)
 Sends the datagrams in the queue for a certain device. More...
 
int ec_master_calc_topology_rec (ec_master_t *master, ec_slave_t *port0_slave, unsigned int *slave_position)
 Calculates the bus topology; recursion function. More...
 
void ec_master_calc_topology (ec_master_t *master)
 Calculates the bus topology. More...
 
void ec_master_calc_transmission_delays (ec_master_t *master)
 Calculates the bus transmission delays. More...
 
static int ec_master_idle_thread (void *priv_data)
 Master kernel thread function for IDLE phase.
 
static int ec_master_operation_thread (void *priv_data)
 Master kernel thread function for OPERATION phase.
 
static int ec_master_eoe_thread (void *priv_data)
 Does the Ethernet over EtherCAT processing.
 
void ec_master_find_dc_ref_clock (ec_master_t *master)
 Finds the DC reference clock. More...
 
void ec_master_clear_device_stats (ec_master_t *master)
 Clears the common device statistics. More...
 
void ec_master_update_device_stats (ec_master_t *master)
 Updates the common device statistics. More...
 
void ec_master_nanosleep (const unsigned long)
 
int ec_master_cached_sii_page_matches (const ec_master_t *master, const ec_sii_page_t *cached_page, uint32_t vendor_id, uint32_t product_code, uint32_t revision, uint32_t serial, uint16_t alias)
 Check if a cached SII page is matching the caching criteria. More...
 
static void sc_reset_task_kicker (struct irq_work *work)
 
static void sc_reset_task (struct work_struct *work)
 
void ec_master_init_static (void)
 Static variables initializer.
 
int ec_master_init (ec_master_t *master, unsigned int index, const uint8_t *main_mac, const uint8_t *backup_mac, dev_t device_number, struct class *class, unsigned int debug_level, unsigned int run_on_cpu, unsigned int sii_caching)
 Master constructor. More...
 
void ec_master_clear (ec_master_t *master)
 Destructor. More...
 
void ec_master_clear_eoe_handlers (ec_master_t *master)
 Clear and free all EoE handlers. More...
 
void ec_master_clear_slaves (ec_master_t *master)
 Clear all slaves.
 
void ec_master_internal_send_cb (void *cb_data)
 Internal sending callback. More...
 
void ec_master_internal_receive_cb (void *cb_data)
 Internal receiving callback. More...
 
int ec_master_enter_idle_phase (ec_master_t *master)
 Transition function from ORPHANED to IDLE phase. More...
 
void ec_master_leave_idle_phase (ec_master_t *master)
 Transition function from IDLE to ORPHANED phase. More...
 
int ec_master_enter_operation_phase (ec_master_t *master)
 Transition function from IDLE to OPERATION phase. More...
 
void ec_master_leave_operation_phase (ec_master_t *master)
 Transition function from OPERATION to IDLE phase. More...
 
void ec_master_set_send_interval (ec_master_t *master, unsigned int send_interval)
 Sets the expected interval between calls to ecrt_master_send and calculates the maximum amount of data to queue. More...
 
void ec_master_queue_datagram (ec_master_t *master, ec_datagram_t *datagram)
 Places a datagram in the datagram queue. More...
 
void ec_master_queue_datagram_ext (ec_master_t *master, ec_datagram_t *datagram)
 Places a datagram in the non-application datagram queue. More...
 
static int ec_master_mbox_store (ec_mbox_data_t *mbox_data, const uint8_t *data, size_t size)
 Stores a received mailbox response in a protocol-specific buffer. More...
 
static int ec_master_mbox_dispatch (ec_master_t *master, const uint8_t *data, size_t size, uint16_t slave_addr, uint16_t offset_addr)
 Common mailbox dispatcher for mailboxes read via the station address. More...
 
void ec_master_receive_datagrams (ec_master_t *master, ec_device_t *device, const uint8_t *frame_data, size_t size)
 Processes a received frame. More...
 
void ec_master_output_stats (ec_master_t *master)
 Output master statistics. More...
 
static void set_normal_priority (struct task_struct *p, int nice)
 
void ec_master_eoe_start (ec_master_t *master)
 Starts Ethernet over EtherCAT processing on demand. More...
 
void ec_master_eoe_stop (ec_master_t *master)
 Stops the Ethernet over EtherCAT processing. More...
 
void ec_master_attach_slave_configs (ec_master_t *master)
 Attaches the slave configurations to the slaves. More...
 
ec_slave_t * ec_master_find_slave (ec_master_t *master, uint16_t alias, uint16_t position)
 Finds a slave in the bus, given the alias and position. More...
 
const ec_slave_t * ec_master_find_slave_const (const ec_master_t *master, uint16_t alias, uint16_t position)
 Finds a slave in the bus, given the alias and position. More...
 
ec_slave_config_t * ec_master_find_config_for_slave (ec_master_t *master, const ec_slave_t *slave)
 Finds the slave configuration that will be attached to the given slave. More...
 
unsigned int ec_master_config_count (const ec_master_t *master)
 Get the number of slave configurations provided by the application. More...
 
ec_slave_config_t * ec_master_get_config (const ec_master_t *master, unsigned int pos)
 Get a slave configuration via its position in the list. More...
 
const ec_slave_config_t * ec_master_get_config_const (const ec_master_t *master, unsigned int pos)
 Get a slave configuration via its position in the list. More...
 
unsigned int ec_master_domain_count (const ec_master_t *master)
 Get the number of domains. More...
 
ec_domain_t * ec_master_find_domain (ec_master_t *master, unsigned int index)
 Get a domain via its position in the list. More...
 
const ec_domain_t * ec_master_find_domain_const (const ec_master_t *master, unsigned int index)
 Get a domain via its position in the list. More...
 
uint16_t ec_master_eoe_handler_count (const ec_master_t *master)
 Get the number of EoE handlers. More...
 
const ec_eoe_t * ec_master_get_eoe_handler_const (const ec_master_t *master, uint16_t index)
 Get an EoE handler via its position in the list. More...
 
int ec_master_debug_level (ec_master_t *master, unsigned int level)
 Set the debug level. More...
 
void ec_master_calc_dc (ec_master_t *master)
 Distributed-clocks calculations. More...
 
void ec_master_request_op (ec_master_t *master)
 Request OP state for configured slaves. More...
 
ec_sii_page_t * ec_master_find_cached_sii_page (const ec_master_t *master, uint32_t vendor_id, uint32_t product_code, uint32_t revision, uint32_t serial, uint16_t alias)
 Find a matching cached SII page. More...
 
int ec_master_cache_sii_page (ec_master_t *master, const ec_sii_page_t *page)
 Add an SII page to the cache. More...
 
ec_domain_t * ecrt_master_create_domain_err (ec_master_t *master)
 Same as ecrt_master_create_domain(), but with ERR_PTR() return value. More...
 
ec_domain_t * ecrt_master_create_domain (ec_master_t *master)
 Creates a new process data domain. More...
 
int ecrt_master_activate (ec_master_t *master)
 Finishes the configuration phase and prepares for cyclic operation. More...
 
int ecrt_master_deactivate (ec_master_t *master)
 Deactivates the master. More...
 
int ecrt_master_send (ec_master_t *master)
 Sends all datagrams in the queue. More...
 
int ecrt_master_receive (ec_master_t *master)
 Fetches received frames from the hardware and processes the datagrams. More...
 
int ecrt_master_send_ext (ec_master_t *master)
 Sends non-application datagrams. More...
 
ec_slave_config_t * ecrt_master_slave_config_err (ec_master_t *master, uint16_t alias, uint16_t position, uint32_t vendor_id, uint32_t product_code)
 Same as ecrt_master_slave_config(), but with ERR_PTR() return value.
 
ec_slave_config_t * ecrt_master_slave_config (ec_master_t *master, uint16_t alias, uint16_t position, uint32_t vendor_id, uint32_t product_code)
 Obtains a slave configuration. More...
 
int ecrt_master_select_reference_clock (ec_master_t *master, ec_slave_config_t *sc)
 Selects the reference clock for distributed clocks. More...
 
int ecrt_master (ec_master_t *master, ec_master_info_t *master_info)
 Obtains master information. More...
 
int ecrt_master_scan_progress (ec_master_t *master, ec_master_scan_progress_t *progress)
 Obtains network scan progress information. More...
 
int ecrt_master_get_slave (ec_master_t *master, uint16_t slave_position, ec_slave_info_t *slave_info)
 Obtains slave information. More...
 
void ecrt_master_callbacks (ec_master_t *master, void(*send_cb)(void *), void(*receive_cb)(void *), void *cb_data)
 Sets the locking callbacks. More...
 
int ecrt_master_state (const ec_master_t *master, ec_master_state_t *state)
 Reads the current master state. More...
 
int ecrt_master_link_state (const ec_master_t *master, unsigned int dev_idx, ec_master_link_state_t *state)
 Reads the current state of a redundant link. More...
 
int ecrt_master_application_time (ec_master_t *master, uint64_t app_time)
 Sets the application time. More...
 
int ecrt_master_reference_clock_time (const ec_master_t *master, uint32_t *time)
 Get the lower 32 bit of the reference clock system time. More...
 
int ecrt_master_sync_reference_clock (ec_master_t *master)
 Queues the DC reference clock drift compensation datagram for sending. More...
 
int ecrt_master_sync_reference_clock_to (ec_master_t *master, uint64_t sync_time)
 Queues the DC reference clock drift compensation datagram for sending. More...
 
int ecrt_master_sync_slave_clocks (ec_master_t *master)
 Queues the DC clock drift compensation datagram for sending. More...
 
int ecrt_master_sync_monitor_queue (ec_master_t *master)
 Queues the DC synchrony monitoring datagram for sending. More...
 
uint32_t ecrt_master_sync_monitor_process (const ec_master_t *master)
 Processes the DC synchrony monitoring datagram. More...
 
int ecrt_master_sdo_download (ec_master_t *master, uint16_t slave_position, uint16_t index, uint8_t subindex, const uint8_t *data, size_t data_size, uint32_t *abort_code)
 Executes an SDO download request to write data to a slave. More...
 
int ecrt_master_sdo_download_complete (ec_master_t *master, uint16_t slave_position, uint16_t index, const uint8_t *data, size_t data_size, uint32_t *abort_code)
 Executes an SDO download request to write data to a slave via complete access. More...
 
int ecrt_master_sdo_upload (ec_master_t *master, uint16_t slave_position, uint16_t index, uint8_t subindex, uint8_t *target, size_t target_size, size_t *result_size, uint32_t *abort_code)
 Executes an SDO upload request to read data from a slave. More...
 
int ecrt_master_write_idn (ec_master_t *master, uint16_t slave_position, uint8_t drive_no, uint16_t idn, const uint8_t *data, size_t data_size, uint16_t *error_code)
 Executes an SoE write request. More...
 
int ecrt_master_read_idn (ec_master_t *master, uint16_t slave_position, uint8_t drive_no, uint16_t idn, uint8_t *target, size_t target_size, size_t *result_size, uint16_t *error_code)
 Executes an SoE read request. More...
 
int ecrt_master_reset (ec_master_t *master)
 Retry configuring slaves. More...
 
int ecrt_master_sii_caching (ec_master_t *master, ec_sii_caching_fields_t fields)
 Set the SII caching method. More...
 

Variables

static unsigned long timeout_jiffies
 Frame timeout in jiffies.
 
static unsigned long ext_injection_timeout_jiffies
 Timeout for external datagram injection [jiffies].
 
const unsigned int rate_intervals []
 List of intervals for statistics [s]. More...
 

Detailed Description

EtherCAT master methods.

Definition in file master.c.

Macro Definition Documentation

◆ EC_SDO_INJECTION_TIMEOUT

#define EC_SDO_INJECTION_TIMEOUT   10000

SDO injection timeout in microseconds.

Definition at line 80 of file master.c.

◆ EC_SII_CACHING_MASK

#define EC_SII_CACHING_MASK
Value:
EC_SII_REVISION | EC_SII_SERIAL | EC_SII_ALIAS)
Use vendor ID.
Definition: ecrt.h:685
Use revision number.
Definition: ecrt.h:687
Disable SII caching.
Definition: ecrt.h:684
Use serial number.
Definition: ecrt.h:688

SII caching mask (combination of valid flags).

Definition at line 83 of file master.c.

◆ EC_FIND_SLAVE

#define EC_FIND_SLAVE
Value:
do { \
if (alias) { \
for (; slave < master->slaves + master->slave_count; \
slave++) { \
if (slave->effective_alias == alias) \
break; \
} \
if (slave == master->slaves + master->slave_count) \
return NULL; \
} \
\
slave += position; \
if (slave < master->slaves + master->slave_count) { \
return slave; \
} else { \
return NULL; \
} \
} while (0)

Common implementation for ec_master_find_slave() and ec_master_find_slave_const().

Definition at line 1986 of file master.c.

◆ EC_FIND_CONFIG

#define EC_FIND_CONFIG
Value:
do { \
list_for_each_entry(sc, &master->configs, list) { \
if (pos--) \
continue; \
return sc; \
} \
return NULL; \
} while (0)

Common implementation for ec_master_get_config() and ec_master_get_config_const().

Definition at line 2101 of file master.c.

◆ EC_FIND_DOMAIN

#define EC_FIND_DOMAIN
Value:
do { \
list_for_each_entry(domain, &master->domains, list) { \
if (index--) \
continue; \
return domain; \
} \
\
return NULL; \
} while (0)

Common implementation for ec_master_find_domain() and ec_master_find_domain_const().

Definition at line 2164 of file master.c.

Function Documentation

◆ ec_master_clear_config()

void ec_master_clear_config ( ec_master_t *  master)

Clear the configuration applied by the application.

Parameters
masterEtherCAT master.

Definition at line 571 of file master.c.

◆ ec_master_thread_start()

int ec_master_thread_start ( ec_master_t *  master,
int(*)(void *)  thread_func,
const char *  name 
)

Starts the master thread.

Return values
0Success.
<0Error code.
Parameters
masterEtherCAT master
thread_functhread function to start
nameThread name.

Definition at line 618 of file master.c.

◆ ec_master_thread_stop()

void ec_master_thread_stop ( ec_master_t *  master)

Stops the master thread.

Parameters
masterEtherCAT master

Definition at line 648 of file master.c.

◆ ec_master_inject_external_datagrams()

void ec_master_inject_external_datagrams ( ec_master_t *  master)

Injects external datagrams that fit into the datagram queue.

Parameters
masterEtherCAT master

Definition at line 830 of file master.c.

◆ ec_master_get_external_datagram()

ec_datagram_t * ec_master_get_external_datagram ( ec_master_t *  master)

Searches for a free datagram in the external datagram ring.

Returns
Next free datagram, or NULL.
Parameters
masterEtherCAT master

Definition at line 961 of file master.c.

◆ ec_master_exec_slave_fsms()

void ec_master_exec_slave_fsms ( ec_master_t *  master)

Execute slave FSMs.

Parameters
masterEtherCAT master.

Definition at line 1615 of file master.c.

◆ ec_master_send_datagrams()

void ec_master_send_datagrams ( ec_master_t *  master,
ec_device_index_t  device_index 
)

Sends the datagrams in the queue for a certain device.

Parameters
masterEtherCAT master
device_indexDevice index.

Definition at line 1030 of file master.c.

◆ ec_master_calc_topology_rec()

int ec_master_calc_topology_rec ( ec_master_t *  master,
ec_slave_t *  port0_slave,
unsigned int *  slave_position 
)

Calculates the bus topology; recursion function.

Returns
Zero on success, otherwise a negative error code.
Parameters
masterEtherCAT master.
port0_slaveSlave at port 0.
slave_positionSlave position.

Definition at line 2366 of file master.c.

◆ ec_master_calc_topology()

void ec_master_calc_topology ( ec_master_t *  master)

Calculates the bus topology.

Parameters
masterEtherCAT master.

Definition at line 2409 of file master.c.

◆ ec_master_calc_transmission_delays()

void ec_master_calc_transmission_delays ( ec_master_t *  master)

Calculates the bus transmission delays.

Parameters
masterEtherCAT master.

Definition at line 2426 of file master.c.

◆ ec_master_find_dc_ref_clock()

void ec_master_find_dc_ref_clock ( ec_master_t *  master)

Finds the DC reference clock.

Parameters
masterEtherCAT master.

Definition at line 2281 of file master.c.

◆ ec_master_clear_device_stats()

void ec_master_clear_device_stats ( ec_master_t *  master)

Clears the common device statistics.

Parameters
masterEtherCAT master

Definition at line 1479 of file master.c.

◆ ec_master_update_device_stats()

void ec_master_update_device_stats ( ec_master_t *  master)

Updates the common device statistics.

Parameters
masterEtherCAT master

Definition at line 1511 of file master.c.

◆ ec_master_cached_sii_page_matches()

int ec_master_cached_sii_page_matches ( const ec_master_t *  master,
const ec_sii_page_t *  cached_page,
uint32_t  vendor_id,
uint32_t  product_code,
uint32_t  revision,
uint32_t  serial,
uint16_t  alias 
)

Check if a cached SII page is matching the caching criteria.

Returns non-zero if matching.

Parameters
masterEtherCAT master.
cached_pageSII page.

Definition at line 2502 of file master.c.

◆ ec_master_init()

int ec_master_init ( ec_master_t *  master,
unsigned int  index,
const uint8_t *  main_mac,
const uint8_t *  backup_mac,
dev_t  device_number,
struct class *  class,
unsigned int  debug_level,
unsigned int  run_on_cpu,
unsigned int  sii_caching 
)

Master constructor.

Returns
0 in case of success, else < 0
Parameters
masterEtherCAT master
indexmaster index
main_macMAC address of main device
backup_macMAC address of backup device
device_numberCharacter device number.
classDevice class.
debug_levelDebug level (module parameter).
run_on_cpuBind created kernel threads to a cpu.
sii_cachingSII caching mode.

Definition at line 170 of file master.c.

◆ ec_master_clear()

void ec_master_clear ( ec_master_t *  master)

Destructor.

Parameters
masterEtherCAT master

Definition at line 416 of file master.c.

◆ ec_master_clear_eoe_handlers()

void ec_master_clear_eoe_handlers ( ec_master_t *  master)

Clear and free all EoE handlers.

Parameters
masterEtherCAT master

Definition at line 463 of file master.c.

◆ ec_master_internal_send_cb()

void ec_master_internal_send_cb ( void *  cb_data)

Internal sending callback.

Parameters
cb_dataCallback data.

Definition at line 585 of file master.c.

◆ ec_master_internal_receive_cb()

void ec_master_internal_receive_cb ( void *  cb_data)

Internal receiving callback.

Parameters
cb_dataCallback data.

Definition at line 600 of file master.c.

◆ ec_master_enter_idle_phase()

int ec_master_enter_idle_phase ( ec_master_t *  master)

Transition function from ORPHANED to IDLE phase.

Returns
Zero on success, otherwise a negative error code.
Parameters
masterEtherCAT master

Definition at line 680 of file master.c.

◆ ec_master_leave_idle_phase()

void ec_master_leave_idle_phase ( ec_master_t *  master)

Transition function from IDLE to ORPHANED phase.

Parameters
masterEtherCAT master

Definition at line 713 of file master.c.

◆ ec_master_enter_operation_phase()

int ec_master_enter_operation_phase ( ec_master_t *  master)

Transition function from IDLE to OPERATION phase.

Returns
Zero on success, otherwise a negative error code.
Parameters
masterEtherCAT master

Definition at line 737 of file master.c.

◆ ec_master_leave_operation_phase()

void ec_master_leave_operation_phase ( ec_master_t *  master)

Transition function from OPERATION to IDLE phase.

Parameters
masterEtherCAT master

Definition at line 808 of file master.c.

◆ ec_master_set_send_interval()

void ec_master_set_send_interval ( ec_master_t *  master,
unsigned int  send_interval 
)

Sets the expected interval between calls to ecrt_master_send and calculates the maximum amount of data to queue.

Parameters
masterEtherCAT master
send_intervalSend interval

Definition at line 944 of file master.c.

◆ ec_master_queue_datagram()

void ec_master_queue_datagram ( ec_master_t *  master,
ec_datagram_t *  datagram 
)

Places a datagram in the datagram queue.

Parameters
masterEtherCAT master
datagramdatagram

Definition at line 980 of file master.c.

◆ ec_master_queue_datagram_ext()

void ec_master_queue_datagram_ext ( ec_master_t *  master,
ec_datagram_t *  datagram 
)

Places a datagram in the non-application datagram queue.

Parameters
masterEtherCAT master
datagramdatagram

Definition at line 1015 of file master.c.

◆ ec_master_mbox_store()

static int ec_master_mbox_store ( ec_mbox_data_t *  mbox_data,
const uint8_t *  data,
size_t  size 
)
static

Stores a received mailbox response in a protocol-specific buffer.

Return values
0The response was stored.
-ENOENTThere is no buffer for the protocol.
-EOVERFLOWThe response does not fit into the buffer.
Parameters
mbox_dataMailbox response buffer.
dataReceived mailbox data.
sizeSize of the received data.

Definition at line 1167 of file master.c.

◆ ec_master_mbox_dispatch()

static int ec_master_mbox_dispatch ( ec_master_t *  master,
const uint8_t *  data,
size_t  size,
uint16_t  slave_addr,
uint16_t  offset_addr 
)
static

Common mailbox dispatcher for mailboxes read via the station address.

Returns
Non-zero, if the data were handled by the dispatcher, zero, if they shall be copied into the datagram memory.
Parameters
masterEtherCAT master.
dataReceived datagram data.
sizeSize of the received datagram data.
slave_addrStation address of the datagram.
offset_addrRegister offset of the datagram.

Definition at line 1193 of file master.c.

◆ ec_master_receive_datagrams()

void ec_master_receive_datagrams ( ec_master_t *  master,
ec_device_t *  device,
const uint8_t *  frame_data,
size_t  size 
)

Processes a received frame.

This function is called by the network driver for every received frame.

Returns
0 in case of success, else < 0
Parameters
masterEtherCAT master
deviceEtherCAT device
frame_dataframe data
sizesize of the received data

Definition at line 1300 of file master.c.

◆ ec_master_output_stats()

void ec_master_output_stats ( ec_master_t *  master)

Output master statistics.

This function outputs statistical data on demand, but not more often than necessary. The output happens at most once a second.

Parameters
masterEtherCAT master

Definition at line 1449 of file master.c.

◆ ec_master_eoe_start()

void ec_master_eoe_start ( ec_master_t *  master)

Starts Ethernet over EtherCAT processing on demand.

Parameters
masterEtherCAT master

Definition at line 1856 of file master.c.

◆ ec_master_eoe_stop()

void ec_master_eoe_stop ( ec_master_t *  master)

Stops the Ethernet over EtherCAT processing.

Parameters
masterEtherCAT master

Definition at line 1890 of file master.c.

◆ ec_master_attach_slave_configs()

void ec_master_attach_slave_configs ( ec_master_t *  master)

Attaches the slave configurations to the slaves.

Parameters
masterEtherCAT master.

Definition at line 1970 of file master.c.

◆ ec_master_find_slave()

ec_slave_t* ec_master_find_slave ( ec_master_t *  master,
uint16_t  alias,
uint16_t  position 
)

Finds a slave in the bus, given the alias and position.

Returns
Search result, or NULL.
Parameters
masterEtherCAT master.
aliasSlave alias.
positionSlave position.

Definition at line 2010 of file master.c.

◆ ec_master_find_slave_const()

const ec_slave_t* ec_master_find_slave_const ( const ec_master_t *  master,
uint16_t  alias,
uint16_t  position 
)

Finds a slave in the bus, given the alias and position.

Const version.

Returns
Search result, or NULL.
Parameters
masterEtherCAT master.
aliasSlave alias.
positionSlave position.

Definition at line 2026 of file master.c.

◆ ec_master_find_config_for_slave()

ec_slave_config_t* ec_master_find_config_for_slave ( ec_master_t *  master,
const ec_slave_t *  slave 
)

Finds the slave configuration that will be attached to the given slave.

Unlike ec_slave_config_attach(), this does not actually attach the configuration; it just looks one up by alias/position (and, if given, matching vendor ID/product code), which also works before the bus scan has completed and configurations have been attached to their slaves.

Returns
The matching slave configuration, or NULL, if none matches.
Parameters
masterEtherCAT master.
slaveSlave to find a configuration for.

Definition at line 2045 of file master.c.

◆ ec_master_config_count()

unsigned int ec_master_config_count ( const ec_master_t *  master)

Get the number of slave configurations provided by the application.

Returns
Number of configurations.
Parameters
masterEtherCAT master.

Definition at line 2082 of file master.c.

◆ ec_master_get_config()

ec_slave_config_t* ec_master_get_config ( const ec_master_t *  master,
unsigned int  pos 
)

Get a slave configuration via its position in the list.

Returns
Slave configuration or NULL.
Parameters
masterEtherCAT master.
posList position.

Definition at line 2115 of file master.c.

◆ ec_master_get_config_const()

const ec_slave_config_t* ec_master_get_config_const ( const ec_master_t *  master,
unsigned int  pos 
)

Get a slave configuration via its position in the list.

Const version.

Returns
Slave configuration or NULL.
Parameters
masterEtherCAT master.
posList position.

Definition at line 2130 of file master.c.

◆ ec_master_domain_count()

unsigned int ec_master_domain_count ( const ec_master_t *  master)

Get the number of domains.

Returns
Number of domains.
Parameters
masterEtherCAT master.

Definition at line 2145 of file master.c.

◆ ec_master_find_domain()

ec_domain_t* ec_master_find_domain ( ec_master_t *  master,
unsigned int  index 
)

Get a domain via its position in the list.

Returns
Domain pointer, or NULL if not found.
Parameters
masterEtherCAT master.
indexDomain index.

Definition at line 2179 of file master.c.

◆ ec_master_find_domain_const()

const ec_domain_t* ec_master_find_domain_const ( const ec_master_t *  master,
unsigned int  index 
)

Get a domain via its position in the list.

Const version.

Returns
Domain pointer, or NULL if not found.
Parameters
masterEtherCAT master.
indexDomain index.

Definition at line 2194 of file master.c.

◆ ec_master_eoe_handler_count()

uint16_t ec_master_eoe_handler_count ( const ec_master_t *  master)

Get the number of EoE handlers.

Returns
Number of EoE handlers.
Parameters
masterEtherCAT master.

Definition at line 2211 of file master.c.

◆ ec_master_get_eoe_handler_const()

const ec_eoe_t* ec_master_get_eoe_handler_const ( const ec_master_t *  master,
uint16_t  index 
)

Get an EoE handler via its position in the list.

Const version.

Returns
EoE handler pointer, or NULL if not found.
Parameters
masterEtherCAT master.
indexEoE handler index.

Definition at line 2233 of file master.c.

◆ ec_master_debug_level()

int ec_master_debug_level ( ec_master_t *  master,
unsigned int  level 
)

Set the debug level.

Return values
0Success.
-EINVALInvalid debug level.
Parameters
masterEtherCAT master.
levelDebug level. May be 0, 1 or 2.

Definition at line 2258 of file master.c.

◆ ec_master_calc_dc()

void ec_master_calc_dc ( ec_master_t *  master)

Distributed-clocks calculations.

Parameters
masterEtherCAT master.

Definition at line 2453 of file master.c.

◆ ec_master_request_op()

void ec_master_request_op ( ec_master_t *  master)

Request OP state for configured slaves.

Parameters
masterEtherCAT master.

Definition at line 2470 of file master.c.

◆ ec_master_find_cached_sii_page()

ec_sii_page_t* ec_master_find_cached_sii_page ( const ec_master_t *  master,
uint32_t  vendor_id,
uint32_t  product_code,
uint32_t  revision,
uint32_t  serial,
uint16_t  alias 
)

Find a matching cached SII page.

Returns pointer to the cached page, or zero if nothing usable found.

Parameters
masterEtherCAT master.

Definition at line 2549 of file master.c.

◆ ec_master_cache_sii_page()

int ec_master_cache_sii_page ( ec_master_t *  master,
const ec_sii_page_t *  page 
)

Add an SII page to the cache.

If caching is disabled or the page already exists, it is not added.

Returns non-zero on error.

Parameters
masterEtherCAT master.
pageSII page.

Definition at line 2577 of file master.c.

◆ ecrt_master_create_domain_err()

ec_domain_t* ecrt_master_create_domain_err ( ec_master_t *  master)

Same as ecrt_master_create_domain(), but with ERR_PTR() return value.

Returns
New domain, or ERR_PTR() return value.
Parameters
mastermaster

Definition at line 2641 of file master.c.

Variable Documentation

◆ rate_intervals

const unsigned int rate_intervals[]
Initial value:
= {
1, 10, 60
}

List of intervals for statistics [s].

Definition at line 111 of file master.c.