Skip to content
Snippets Groups Projects
Commit 4212235a authored by Florian Pose's avatar Florian Pose
Browse files

Fixed bug in copying sync managers. Now making a deep copy.

parent ebba6f47
No related branches found
No related tags found
No related merge requests found
......@@ -502,9 +502,8 @@ int ec_slave_fetch_sii_syncs(
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) {
......
......@@ -62,6 +62,28 @@ void ec_sync_init(
/*****************************************************************************/
/** 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(
......
......@@ -76,6 +76,7 @@ typedef struct {
/*****************************************************************************/
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 *);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment