36 EtherCAT domain methods. |
36 EtherCAT domain methods. |
37 */ |
37 */ |
38 |
38 |
39 /*****************************************************************************/ |
39 /*****************************************************************************/ |
40 |
40 |
|
41 #include <sys/ioctl.h> |
|
42 #include <sys/mman.h> |
|
43 #include <stdio.h> |
|
44 #include <errno.h> |
|
45 #include <string.h> |
|
46 |
41 #include "domain.h" |
47 #include "domain.h" |
|
48 #include "master.h" |
|
49 #include "master/ioctl.h" |
42 |
50 |
43 /*****************************************************************************/ |
51 /*****************************************************************************/ |
44 |
52 |
45 int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain, |
53 int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain, |
46 const ec_pdo_entry_reg_t *regs) |
54 const ec_pdo_entry_reg_t *regs) |
66 |
74 |
67 /*****************************************************************************/ |
75 /*****************************************************************************/ |
68 |
76 |
69 uint8_t *ecrt_domain_data(ec_domain_t *domain) |
77 uint8_t *ecrt_domain_data(ec_domain_t *domain) |
70 { |
78 { |
71 return 0; |
79 if (!domain->process_data) { |
|
80 int offset = 0; |
|
81 |
|
82 offset = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_OFFSET, |
|
83 domain->index); |
|
84 if (offset == -1) { |
|
85 fprintf(stderr, "Failed to get domain offset: %s\n", |
|
86 strerror(errno)); |
|
87 return NULL; |
|
88 } |
|
89 |
|
90 domain->process_data = domain->master->process_data + offset; |
|
91 } |
|
92 |
|
93 return domain->process_data; |
72 } |
94 } |
73 |
95 |
74 /*****************************************************************************/ |
96 /*****************************************************************************/ |
75 |
97 |
76 void ecrt_domain_process(ec_domain_t *domain) |
98 void ecrt_domain_process(ec_domain_t *domain) |
77 { |
99 { |
|
100 if (ioctl(domain->master->fd, EC_IOCTL_DOMAIN_PROCESS, |
|
101 domain->index) == -1) { |
|
102 fprintf(stderr, "Failed to process domain offset: %s\n", |
|
103 strerror(errno)); |
|
104 } |
78 } |
105 } |
79 |
106 |
80 /*****************************************************************************/ |
107 /*****************************************************************************/ |
81 |
108 |
82 void ecrt_domain_queue(ec_domain_t *domain) |
109 void ecrt_domain_queue(ec_domain_t *domain) |
83 { |
110 { |
|
111 if (ioctl(domain->master->fd, EC_IOCTL_DOMAIN_QUEUE, |
|
112 domain->index) == -1) { |
|
113 fprintf(stderr, "Failed to queue domain offset: %s\n", |
|
114 strerror(errno)); |
|
115 } |
84 } |
116 } |
85 |
117 |
86 /*****************************************************************************/ |
118 /*****************************************************************************/ |
87 |
119 |
88 void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state) |
120 void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state) |