equal
deleted
inserted
replaced
154 \return 0 in case of success, else < 0 |
154 \return 0 in case of success, else < 0 |
155 */ |
155 */ |
156 |
156 |
157 int ec_device_open(ec_device_t *device /**< EtherCAT device */) |
157 int ec_device_open(ec_device_t *device /**< EtherCAT device */) |
158 { |
158 { |
159 unsigned int i; |
|
160 |
|
161 if (!device->dev) { |
159 if (!device->dev) { |
162 EC_ERR("No net_device to open!\n"); |
160 EC_ERR("No net_device to open!\n"); |
163 return -1; |
161 return -1; |
164 } |
162 } |
165 |
163 |
166 if (device->open) { |
164 if (device->open) { |
167 EC_WARN("Device already opened!\n"); |
165 EC_WARN("Device already opened!\n"); |
168 return 0; |
166 return 0; |
169 } |
167 } |
170 |
|
171 // device could have received frames before |
|
172 for (i = 0; i < 4; i++) ec_device_poll(device); |
|
173 |
168 |
174 device->link_state = 0; |
169 device->link_state = 0; |
175 device->tx_count = 0; |
170 device->tx_count = 0; |
176 device->rx_count = 0; |
171 device->rx_count = 0; |
177 |
172 |