mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-02-06 03:41:52 +08:00
Moved fetching domain offset to ecrt_master_activate().
This commit is contained in:
@@ -1866,7 +1866,7 @@ void ecrt_domain_external_memory(
|
||||
* \return Pointer to the process data memory.
|
||||
*/
|
||||
EC_PUBLIC_API uint8_t *ecrt_domain_data(
|
||||
ec_domain_t *domain /**< Domain. */
|
||||
const ec_domain_t *domain /**< Domain. */
|
||||
);
|
||||
|
||||
/** Determines the states of the domain's datagrams.
|
||||
|
||||
16
lib/domain.c
16
lib/domain.c
@@ -83,22 +83,8 @@ size_t ecrt_domain_size(const ec_domain_t *domain)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
uint8_t *ecrt_domain_data(ec_domain_t *domain)
|
||||
uint8_t *ecrt_domain_data(const ec_domain_t *domain)
|
||||
{
|
||||
if (!domain->process_data) {
|
||||
int offset = 0;
|
||||
|
||||
offset = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_OFFSET,
|
||||
domain->index);
|
||||
if (EC_IOCTL_IS_ERROR(offset)) {
|
||||
fprintf(stderr, "Failed to get domain offset: %s\n",
|
||||
strerror(EC_IOCTL_ERRNO(offset)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
domain->process_data = domain->master->process_data + offset;
|
||||
}
|
||||
|
||||
return domain->process_data;
|
||||
}
|
||||
|
||||
|
||||
15
lib/master.c
15
lib/master.c
@@ -585,6 +585,21 @@ int ecrt_master_activate(ec_master_t *master)
|
||||
master->process_data[0] = 0x00;
|
||||
}
|
||||
|
||||
// pick up process data pointers for all created domains
|
||||
ec_domain_t *domain = master->first_domain;
|
||||
while (domain) {
|
||||
int offset = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_OFFSET,
|
||||
domain->index);
|
||||
if (EC_IOCTL_IS_ERROR(offset)) {
|
||||
fprintf(stderr, "Failed to get domain offset: %s\n",
|
||||
strerror(EC_IOCTL_ERRNO(offset)));
|
||||
return -EC_IOCTL_ERRNO(offset);
|
||||
}
|
||||
|
||||
domain->process_data = master->process_data + offset;
|
||||
domain = domain->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ void ecrt_domain_external_memory(ec_domain_t *domain, uint8_t *mem)
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
uint8_t *ecrt_domain_data(ec_domain_t *domain)
|
||||
uint8_t *ecrt_domain_data(const ec_domain_t *domain)
|
||||
{
|
||||
return domain->data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user