Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
authorFlorian Pose <fp@igh-essen.com>
Tue, 01 Aug 2006 14:15:33 +0000
changeset 320 71d559ec66d7
parent 319 88f2e8c4face
child 321 64e20e6e9d0b
Fixed bug with bit-sized PDOs leading to wrong Sync-Manager sizes.
master/slave.c
--- a/master/slave.c	Mon Jul 31 18:52:06 2006 +0000
+++ b/master/slave.c	Tue Aug 01 14:15:33 2006 +0000
@@ -1508,20 +1508,23 @@
 {
     ec_eeprom_pdo_t *pdo;
     ec_eeprom_pdo_entry_t *pdo_entry;
-    uint16_t size;
+    unsigned int bit_size;
 
     if (sync->length) return sync->length;
 
-    size = 0;
+    bit_size = 0;
     list_for_each_entry(pdo, &slave->eeprom_pdos, list) {
         if (pdo->sync_manager != sync->index) continue;
 
         list_for_each_entry(pdo_entry, &pdo->entries, list) {
-            size += pdo_entry->bit_length / 8;
-        }
-    }
-
-    return size;
+            bit_size += pdo_entry->bit_length;
+        }
+    }
+
+    if (bit_size % 8) // round up to full bytes
+        return bit_size / 8 + 1;
+    else
+        return bit_size / 8;
 }
 
 /******************************************************************************