490 |
490 |
491 // did the slave not respond to its station address? |
491 // did the slave not respond to its station address? |
492 if (datagram->working_counter != 1) { |
492 if (datagram->working_counter != 1) { |
493 if (slave->online) { |
493 if (slave->online) { |
494 slave->online = 0; |
494 slave->online = 0; |
495 EC_INFO("Slave %i: offline.\n", slave->ring_position); |
495 if (master->debug_level) |
|
496 EC_DBG("Slave %i: offline.\n", slave->ring_position); |
496 } |
497 } |
497 ec_fsm_master_action_next_slave_state(fsm); |
498 ec_fsm_master_action_next_slave_state(fsm); |
498 return; |
499 return; |
499 } |
500 } |
500 |
501 |
501 // slave responded |
502 // slave responded |
502 new_state = EC_READ_U8(datagram->data); |
503 new_state = EC_READ_U8(datagram->data); |
503 if (!slave->online) { // slave was offline before |
504 if (!slave->online) { // slave was offline before |
504 char cur_state[EC_STATE_STRING_SIZE]; |
|
505 slave->online = 1; |
505 slave->online = 1; |
506 slave->error_flag = 0; // clear error flag |
506 slave->error_flag = 0; // clear error flag |
507 slave->current_state = new_state; |
507 slave->current_state = new_state; |
508 ec_state_string(slave->current_state, cur_state); |
508 if (master->debug_level) { |
509 EC_INFO("Slave %i: online (%s).\n", slave->ring_position, cur_state); |
509 char cur_state[EC_STATE_STRING_SIZE]; |
|
510 ec_state_string(slave->current_state, cur_state); |
|
511 EC_DBG("Slave %i: online (%s).\n", |
|
512 slave->ring_position, cur_state); |
|
513 } |
510 } |
514 } |
511 else if (new_state != slave->current_state) { |
515 else if (new_state != slave->current_state) { |
512 char old_state[EC_STATE_STRING_SIZE], cur_state[EC_STATE_STRING_SIZE]; |
516 if (master->debug_level) { |
513 ec_state_string(slave->current_state, old_state); |
517 char old_state[EC_STATE_STRING_SIZE], |
514 ec_state_string(new_state, cur_state); |
518 cur_state[EC_STATE_STRING_SIZE]; |
515 EC_INFO("Slave %i: %s -> %s.\n", |
519 ec_state_string(slave->current_state, old_state); |
516 slave->ring_position, old_state, cur_state); |
520 ec_state_string(new_state, cur_state); |
|
521 EC_DBG("Slave %i: %s -> %s.\n", |
|
522 slave->ring_position, old_state, cur_state); |
|
523 } |
517 slave->current_state = new_state; |
524 slave->current_state = new_state; |
518 } |
525 } |
519 |
526 |
520 // check, if new slave state has to be acknowledged |
527 // check, if new slave state has to be acknowledged |
521 if (slave->current_state & EC_SLAVE_STATE_ACK_ERR && !slave->error_flag) { |
528 if (slave->current_state & EC_SLAVE_STATE_ACK_ERR && !slave->error_flag) { |