--- etherlabmaster-072c172e6a85/master/domain.c	2011-05-25 09:54:47.000000000 +-0100
+++ etherlabmaster-072c172e6a85/master/domain.c	2013-03-04 08:43:31.000000000 +-0100
@@ -236,20 +236,12 @@
     }
 
     list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
         // Correct logical FMMU address
         fmmu->logical_start_address += base_address;
 
-        // Increment Input/Output counter to determine datagram types
-        // and calculate expected working counters
-        if (fmmu->sc->used_for_fmmu_datagram[fmmu->dir] == 0) {
-            ec_slave_config_t *sc = (ec_slave_config_t *)fmmu->sc;
-            datagram_used[fmmu->dir]++;
-            sc->used_for_fmmu_datagram[fmmu->dir] = 1;
-        }
-
         // If the current FMMU's data do not fit in the current datagram,
         // allocate a new one.
         if (datagram_size + fmmu->data_size > EC_MAX_DATA_SIZE) {
             ret = ec_domain_add_datagram(domain,
                     domain->logical_base_address + datagram_offset,
                     datagram_size, domain->data + datagram_offset,
@@ -264,12 +256,19 @@
             list_for_each_entry(fmmu_temp, &domain->fmmu_configs, list) {
                 ec_slave_config_t *sc = (ec_slave_config_t *)fmmu_temp->sc;
                sc->used_for_fmmu_datagram[fmmu_temp->dir] = 0;
             }
         }
 
+        // Increment Input/Output counter to determine datagram types
+        // and calculate expected working counters
+        if (fmmu->sc->used_for_fmmu_datagram[fmmu->dir] == 0) {
+            ec_slave_config_t *sc = (ec_slave_config_t *)fmmu->sc;
+            datagram_used[fmmu->dir]++;
+            sc->used_for_fmmu_datagram[fmmu->dir] = 1;
+        }
         datagram_size += fmmu->data_size;
     }
 
     // Allocate last datagram, if data are left (this is also the case if the
     // process data fit into a single datagram)
     if (datagram_size) {
