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

This commit is contained in:
Florian Pose 2008-03-17 14:16:16 +00:00
parent f69b21af02
commit f4199b7f60
3 changed files with 25 additions and 3 deletions

View File

@ -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) {

View File

@ -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(

View File

@ -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 *);