diff -r 118dea2fa505 -r b6c87ae254c9 master/domain.c --- a/master/domain.c Fri Feb 22 16:04:23 2008 +0000 +++ b/master/domain.c Fri Feb 22 17:23:05 2008 +0000 @@ -54,6 +54,14 @@ /*****************************************************************************/ +/** Working counter increment values for logical read/write operations. + * + * \attention This is indexed by ec_direction_t. + */ +static const unsigned int working_counter_increment[] = {2, 1}; + +/*****************************************************************************/ + /** \cond */ EC_SYSFS_READ_ATTR(image_size); @@ -91,12 +99,14 @@ domain->master = master; domain->index = index; domain->data_size = 0; + domain->expected_working_counter = 0; domain->data = NULL; domain->data_origin = EC_ORIG_INTERNAL; domain->logical_base_address = 0L; domain->working_counter = 0xFFFFFFFF; + domain->state = 0; + domain->working_counter_changes = 0; domain->notify_jiffies = 0; - domain->working_counter_changes = 0; INIT_LIST_HEAD(&domain->datagrams); @@ -121,11 +131,10 @@ /*****************************************************************************/ -/** - Domain destructor. - Clears and frees a domain object. -*/ - +/** Domain destructor. + * + * Clears and frees a domain object. + */ void ec_domain_destroy(ec_domain_t *domain /**< EtherCAT domain */) { ec_datagram_t *datagram; @@ -143,12 +152,11 @@ /*****************************************************************************/ -/** - Clear and free domain. - This method is called by the kobject, - once there are no more references to it. -*/ - +/** Clear and free domain. + * + * This method is called by the kobject, once there are no more references + * to it. + */ void ec_domain_clear(struct kobject *kobj /**< kobject of the domain */) { ec_domain_t *domain; @@ -182,6 +190,21 @@ /*****************************************************************************/ +/** Adds an FMMU configuration to the domain. + */ +void ec_domain_add_fmmu_config( + ec_domain_t *domain, /**< EtherCAT domain. */ + ec_fmmu_config_t *fmmu /**< FMMU configuration. */ + ) +{ + fmmu->domain = domain; + + domain->data_size += fmmu->data_size; + domain->expected_working_counter += working_counter_increment[fmmu->dir]; +} + +/*****************************************************************************/ + /** Allocates a domain datagram and appends it to the list. * * \return 0 in case of success, else < 0 @@ -449,7 +472,16 @@ void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state) { state->working_counter = domain->working_counter; - state->wc_state = EC_WC_ZERO; // FIXME + + if (domain->working_counter) { + if (domain->working_counter == domain->expected_working_counter) { + state->wc_state = EC_WC_COMPLETE; + } else { + state->wc_state = EC_WC_INCOMPLETE; + } + } else { + state->wc_state = EC_WC_ZERO; + } } /*****************************************************************************/