Improved CoE error messages.

This commit is contained in:
Florian Pose 2010-01-26 11:20:07 +01:00
parent d48d9ebac2
commit ac50d8c983
1 changed files with 39 additions and 12 deletions

View File

@ -50,6 +50,7 @@
#define EC_COE_DOWN_SEG_MIN_DATA_SIZE 7
#define DEBUG_RETRIES 0
#define DEBUG_LONG 0
/*****************************************************************************/
@ -1198,6 +1199,7 @@ void ec_fsm_coe_down_request(ec_fsm_coe_t *fsm /**< finite state machine */)
{
ec_datagram_t *datagram = fsm->datagram;
ec_slave_t *slave = fsm->slave;
unsigned long diff_ms;
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
return; // FIXME: check for response first?
@ -1210,10 +1212,10 @@ void ec_fsm_coe_down_request(ec_fsm_coe_t *fsm /**< finite state machine */)
return;
}
diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
if (datagram->working_counter != 1) {
if (!datagram->working_counter) {
unsigned long diff_ms =
(jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
if (diff_ms < fsm->request->response_timeout) {
#if DEBUG_RETRIES
if (fsm->slave->master->debug_level) {
@ -1227,12 +1229,22 @@ void ec_fsm_coe_down_request(ec_fsm_coe_t *fsm /**< finite state machine */)
}
}
fsm->state = ec_fsm_coe_error;
EC_ERR("Reception of CoE download request failed on slave %u: ",
slave->ring_position);
EC_ERR("Reception of CoE download request for SDO 0x%04x:%x failed"
" with timeout after %u ms on slave %u: ",
fsm->request->index, fsm->request->subindex, (u32) diff_ms,
fsm->slave->ring_position);
ec_datagram_print_wc_error(datagram);
return;
}
#if DEBUG_LONG
if (diff_ms > 200) {
EC_WARN("SDO 0x%04x:%x download took %u ms on slave %u.\n",
fsm->request->index, fsm->request->subindex, (u32) diff_ms,
fsm->slave->ring_position);
}
#endif
fsm->jiffies_start = datagram->jiffies_sent;
ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
@ -1275,8 +1287,10 @@ void ec_fsm_coe_down_check(ec_fsm_coe_t *fsm /**< finite state machine */)
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
if (diff_ms >= fsm->request->response_timeout) {
fsm->state = ec_fsm_coe_error;
EC_ERR("Timeout while waiting for SDO download response on "
"slave %u.\n", slave->ring_position);
EC_ERR("Timeout after %u ms while waiting for SDO 0x%04x:%x"
" download response on slave %u.\n", (u32) diff_ms,
fsm->request->index, fsm->request->subindex,
slave->ring_position);
return;
}
@ -1693,6 +1707,7 @@ void ec_fsm_coe_up_request(ec_fsm_coe_t *fsm /**< finite state machine */)
{
ec_datagram_t *datagram = fsm->datagram;
ec_slave_t *slave = fsm->slave;
unsigned long diff_ms;
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
return; // FIXME: check for response first?
@ -1705,10 +1720,10 @@ void ec_fsm_coe_up_request(ec_fsm_coe_t *fsm /**< finite state machine */)
return;
}
diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
if (datagram->working_counter != 1) {
if (!datagram->working_counter) {
unsigned long diff_ms =
(jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
if (diff_ms < fsm->request->response_timeout) {
#if DEBUG_RETRIES
if (fsm->slave->master->debug_level) {
@ -1722,12 +1737,22 @@ void ec_fsm_coe_up_request(ec_fsm_coe_t *fsm /**< finite state machine */)
}
}
fsm->state = ec_fsm_coe_error;
EC_ERR("Reception of CoE upload request failed on slave %u: ",
slave->ring_position);
EC_ERR("Reception of CoE upload request for SDO 0x%04x:%x failed"
" with timeout after %u ms on slave %u: ",
fsm->request->index, fsm->request->subindex, (u32) diff_ms,
fsm->slave->ring_position);
ec_datagram_print_wc_error(datagram);
return;
}
#if DEBUG_LONG
if (diff_ms > 200) {
EC_WARN("SDO 0x%04x:%x upload took %u ms on slave %u.\n",
fsm->request->index, fsm->request->subindex, (u32) diff_ms,
fsm->slave->ring_position);
}
#endif
fsm->jiffies_start = datagram->jiffies_sent;
ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
@ -1770,8 +1795,10 @@ void ec_fsm_coe_up_check(ec_fsm_coe_t *fsm /**< finite state machine */)
(datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
if (diff_ms >= fsm->request->response_timeout) {
fsm->state = ec_fsm_coe_error;
EC_ERR("Timeout while waiting for SDO upload response on "
"slave %u.\n", slave->ring_position);
EC_ERR("Timeout after %u ms while waiting for SDO 0x%04x:%x"
" upload response on slave %u.\n", (u32) diff_ms,
fsm->request->index, fsm->request->subindex,
slave->ring_position);
return;
}