mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-09-21 17:44:04 +08:00
Separated master requesting into open and reserve for userspace library.
(thanks to Martin Troxler).
This commit is contained in:
+17
-9
@@ -50,9 +50,25 @@ unsigned int ecrt_version_magic(void)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
ec_master_t *ecrt_request_master(unsigned int master_index)
|
||||
{
|
||||
ec_master_t *master = ecrt_open_master(master_index);
|
||||
if (master) {
|
||||
if (ecrt_master_reserve(master) < 0) {
|
||||
close(master->fd);
|
||||
free(master);
|
||||
master = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return master;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define MAX_PATH_LEN 64
|
||||
|
||||
ec_master_t *ecrt_request_master(unsigned int master_index)
|
||||
ec_master_t *ecrt_open_master(unsigned int master_index)
|
||||
{
|
||||
char path[MAX_PATH_LEN];
|
||||
ec_master_t *master;
|
||||
@@ -75,14 +91,6 @@ ec_master_t *ecrt_request_master(unsigned int master_index)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ioctl(master->fd, EC_IOCTL_REQUEST, NULL) == -1) {
|
||||
fprintf(stderr, "Failed to request master %u: %s\n",
|
||||
master_index, strerror(errno));
|
||||
close(master->fd);
|
||||
free(master);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return master;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user