equal
deleted
inserted
replaced
37 #include <errno.h> |
37 #include <errno.h> |
38 #include <string.h> |
38 #include <string.h> |
39 |
39 |
40 #include "master.h" |
40 #include "master.h" |
41 #include "domain.h" |
41 #include "domain.h" |
|
42 #include "slave_config.h" |
42 #include "master/ioctl.h" |
43 #include "master/ioctl.h" |
43 |
44 |
44 /*****************************************************************************/ |
45 /*****************************************************************************/ |
45 |
46 |
46 ec_domain_t *ecrt_master_create_domain(ec_master_t *master) |
47 ec_domain_t *ecrt_master_create_domain(ec_master_t *master) |
69 |
70 |
70 ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, |
71 ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, |
71 uint16_t alias, uint16_t position, uint32_t vendor_id, |
72 uint16_t alias, uint16_t position, uint32_t vendor_id, |
72 uint32_t product_code) |
73 uint32_t product_code) |
73 { |
74 { |
74 return 0; |
75 ec_ioctl_config_t data; |
|
76 ec_slave_config_t *sc; |
|
77 int index; |
|
78 |
|
79 sc = malloc(sizeof(ec_slave_config_t)); |
|
80 if (!sc) { |
|
81 fprintf(stderr, "Failed to allocate memory.\n"); |
|
82 return 0; |
|
83 } |
|
84 |
|
85 data.alias = alias; |
|
86 data.position = position; |
|
87 data.vendor_id = vendor_id; |
|
88 data.product_code = product_code; |
|
89 |
|
90 if (ioctl(master->fd, EC_IOCTL_CREATE_SLAVE_CONFIG, &data) == -1) { |
|
91 fprintf(stderr, "Failed to create slave config: %s\n", |
|
92 strerror(errno)); |
|
93 free(sc); |
|
94 return 0; |
|
95 } |
|
96 |
|
97 sc->index = data.config_index; |
|
98 return sc; |
75 } |
99 } |
76 |
100 |
77 /*****************************************************************************/ |
101 /*****************************************************************************/ |
78 |
102 |
79 int ecrt_master_activate(ec_master_t *master) |
103 int ecrt_master_activate(ec_master_t *master) |