Bugfix: Registrieren von mehreren Feldern gleichzeitig geht jetzt.
authorFlorian Pose <fp@igh-essen.com>
Sun, 19 Mar 2006 15:21:57 +0000
changeset 108 dc3d56151d07
parent 107 b4546c37f28f
child 109 c6766baead5e
Bugfix: Registrieren von mehreren Feldern gleichzeitig geht jetzt.
master/domain.c
--- a/master/domain.c	Sun Mar 19 14:58:49 2006 +0000
+++ b/master/domain.c	Sun Mar 19 15:21:57 2006 +0000
@@ -254,7 +254,7 @@
     ec_master_t *master;
     const ec_sync_t *sync;
     const ec_field_t *field;
-    unsigned int field_idx, i, j;
+    unsigned int field_counter, i, j, orig_field_index, orig_field_count;
     uint32_t field_offset;
 
     if (!field_count) {
@@ -281,19 +281,22 @@
         return NULL;
     }
 
-    field_idx = 0;
+    orig_field_index = field_index;
+    orig_field_count = field_count;
+
+    field_counter = 0;
     for (i = 0; type->sync_managers[i]; i++) {
         sync = type->sync_managers[i];
         field_offset = 0;
         for (j = 0; sync->fields[j]; j++) {
             field = sync->fields[j];
             if (!strcmp(field->name, field_name)) {
-                if (field_idx == field_index) {
+                if (field_counter++ == field_index) {
                     ec_domain_reg_field(domain, slave, sync, field_offset,
                                         data_ptr++);
                     if (!(--field_count)) return slave;
+                    field_index++;
                 }
-                field_idx++;
             }
             field_offset += field->size;
         }
@@ -301,7 +304,7 @@
 
     EC_ERR("Slave %i (\"%s %s\") registration mismatch: Field \"%s\","
            " index %i, count %i.\n", slave->ring_position, vendor_name,
-           product_name, field_name, field_index, field_count);
+           product_name, field_name, orig_field_index, orig_field_count);
     return NULL;
 }