master/domain.c
branchstable-1.1
changeset 1719 42ed27ae6785
parent 1717 cc1ee18207d3
child 1724 07c82e520ddd
equal deleted inserted replaced
1718:048c7310279c 1719:42ed27ae6785
   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;
   109     domain->notify_jiffies = 0;
   110     domain->working_counter_changes = 0;
   110     domain->working_counter_changes = 0;
   111 
   111 
   112     INIT_LIST_HEAD(&domain->data_regs);
   112     INIT_LIST_HEAD(&domain->data_regs);
   113     INIT_LIST_HEAD(&domain->datagrams);
   113     INIT_LIST_HEAD(&domain->datagrams);
   114 
   114 
   191     bit_offset = 0;
   191     bit_offset = 0;
   192     byte_offset = 0;
   192     byte_offset = 0;
   193     list_for_each_entry(other_pdo, &slave->sii_pdos, list) {
   193     list_for_each_entry(other_pdo, &slave->sii_pdos, list) {
   194         if (other_pdo->sync_index != sync->index) continue;
   194         if (other_pdo->sync_index != sync->index) continue;
   195 
   195 
   196         list_for_each_entry(other_entry, &pdo->entries, list) {
   196         list_for_each_entry(other_entry, &other_pdo->entries, list) {
   197             if (other_entry == entry) {
   197             if (other_entry == entry) {
   198                 byte_offset = bit_offset / 8;
   198                 byte_offset = bit_offset / 8;
   199                 break;
   199                 break;
   200             }
   200             }
   201             bit_offset += other_entry->bit_length;
   201             bit_offset += other_entry->bit_length;
   511 
   511 
   512 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */)
   512 void ecrt_domain_process(ec_domain_t *domain /**< EtherCAT domain */)
   513 {
   513 {
   514     unsigned int working_counter_sum;
   514     unsigned int working_counter_sum;
   515     ec_datagram_t *datagram;
   515     ec_datagram_t *datagram;
   516     cycles_t t_now = get_cycles();
       
   517 
   516 
   518     working_counter_sum = 0;
   517     working_counter_sum = 0;
   519     list_for_each_entry(datagram, &domain->datagrams, list) {
   518     list_for_each_entry(datagram, &domain->datagrams, list) {
   520         if (datagram->state == EC_DATAGRAM_RECEIVED) {
   519         if (datagram->state == EC_DATAGRAM_RECEIVED) {
   521             working_counter_sum += datagram->working_counter;
   520             working_counter_sum += datagram->working_counter;
   526         domain->working_counter_changes++;
   525         domain->working_counter_changes++;
   527         domain->response_count = working_counter_sum;
   526         domain->response_count = working_counter_sum;
   528     }
   527     }
   529 
   528 
   530     if (domain->working_counter_changes &&
   529     if (domain->working_counter_changes &&
   531         (u32) (t_now - domain->t_last) / cpu_khz > 1000) {
   530         jiffies - domain->notify_jiffies > HZ) {
   532         domain->t_last = t_now;
   531         domain->notify_jiffies = jiffies;
   533         if (domain->working_counter_changes == 1) {
   532         if (domain->working_counter_changes == 1) {
   534             EC_INFO("Domain %i working counter change: %i\n", domain->index,
   533             EC_INFO("Domain %i working counter change: %i\n", domain->index,
   535                     domain->response_count);
   534                     domain->response_count);
   536         }
   535         }
   537         else {
   536         else {