slave.c File Reference


Detailed Description

EtherCAT slave methods.

Definition in file slave.c.

Go to the source code of this file.

Functions

int ec_slave_fetch_categories (ec_slave_t *slave)
 Fetches data from slave's EEPROM.
ssize_t ec_show_slave_attribute (struct kobject *kobj,struct attribute *attr,char *buffer)
 Formats attribute data for SysFS read access.
ssize_t ec_store_slave_attribute (struct kobject *kobj,struct attribute *attr,const char *buffer,size_t size)
 Formats attribute data for SysFS write access.
int ec_slave_init (ec_slave_t *slave, ec_master_t *master, uint16_t ring_position, uint16_t station_address)
 Slave constructor.
void ec_slave_clear (struct kobject *kobj)
 Slave destructor.
int ec_slave_fetch (ec_slave_t *slave)
 Reads all necessary information from a slave.
int ec_slave_sii_read16 (ec_slave_t *slave, uint16_t offset, uint16_t *target)
 Reads 16 bit from the slave information interface (SII).
int ec_slave_sii_read32 (ec_slave_t *slave, uint16_t offset, uint32_t *target)
 Reads 32 bit from the slave information interface (SII).
int ec_slave_sii_write16 (ec_slave_t *slave, uint16_t offset, uint16_t value)
 Writes 16 bit of data to the slave information interface (SII).
int ec_slave_fetch_strings (ec_slave_t *slave, const uint8_t *data)
 Fetches data from a STRING category.
int ec_slave_fetch_general (ec_slave_t *slave, const uint8_t *data)
 Fetches data from a GENERAL category.
int ec_slave_fetch_sync (ec_slave_t *slave, const uint8_t *data, size_t word_count)
 Fetches data from a SYNC MANAGER category.
int ec_slave_fetch_pdo (ec_slave_t *slave, const uint8_t *data, size_t word_count, ec_pdo_type_t pdo_type)
 Fetches data from a [RT]XPDO category.
int ec_slave_locate_string (ec_slave_t *slave, unsigned int index, char **ptr)
 Searches the string list for an index and allocates a new string.
void ec_slave_state_ack (ec_slave_t *slave, uint8_t state)
 Acknowledges an error after a state transition.
void ec_slave_read_al_status_code (ec_slave_t *slave)
 Reads the AL status code of a slave and displays it.
int ec_slave_state_change (ec_slave_t *slave, uint8_t state)
 Does a state transition.
int ec_slave_prepare_fmmu (ec_slave_t *slave, const ec_domain_t *domain, const ec_sync_t *sync)
 Prepares an FMMU configuration.
void ec_slave_print (const ec_slave_t *slave, unsigned int verbosity)
 Outputs all information about a certain slave.
int ec_slave_check_crc (ec_slave_t *slave)
 Outputs the values of the CRC faoult counters and resets them.
ssize_t ec_slave_write_eeprom (ec_slave_t *slave, const uint8_t *data, size_t size)
 Schedules an EEPROM write operation.
size_t ec_slave_calc_sync_size (const ec_slave_t *slave, const ec_sync_t *sync)
uint16_t ec_slave_calc_eeprom_sync_size (const ec_slave_t *slave, const ec_eeprom_sync_t *sync)
 Calculates the size of a sync manager by evaluating PDO sizes.
int ecrt_slave_write_alias (ec_slave_t *slave, uint16_t alias)
 Writes the "configured station alias" to the slave's EEPROM.
int ecrt_slave_field_size (ec_slave_t *slave, const char *field_name, unsigned int field_index, size_t size)

Variables

const ec_code_msg_t al_status_messages []
 Application layer status messages.


Function Documentation

int ec_slave_fetch_categories ec_slave_t slave  ) 
 

Fetches data from slave's EEPROM.

Returns:
0 in case of success, else < 0
Todo:
memory allocation
Parameters:
slave  EtherCAT slave

Definition at line 533 of file slave.c.

ssize_t ec_show_slave_attribute struct kobject *  kobj,
struct attribute *  attr,
char *  buffer
 

Formats attribute data for SysFS read access.

Returns:
number of bytes to read
Parameters:
kobj  slave's kobject
attr  attribute
buffer  memory to store data

Definition at line 1346 of file slave.c.

ssize_t ec_store_slave_attribute struct kobject *  kobj,
struct attribute *  attr,
const char *  buffer,
size_t  size
 

Formats attribute data for SysFS write access.

Returns:
number of bytes processed, or negative error code
Parameters:
kobj  slave's kobject
attr  attribute
buffer  memory with data
size  size of data to store

Definition at line 1424 of file slave.c.

int ec_slave_init ec_slave_t slave,
ec_master_t master,
uint16_t  ring_position,
uint16_t  station_address
 

Slave constructor.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
master  EtherCAT master
ring_position  ring position
station_address  station address to configure

Definition at line 107 of file slave.c.

void ec_slave_clear struct kobject *  kobj  ) 
 

Slave destructor.

Parameters:
kobj  kobject of the slave

Definition at line 185 of file slave.c.

int ec_slave_fetch ec_slave_t slave  ) 
 

Reads all necessary information from a slave.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave

Definition at line 260 of file slave.c.

int ec_slave_sii_read16 ec_slave_t slave,
uint16_t  offset,
uint16_t *  target
 

Reads 16 bit from the slave information interface (SII).

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
offset  address of the SII register to read
target  target memory

Definition at line 339 of file slave.c.

int ec_slave_sii_read32 ec_slave_t slave,
uint16_t  offset,
uint32_t *  target
 

Reads 32 bit from the slave information interface (SII).

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
offset  address of the SII register to read
target  target memory

Definition at line 400 of file slave.c.

int ec_slave_sii_write16 ec_slave_t slave,
uint16_t  offset,
uint16_t  value
 

Writes 16 bit of data to the slave information interface (SII).

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
offset  address of the SII register to write
value  new value

Definition at line 461 of file slave.c.

int ec_slave_fetch_strings ec_slave_t slave,
const uint8_t *  data
 

Fetches data from a STRING category.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
data  category data

Definition at line 625 of file slave.c.

int ec_slave_fetch_general ec_slave_t slave,
const uint8_t *  data
 

Fetches data from a GENERAL category.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
data  category data

Definition at line 663 of file slave.c.

int ec_slave_fetch_sync ec_slave_t slave,
const uint8_t *  data,
size_t  word_count
 

Fetches data from a SYNC MANAGER category.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
data  category data
word_count  number of words

Definition at line 692 of file slave.c.

int ec_slave_fetch_pdo ec_slave_t slave,
const uint8_t *  data,
size_t  word_count,
ec_pdo_type_t  pdo_type
 

Fetches data from a [RT]XPDO category.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
data  category data
word_count  number of words
pdo_type  PDO type

Definition at line 728 of file slave.c.

int ec_slave_locate_string ec_slave_t slave,
unsigned int  index,
char **  ptr
 

Searches the string list for an index and allocates a new string.

Returns:
0 in case of success, else < 0
Todo:
documentation
Parameters:
slave  EtherCAT slave
index  string index
ptr  Address of the string pointer

Definition at line 790 of file slave.c.

void ec_slave_state_ack ec_slave_t slave,
uint8_t  state
 

Acknowledges an error after a state transition.

Parameters:
slave  EtherCAT slave
state  previous state

Definition at line 838 of file slave.c.

void ec_slave_read_al_status_code ec_slave_t slave  ) 
 

Reads the AL status code of a slave and displays it.

If the AL status code is not supported, or if no error occurred (both resulting in code = 0), nothing is displayed.

Parameters:
slave  EtherCAT slave

Definition at line 896 of file slave.c.

int ec_slave_state_change ec_slave_t slave,
uint8_t  state
 

Does a state transition.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
state  new state

Definition at line 931 of file slave.c.

int ec_slave_prepare_fmmu ec_slave_t slave,
const ec_domain_t domain,
const ec_sync_t sync
 

Prepares an FMMU configuration.

Configuration data for the FMMU is saved in the slave structure and is written to the slave in ecrt_master_activate(). The FMMU configuration is done in a way, that the complete data range of the corresponding sync manager is covered. Seperate FMMUs arce configured for each domain. If the FMMU configuration is already prepared, the function returns with success.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
domain  domain
sync  sync manager

Definition at line 1009 of file slave.c.

void ec_slave_print const ec_slave_t slave,
unsigned int  verbosity
 

Outputs all information about a certain slave.

Verbosity:

  • 0: Only slave types and addresses
  • 1: with EEPROM information
  • >1: with SDO dictionaries
Parameters:
slave  EtherCAT slave
verbosity  verbosity level

Definition at line 1047 of file slave.c.

int ec_slave_check_crc ec_slave_t slave  ) 
 

Outputs the values of the CRC faoult counters and resets them.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave

Definition at line 1212 of file slave.c.

ssize_t ec_slave_write_eeprom ec_slave_t slave,
const uint8_t *  data,
size_t  size
 

Schedules an EEPROM write operation.

Returns:
0 in case of success, else < 0
Parameters:
slave  EtherCAT slave
data  new EEPROM data
size  size of data in bytes

Definition at line 1269 of file slave.c.

size_t ec_slave_calc_sync_size const ec_slave_t slave,
const ec_sync_t sync
 

Returns:
size of sync manager contents
Parameters:
slave  EtherCAT slave
sync  sync manager

Definition at line 1465 of file slave.c.

uint16_t ec_slave_calc_eeprom_sync_size const ec_slave_t slave,
const ec_eeprom_sync_t sync
 

Calculates the size of a sync manager by evaluating PDO sizes.

Returns:
sync manager size
Parameters:
slave  EtherCAT slave
sync  sync manager

Definition at line 1503 of file slave.c.


Generated on Wed Aug 2 18:41:44 2006 for IgH EtherCAT master by  doxygen 1.4.6