equal
deleted
inserted
replaced
177 |
177 |
178 /** |
178 /** |
179 Slave scan state: ADDRESS. |
179 Slave scan state: ADDRESS. |
180 */ |
180 */ |
181 |
181 |
182 void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
182 void ec_fsm_slave_scan_state_address( |
|
183 ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
|
184 ) |
183 { |
185 { |
184 ec_datagram_t *datagram = fsm->datagram; |
186 ec_datagram_t *datagram = fsm->datagram; |
185 |
187 |
186 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
188 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
187 return; |
189 return; |
188 |
190 |
189 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
191 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
190 fsm->state = ec_fsm_slave_scan_state_error; |
192 fsm->state = ec_fsm_slave_scan_state_error; |
191 EC_ERR("Failed to receive station address datagram for slave %u" |
193 EC_ERR("Failed to receive station address datagram for slave %u: ", |
192 " (datagram state %u)\n", |
194 fsm->slave->ring_position); |
193 fsm->slave->ring_position, datagram->state); |
195 ec_datagram_print_state(datagram); |
194 return; |
196 return; |
195 } |
197 } |
196 |
198 |
197 if (datagram->working_counter != 1) { |
199 if (datagram->working_counter != 1) { |
198 fsm->slave->error_flag = 1; |
200 fsm->slave->error_flag = 1; |
226 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
228 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
227 return; |
229 return; |
228 |
230 |
229 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
231 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
230 fsm->state = ec_fsm_slave_scan_state_error; |
232 fsm->state = ec_fsm_slave_scan_state_error; |
231 EC_ERR("Failed to receive AL state datagram from slave %u" |
233 EC_ERR("Failed to receive AL state datagram from slave %u: ", |
232 " (datagram state %u).\n", |
234 fsm->slave->ring_position); |
233 fsm->slave->ring_position, datagram->state); |
235 ec_datagram_print_state(datagram); |
234 return; |
236 return; |
235 } |
237 } |
236 |
238 |
237 if (datagram->working_counter != 1) { |
239 if (datagram->working_counter != 1) { |
238 fsm->slave->error_flag = 1; |
240 fsm->slave->error_flag = 1; |
274 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
276 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
275 return; |
277 return; |
276 |
278 |
277 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
279 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
278 fsm->state = ec_fsm_slave_scan_state_error; |
280 fsm->state = ec_fsm_slave_scan_state_error; |
279 EC_ERR("Failed to receive base data datagram for slave %u" |
281 EC_ERR("Failed to receive base data datagram for slave %u: ", |
280 " (datagram state %u).\n", |
282 slave->ring_position); |
281 slave->ring_position, datagram->state); |
283 ec_datagram_print_state(datagram); |
282 return; |
284 return; |
283 } |
285 } |
284 |
286 |
285 if (datagram->working_counter != 1) { |
287 if (datagram->working_counter != 1) { |
286 fsm->slave->error_flag = 1; |
288 fsm->slave->error_flag = 1; |
349 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
351 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
350 return; |
352 return; |
351 |
353 |
352 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
354 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
353 fsm->state = ec_fsm_slave_scan_state_error; |
355 fsm->state = ec_fsm_slave_scan_state_error; |
354 EC_ERR("Failed to receive system time datagram for slave %u" |
356 EC_ERR("Failed to receive system time datagram for slave %u: ", |
355 " (datagram state %u).\n", |
357 slave->ring_position); |
356 slave->ring_position, datagram->state); |
358 ec_datagram_print_state(datagram); |
357 return; |
359 return; |
358 } |
360 } |
359 |
361 |
360 if (datagram->working_counter == 1) { |
362 if (datagram->working_counter == 1) { |
361 slave->has_dc_system_time = 1; |
363 slave->has_dc_system_time = 1; |
401 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
403 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
402 return; |
404 return; |
403 |
405 |
404 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
406 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
405 fsm->state = ec_fsm_slave_scan_state_error; |
407 fsm->state = ec_fsm_slave_scan_state_error; |
406 EC_ERR("Failed to receive system time datagram for slave %u" |
408 EC_ERR("Failed to receive system time datagram for slave %u: ", |
407 " (datagram state %u).\n", |
409 slave->ring_position); |
408 slave->ring_position, datagram->state); |
410 ec_datagram_print_state(datagram); |
409 return; |
411 return; |
410 } |
412 } |
411 |
413 |
412 if (datagram->working_counter != 1) { |
414 if (datagram->working_counter != 1) { |
413 fsm->slave->error_flag = 1; |
415 fsm->slave->error_flag = 1; |
461 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
463 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
462 return; |
464 return; |
463 |
465 |
464 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
466 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
465 fsm->state = ec_fsm_slave_scan_state_error; |
467 fsm->state = ec_fsm_slave_scan_state_error; |
466 EC_ERR("Failed to receive DL status datagram from slave %u" |
468 EC_ERR("Failed to receive DL status datagram from slave %u: ", |
467 " (datagram state %u).\n", |
469 slave->ring_position); |
468 slave->ring_position, datagram->state); |
470 ec_datagram_print_state(datagram); |
469 return; |
471 return; |
470 } |
472 } |
471 |
473 |
472 if (datagram->working_counter != 1) { |
474 if (datagram->working_counter != 1) { |
473 fsm->slave->error_flag = 1; |
475 fsm->slave->error_flag = 1; |
761 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
763 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
762 return; |
764 return; |
763 |
765 |
764 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
766 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
765 fsm->state = ec_fsm_slave_scan_state_error; |
767 fsm->state = ec_fsm_slave_scan_state_error; |
766 EC_ERR("Failed to receive get reg alias datagram from slave %u" |
768 EC_ERR("Failed to receive get reg alias datagram from slave %u: ", |
767 " (datagram state %u).\n", |
769 fsm->slave->ring_position); |
768 fsm->slave->ring_position, datagram->state); |
770 ec_datagram_print_state(datagram); |
769 return; |
771 return; |
770 } |
772 } |
771 |
773 |
772 if (datagram->working_counter != 1) { |
774 if (datagram->working_counter != 1) { |
773 EC_WARN("Failed to read reg alias of slave %u.\n", |
775 EC_WARN("Failed to read reg alias of slave %u.\n", |
858 return; |
860 return; |
859 |
861 |
860 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
862 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
861 fsm->state = ec_fsm_slave_scan_state_error; |
863 fsm->state = ec_fsm_slave_scan_state_error; |
862 EC_ERR("Failed to receive sync manager configuration datagram" |
864 EC_ERR("Failed to receive sync manager configuration datagram" |
863 " from slave %u (datagram state %u).\n", |
865 " from slave %u: ", slave->ring_position); |
864 slave->ring_position, datagram->state); |
866 ec_datagram_print_state(datagram); |
865 return; |
867 return; |
866 } |
868 } |
867 |
869 |
868 if (datagram->working_counter != 1) { |
870 if (datagram->working_counter != 1) { |
869 fsm->slave->error_flag = 1; |
871 fsm->slave->error_flag = 1; |