diff -r 3b7eec329112 -r 8fede404c01f master/domain.c --- a/master/domain.c Wed Oct 25 16:53:17 2006 +0000 +++ b/master/domain.c Thu Oct 26 16:29:26 2006 +0000 @@ -139,8 +139,6 @@ domain = container_of(kobj, ec_domain_t, kobj); - EC_INFO("Clearing domain %i.\n", domain->index); - list_for_each_entry_safe(datagram, next, &domain->datagrams, list) { ec_datagram_clear(datagram); kfree(datagram); @@ -222,6 +220,9 @@ data_reg->data_ptr = data_ptr; list_add_tail(&data_reg->list, &domain->data_regs); + + ec_slave_request_state(slave, EC_SLAVE_STATE_OP); + return 0; } @@ -297,6 +298,9 @@ } list_add_tail(&data_reg->list, &domain->data_regs); + + ec_slave_request_state(slave, EC_SLAVE_STATE_OP); + return 0; } @@ -448,7 +452,7 @@ Places all process data datagrams in the masters datagram queue. */ -void ec_domain_queue(ec_domain_t *domain /**< EtherCAT domain */) +void ec_domain_queue_datagrams(ec_domain_t *domain /**< EtherCAT domain */) { ec_datagram_t *datagram; @@ -460,6 +464,22 @@ /*****************************************************************************/ /** + Dequeues all datagrams from the masters datagram queue. +*/ + +void ec_domain_dequeue_datagrams(ec_domain_t *domain /**< EtherCAT domain */) +{ + ec_datagram_t *datagram; + + list_for_each_entry(datagram, &domain->datagrams, list) { + if (!list_empty(&datagram->queue)) // datagram queued? + list_del_init(&datagram->queue); + } +} + +/*****************************************************************************/ + +/** Formats attribute data for SysFS reading. \return number of bytes to read */ @@ -518,18 +538,15 @@ if (!(slave = ecrt_master_get_slave(master, address))) return NULL; if (ec_slave_validate(slave, vendor_id, product_code)) return NULL; - if (!data_ptr) { - // data_ptr is NULL => mark slave as "registered" (do not warn) - slave->registered = 1; - } + if (!data_ptr) return slave; list_for_each_entry(pdo, &slave->sii_pdos, list) { list_for_each_entry(entry, &pdo->entries, list) { if (entry->index != pdo_index || entry->subindex != pdo_subindex) continue; - if (data_ptr) { - ec_domain_reg_pdo_entry(domain, slave, pdo, entry, data_ptr); + if (ec_domain_reg_pdo_entry(domain, slave, pdo, entry, data_ptr)) { + return NULL; } return slave; @@ -538,7 +555,6 @@ EC_ERR("Slave %i does not provide PDO 0x%04X:%i.\n", slave->ring_position, pdo_index, pdo_subindex); - slave->registered = 0; return NULL; } @@ -609,11 +625,7 @@ if (!(slave = ecrt_master_get_slave(master, address))) return NULL; if (ec_slave_validate(slave, vendor_id, product_code)) return NULL; - if (!data_ptr) { - // data_ptr is NULL => mark slave as "registered" (do not warn) - slave->registered = 1; - return slave; - } + if (!data_ptr) return slave; if (ec_domain_reg_pdo_range(domain, slave, direction, offset, length, data_ptr)) { @@ -666,7 +678,7 @@ domain->working_counter_changes = 0; } - ec_domain_queue(domain); + ec_domain_queue_datagrams(domain); } /*****************************************************************************/