Fixed bug in copying sync managers. Now making a deep copy.
--- a/master/slave.c Mon Mar 17 09:38:48 2008 +0000
+++ b/master/slave.c Mon Mar 17 14:16:16 2008 +0000
@@ -502,9 +502,8 @@
return -1;
}
- // copy existing sync managers
- memcpy(syncs, slave->sii.syncs,
- slave->sii.sync_count * sizeof(ec_sync_t));
+ for (i = 0; i < slave->sii.sync_count; i++)
+ ec_sync_init_copy(syncs + i, slave->sii.syncs + i);
// initialize new sync managers
for (i = 0; i < count; i++, data += 8) {
--- a/master/sync.c Mon Mar 17 09:38:48 2008 +0000
+++ b/master/sync.c Mon Mar 17 14:16:16 2008 +0000
@@ -62,6 +62,28 @@
/*****************************************************************************/
+/** Copy constructor.
+ */
+void ec_sync_init_copy(
+ ec_sync_t *sync, /**< EtherCAT sync manager. */
+ const ec_sync_t *other /**< Sync manager to copy from. */
+ )
+{
+ sync->slave = other->slave;
+ sync->index = other->index;
+ sync->physical_start_address = other->physical_start_address;
+ sync->length = other->length;
+ sync->control_register = other->control_register;
+ sync->enable = other->enable;
+
+ ec_pdo_mapping_init(&sync->mapping);
+ ec_pdo_mapping_copy(&sync->mapping, &other->mapping);
+
+ sync->mapping_source = other->mapping_source;
+}
+
+/*****************************************************************************/
+
/** Destructor.
*/
void ec_sync_clear(
--- a/master/sync.h Mon Mar 17 09:38:48 2008 +0000
+++ b/master/sync.h Mon Mar 17 14:16:16 2008 +0000
@@ -76,6 +76,7 @@
/*****************************************************************************/
void ec_sync_init(ec_sync_t *, ec_slave_t *, unsigned int);
+void ec_sync_init_copy(ec_sync_t *, const ec_sync_t *);
void ec_sync_clear(ec_sync_t *);
void ec_sync_config(const ec_sync_t *, uint16_t, uint8_t *);