104 domain->master = master; |
104 domain->master = master; |
105 domain->index = index; |
105 domain->index = index; |
106 domain->data_size = 0; |
106 domain->data_size = 0; |
107 domain->base_address = 0; |
107 domain->base_address = 0; |
108 domain->response_count = 0xFFFFFFFF; |
108 domain->response_count = 0xFFFFFFFF; |
|
109 domain->t_last = 0; |
|
110 domain->working_counter_changes = 0; |
109 |
111 |
110 INIT_LIST_HEAD(&domain->data_regs); |
112 INIT_LIST_HEAD(&domain->data_regs); |
111 INIT_LIST_HEAD(&domain->datagrams); |
113 INIT_LIST_HEAD(&domain->datagrams); |
112 |
114 |
113 // init kobject and add it to the hierarchy |
115 // init kobject and add it to the hierarchy |
149 } |
151 } |
150 |
152 |
151 /*****************************************************************************/ |
153 /*****************************************************************************/ |
152 |
154 |
153 /** |
155 /** |
154 Registeres a data field in a domain. |
156 Registeres a PDO entry. |
155 \return 0 in case of success, else < 0 |
157 \return 0 in case of success, else < 0 |
156 */ |
158 */ |
157 |
159 |
158 int ec_domain_reg_pdo_entry(ec_domain_t *domain, /**< EtherCAT domain */ |
160 int ec_domain_reg_pdo_entry(ec_domain_t *domain, /**< EtherCAT domain */ |
159 ec_slave_t *slave, /**< slave */ |
161 ec_slave_t *slave, /**< slave */ |
223 } |
225 } |
224 |
226 |
225 /*****************************************************************************/ |
227 /*****************************************************************************/ |
226 |
228 |
227 /** |
229 /** |
228 Clears the list of the registered data fields. |
230 Clears the list of the data registrations. |
229 */ |
231 */ |
230 |
232 |
231 void ec_domain_clear_data_regs(ec_domain_t *domain /**< EtherCAT domain */) |
233 void ec_domain_clear_data_regs(ec_domain_t *domain /**< EtherCAT domain */) |
232 { |
234 { |
233 ec_data_reg_t *data_reg, *next; |
235 ec_data_reg_t *data_reg, *next; |
509 |
511 |
510 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) |
512 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */) |
511 { |
513 { |
512 unsigned int working_counter_sum; |
514 unsigned int working_counter_sum; |
513 ec_datagram_t *datagram; |
515 ec_datagram_t *datagram; |
|
516 cycles_t t_now = get_cycles(); |
514 |
517 |
515 working_counter_sum = 0; |
518 working_counter_sum = 0; |
516 list_for_each_entry(datagram, &domain->datagrams, list) { |
519 list_for_each_entry(datagram, &domain->datagrams, list) { |
517 if (datagram->state == EC_DATAGRAM_RECEIVED) { |
520 if (datagram->state == EC_DATAGRAM_RECEIVED) { |
518 working_counter_sum += datagram->working_counter; |
521 working_counter_sum += datagram->working_counter; |
519 } |
522 } |
520 } |
523 } |
521 |
524 |
522 if (working_counter_sum != domain->response_count) { |
525 if (working_counter_sum != domain->response_count) { |
|
526 domain->working_counter_changes++; |
523 domain->response_count = working_counter_sum; |
527 domain->response_count = working_counter_sum; |
524 EC_INFO("Domain %i working counter change: %i\n", domain->index, |
528 } |
525 domain->response_count); |
529 |
|
530 if (domain->working_counter_changes && |
|
531 (u32) (t_now - domain->t_last) / cpu_khz > 1000) { |
|
532 domain->t_last = t_now; |
|
533 if (domain->working_counter_changes == 1) { |
|
534 EC_INFO("Domain %i working counter change: %i\n", domain->index, |
|
535 domain->response_count); |
|
536 } |
|
537 else { |
|
538 EC_INFO("Domain %i: %u WC changes. Current response count: %i\n", |
|
539 domain->index, domain->working_counter_changes, |
|
540 domain->response_count); |
|
541 } |
|
542 domain->working_counter_changes = 0; |
526 } |
543 } |
527 |
544 |
528 ec_domain_queue(domain); |
545 ec_domain_queue(domain); |
529 } |
546 } |
530 |
547 |