diff -r 63bef67e812b -r fdb85a806585 include/ecrt.h --- a/include/ecrt.h Thu Sep 06 14:40:10 2012 +0200 +++ b/include/ecrt.h Thu Sep 06 18:28:57 2012 +0200 @@ -39,6 +39,14 @@ * request a master, to map process data, to communicate with slaves via CoE * and to configure and activate the bus. * + * Changed since 1.5: + * + * - Added redundancy_active flag to ec_domain_state_t. + * - Added ecrt_master_link_state() method and ec_master_link_state_t to query + * the state of a redundant link. + * - Added the EC_HAVE_REDUNDANCY define, to check, if the interface contains + * redundancy features. + * * Changes in version 1.5: * * - Added the distributed clocks feature and the respective method @@ -119,6 +127,17 @@ */ #define ECRT_VERSION_MAGIC ECRT_VERSION(ECRT_VER_MAJOR, ECRT_VER_MINOR) +/****************************************************************************** + * Feature flags + *****************************************************************************/ + +/** Defined, if the redundancy features are available. + * + * I. e. if the \a redundancy_active flag in ec_domain_state_t and the + * ecrt_master_link_state() method are available. + */ +#define EC_HAVE_REDUNDANCY + /*****************************************************************************/ /** End of list marker. @@ -179,7 +198,8 @@ * \see ecrt_master_state(). */ typedef struct { - unsigned int slaves_responding; /**< Number of slaves in the bus. */ + unsigned int slaves_responding; /**< Sum of responding slaves on all + Ethernet devices. */ unsigned int al_states : 4; /**< Application-layer states of all slaves. The states are coded in the lower 4 bits. If a bit is set, it means that at least one @@ -189,11 +209,36 @@ - Bit 1: \a PREOP - Bit 2: \a SAFEOP - Bit 3: \a OP */ - unsigned int link_up : 1; /**< \a true, if the network link is up. */ + unsigned int link_up : 1; /**< \a true, if at least one Ethernet link is + up. */ } ec_master_state_t; /*****************************************************************************/ +/** Redundant link state. + * + * This is used for the output parameter of ecrt_master_link_state(). + * + * \see ecrt_master_link_state(). + */ +typedef struct { + unsigned int slaves_responding; /**< Sum of responding slaves on the given + link. */ + unsigned int al_states : 4; /**< Application-layer states of the slaves on + the given link. The states are coded in the + lower 4 bits. If a bit is set, it means + that at least one slave in the bus is in the + corresponding state: + - Bit 0: \a INIT + - Bit 1: \a PREOP + - Bit 2: \a SAFEOP + - Bit 3: \a OP */ + unsigned int link_up : 1; /**< \a true, if the given Ethernet link is up. + */ +} ec_master_link_state_t; + +/*****************************************************************************/ + /** Slave configuration state. * * This is used as an output parameter of ecrt_slave_config_state(). @@ -304,6 +349,7 @@ typedef struct { unsigned int working_counter; /**< Value of the last working counter. */ ec_wc_state_t wc_state; /**< Working counter interpretation. */ + unsigned int redundancy_active; /**< Redundant link is in use. */ } ec_domain_state_t; /*****************************************************************************/ @@ -848,12 +894,29 @@ /** Reads the current master state. * * Stores the master state information in the given \a state structure. + * + * This method returns a global state. For the link-specific states in a + * redundant bus topology, use the ecrt_master_link_state() method. */ void ecrt_master_state( const ec_master_t *master, /**< EtherCAT master. */ ec_master_state_t *state /**< Structure to store the information. */ ); +/** Reads the current state of a redundant link. + * + * Stores the link state information in the given \a state structure. + * + * \return Zero on success, otherwise negative error code. + */ +int ecrt_master_link_state( + const ec_master_t *master, /**< EtherCAT master. */ + unsigned int dev_idx, /**< Index of the device (0 = main device, 1 = + first backup device, ...). */ + ec_master_link_state_t *state /**< Structure to store the information. + */ + ); + /** Sets the application time. * * The master has to know the application's time when operating slaves with