--- a/master/fsm_change.c Fri May 07 15:26:26 2010 +0200
+++ b/master/fsm_change.c Tue May 11 13:57:58 2010 +0200
@@ -182,8 +182,7 @@
if (datagram->state != EC_DATAGRAM_RECEIVED) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to receive state datagram from slave %u: ",
- fsm->slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to receive state datagram: ");
ec_datagram_print_state(datagram);
return;
}
@@ -198,8 +197,7 @@
char state_str[EC_STATE_STRING_SIZE];
ec_state_string(fsm->requested_state, state_str, 0);
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to set state %s on slave %u: ",
- state_str, fsm->slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to set state %s: ", state_str);
ec_datagram_print_wc_error(datagram);
return;
}
@@ -215,8 +213,7 @@
char state_str[EC_STATE_STRING_SIZE];
ec_state_string(fsm->requested_state, state_str, 0);
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to set state %s on slave %u: ",
- state_str, fsm->slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to set state %s: ", state_str);
ec_datagram_print_wc_error(datagram);
return;
}
@@ -248,8 +245,7 @@
if (datagram->state != EC_DATAGRAM_RECEIVED) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to receive state checking datagram from slave %u: ",
- slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to receive state checking datagram: ");
ec_datagram_print_state(datagram);
return;
}
@@ -258,8 +254,7 @@
char req_state[EC_STATE_STRING_SIZE];
ec_state_string(fsm->requested_state, req_state, 0);
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to check state %s on slave %u: ",
- req_state, slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to check state %s: ", req_state);
ec_datagram_print_wc_error(datagram);
return;
}
@@ -288,8 +283,8 @@
// state change
fsm->spontaneous_change = 1;
fsm->old_state = slave->current_state;
- EC_WARN("Slave %u changed to %s in the meantime.\n",
- slave->ring_position, cur_state);
+ EC_SLAVE_WARN(slave, "Changed to %s in the meantime.\n",
+ cur_state);
goto check_again;
}
@@ -298,8 +293,8 @@
slave->error_flag = 1;
ec_state_string(fsm->requested_state, req_state, 0);
- EC_ERR("Failed to set %s state, slave %u refused state change (%s).\n",
- req_state, slave->ring_position, cur_state);
+ EC_SLAVE_ERR(slave, "Failed to set %s state, slave refused state"
+ " change (%s).\n", req_state, cur_state);
// fetch AL status error code
ec_datagram_fprd(datagram, slave->station_address, 0x0134, 2);
ec_datagram_zero(datagram);
@@ -316,8 +311,7 @@
char state_str[EC_STATE_STRING_SIZE];
ec_state_string(fsm->requested_state, state_str, 0);
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Timeout while setting state %s on slave %u.\n",
- state_str, slave->ring_position);
+ EC_SLAVE_ERR(slave, "Timeout while setting state %s.\n", state_str);
return;
}
@@ -406,25 +400,27 @@
if (datagram->state != EC_DATAGRAM_RECEIVED) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to receive AL status code datagram from slave %u: ",
- fsm->slave->ring_position);
+ EC_SLAVE_ERR(fsm->slave, "Failed to receive"
+ " AL status code datagram: ");
ec_datagram_print_state(datagram);
return;
}
if (datagram->working_counter != 1) {
- EC_WARN("Reception of AL status code datagram failed: ");
+ EC_SLAVE_WARN(fsm->slave, "Reception of AL status code"
+ " datagram failed: ");
ec_datagram_print_wc_error(datagram);
} else {
code = EC_READ_U16(datagram->data);
for (al_msg = al_status_messages; al_msg->code != 0xffff; al_msg++) {
if (al_msg->code != code) continue;
- EC_ERR("AL status message 0x%04X: \"%s\".\n",
+ EC_SLAVE_ERR(fsm->slave, "AL status message 0x%04X: \"%s\".\n",
al_msg->code, al_msg->message);
break;
}
if (!al_msg->code)
- EC_ERR("Unknown AL status code 0x%04X.\n", code);
+ EC_SLAVE_ERR(fsm->slave, "Unknown AL status code 0x%04X.\n",
+ code);
}
// acknowledge "old" slave state
@@ -465,16 +461,14 @@
if (datagram->state != EC_DATAGRAM_RECEIVED) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to receive state ack datagram for slave %u: ",
- slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to receive state ack datagram: ");
ec_datagram_print_state(datagram);
return;
}
if (datagram->working_counter != 1) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Reception of state ack datagram failed on slave %u: ",
- slave->ring_position);
+ EC_SLAVE_ERR(slave, "Reception of state ack datagram failed: ");
ec_datagram_print_wc_error(datagram);
return;
}
@@ -505,16 +499,14 @@
if (datagram->state != EC_DATAGRAM_RECEIVED) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Failed to receive state ack check datagram from slave %u: ",
- slave->ring_position);
+ EC_SLAVE_ERR(slave, "Failed to receive state ack check datagram: ");
ec_datagram_print_state(datagram);
return;
}
if (datagram->working_counter != 1) {
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Reception of state ack check datagram failed on slave %u: ",
- slave->ring_position);
+ EC_SLAVE_ERR(slave, "Reception of state ack check datagram failed: ");
ec_datagram_print_wc_error(datagram);
return;
}
@@ -535,8 +527,7 @@
else { // EC_FSM_CHANGE_MODE_ACK_ONLY
fsm->state = ec_fsm_change_state_end;
}
- EC_INFO("Acknowledged state %s on slave %u.\n",
- state_str, slave->ring_position);
+ EC_SLAVE_INFO(slave, "Acknowledged state %s.\n", state_str);
return;
}
@@ -546,8 +537,8 @@
char state_str[EC_STATE_STRING_SIZE];
ec_state_string(slave->current_state, state_str, 0);
fsm->state = ec_fsm_change_state_error;
- EC_ERR("Timeout while acknowledging state %s on slave %u.\n",
- state_str, slave->ring_position);
+ EC_SLAVE_ERR(slave, "Timeout while acknowledging state %s.\n",
+ state_str);
return;
}