Improved output when PDO assignment/mapping fails.

This commit is contained in:
Florian Pose 2010-02-23 15:49:12 +01:00
parent f5a2a4167d
commit ed4205d08a
6 changed files with 83 additions and 19 deletions

View File

@ -99,6 +99,21 @@ void ec_fsm_pdo_clear(
/*****************************************************************************/
/** Print the current and desired PDO assignment.
*/
void ec_fsm_pdo_print(
ec_fsm_pdo_t *fsm /**< PDO configuration state machine. */
)
{
printk("Currently assigned PDOs: ");
ec_pdo_list_print(&fsm->sync->pdos);
printk(". PDOs to assign: ");
ec_pdo_list_print(&fsm->pdos);
printk("\n");
}
/*****************************************************************************/
/** Start reading the PDO configuration.
*/
void ec_fsm_pdo_start_reading(
@ -501,13 +516,8 @@ void ec_fsm_pdo_conf_action_check_mapping(
return;
}
if (fsm->slave->master->debug_level) {
// TODO display diff
EC_DBG("Changing mapping of PDO 0x%04X.\n", fsm->pdo->index);
}
ec_fsm_pdo_entry_start_configuration(&fsm->fsm_pdo_entry, fsm->slave,
fsm->pdo);
fsm->pdo, &fsm->slave_pdo);
fsm->state = ec_fsm_pdo_conf_state_mapping;
fsm->state(fsm); // execure immediately
}
@ -569,12 +579,7 @@ void ec_fsm_pdo_conf_action_check_assignment(
if (fsm->slave->master->debug_level) {
EC_DBG("PDO assignment of SM%u differs:\n", fsm->sync_index);
EC_DBG("Currently assigned PDOs: ");
ec_pdo_list_print(&fsm->sync->pdos);
printk("\n");
EC_DBG("PDOs to assign: ");
ec_pdo_list_print(&fsm->pdos);
printk("\n");
EC_DBG(""); ec_fsm_pdo_print(fsm);
}
// PDO assignment has to be changed. Does the slave support this?
@ -583,6 +588,7 @@ void ec_fsm_pdo_conf_action_check_assignment(
&& !fsm->slave->sii.coe_details.enable_pdo_assign)) {
EC_WARN("Slave %u does not support assigning PDOs!\n",
fsm->slave->ring_position);
EC_WARN(""); ec_fsm_pdo_print(fsm);
ec_fsm_pdo_conf_action_next_sync(fsm);
return;
}
@ -619,6 +625,7 @@ void ec_fsm_pdo_conf_state_zero_pdo_count(
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
EC_WARN("Failed to clear PDO assignment of SM%u.\n", fsm->sync_index);
EC_WARN(""); ec_fsm_pdo_print(fsm);
fsm->state = ec_fsm_pdo_state_error;
return;
}
@ -680,6 +687,7 @@ void ec_fsm_pdo_conf_state_assign_pdo(
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
EC_WARN("Failed to assign PDO 0x%04X at position %u of SM%u.\n",
fsm->pdo->index, fsm->pdo_pos, fsm->sync_index);
EC_WARN(""); ec_fsm_pdo_print(fsm);
fsm->state = ec_fsm_pdo_state_error;
return;
}
@ -720,6 +728,7 @@ void ec_fsm_pdo_conf_state_set_pdo_count(
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
EC_WARN("Failed to set number of assigned PDOs of SM%u.\n",
fsm->sync_index);
EC_WARN(""); ec_fsm_pdo_print(fsm);
fsm->state = ec_fsm_pdo_state_error;
return;
}

View File

@ -84,6 +84,21 @@ void ec_fsm_pdo_entry_clear(
/*****************************************************************************/
/** Print the current and desired PDO mapping.
*/
void ec_fsm_pdo_entry_print(
ec_fsm_pdo_entry_t *fsm /**< PDO configuration state machine. */
)
{
printk("Currently mapped PDO entries: ");
ec_pdo_print_entries(fsm->cur_pdo);
printk(". Entries to map: ");
ec_pdo_print_entries(fsm->source_pdo);
printk("\n");
}
/*****************************************************************************/
/** Start reading a PDO's entries.
*/
void ec_fsm_pdo_entry_start_reading(
@ -107,11 +122,18 @@ void ec_fsm_pdo_entry_start_reading(
void ec_fsm_pdo_entry_start_configuration(
ec_fsm_pdo_entry_t *fsm, /**< PDO mapping state machine. */
ec_slave_t *slave, /**< slave to configure */
const ec_pdo_t *pdo /**< PDO with the desired entries. */
const ec_pdo_t *pdo, /**< PDO with the desired entries. */
const ec_pdo_t *cur_pdo /**< Current PDO mapping. */
)
{
fsm->slave = slave;
fsm->source_pdo = pdo;
fsm->cur_pdo = cur_pdo;
if (fsm->slave->master->debug_level) {
EC_DBG("Changing mapping of PDO 0x%04X.\n", pdo->index);
EC_DBG(""); ec_fsm_pdo_entry_print(fsm);
}
fsm->state = ec_fsm_pdo_entry_conf_state_start;
}
@ -310,6 +332,7 @@ void ec_fsm_pdo_entry_conf_state_start(
&& !fsm->slave->sii.coe_details.enable_pdo_configuration)) {
EC_WARN("Slave %u does not support changing the PDO mapping!\n",
fsm->slave->ring_position);
EC_WARN(""); ec_fsm_pdo_entry_print(fsm);
fsm->state = ec_fsm_pdo_entry_state_error;
return;
}
@ -361,6 +384,7 @@ void ec_fsm_pdo_entry_conf_state_zero_entry_count(
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
EC_WARN("Failed to clear PDO mapping.\n");
EC_WARN(""); ec_fsm_pdo_entry_print(fsm);
fsm->state = ec_fsm_pdo_entry_state_error;
return;
}
@ -422,6 +446,7 @@ void ec_fsm_pdo_entry_conf_state_map_entry(
EC_WARN("Failed to map PDO entry 0x%04X:%02X (%u bit) to "
"position %u.\n", fsm->entry->index, fsm->entry->subindex,
fsm->entry->bit_length, fsm->entry_pos);
EC_WARN(""); ec_fsm_pdo_entry_print(fsm);
fsm->state = ec_fsm_pdo_entry_state_error;
return;
}
@ -461,7 +486,8 @@ void ec_fsm_pdo_entry_conf_state_set_entry_count(
if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
if (!ec_fsm_coe_success(fsm->fsm_coe)) {
EC_ERR("Failed to set number of entries.\n");
EC_WARN("Failed to set number of entries.\n");
EC_WARN(""); ec_fsm_pdo_entry_print(fsm);
fsm->state = ec_fsm_pdo_entry_state_error;
return;
}

View File

@ -58,6 +58,7 @@ struct ec_fsm_pdo_entry
ec_slave_t *slave; /**< Slave the FSM runs on. */
ec_pdo_t *target_pdo; /**< PDO to read the mapping for. */
const ec_pdo_t *source_pdo; /**< PDO with desired mapping. */
const ec_pdo_t *cur_pdo; /**< PDO with current mapping (display only). */
const ec_pdo_entry_t *entry; /**< Current entry. */
unsigned int entry_count; /**< Number of entries. */
unsigned int entry_pos; /**< Position in PDO mapping. */
@ -71,7 +72,7 @@ void ec_fsm_pdo_entry_clear(ec_fsm_pdo_entry_t *);
void ec_fsm_pdo_entry_start_reading(ec_fsm_pdo_entry_t *, ec_slave_t *,
ec_pdo_t *);
void ec_fsm_pdo_entry_start_configuration(ec_fsm_pdo_entry_t *, ec_slave_t *,
const ec_pdo_t *);
const ec_pdo_t *, const ec_pdo_t *);
int ec_fsm_pdo_entry_exec(ec_fsm_pdo_entry_t *);
int ec_fsm_pdo_entry_success(const ec_fsm_pdo_entry_t *);

View File

@ -291,3 +291,25 @@ const ec_pdo_entry_t *ec_pdo_find_entry_by_pos_const(
}
/*****************************************************************************/
/** Outputs the PDOs in the list.
*/
void ec_pdo_print_entries(
const ec_pdo_t *pdo /**< PDO. */
)
{
const ec_pdo_entry_t *entry;
if (list_empty(&pdo->entries)) {
printk("(none)");
} else {
list_for_each_entry(entry, &pdo->entries, list) {
printk("0x%04X:%02X/%u",
entry->index, entry->subindex, entry->bit_length);
if (entry->list.next != &pdo->entries)
printk(" ");
}
}
}
/*****************************************************************************/

View File

@ -68,6 +68,8 @@ unsigned int ec_pdo_entry_count(const ec_pdo_t *);
const ec_pdo_entry_t *ec_pdo_find_entry_by_pos_const(
const ec_pdo_t *, unsigned int);
void ec_pdo_print_entries(const ec_pdo_t *);
/*****************************************************************************/
#endif

View File

@ -326,10 +326,14 @@ void ec_pdo_list_print(
{
const ec_pdo_t *pdo;
list_for_each_entry(pdo, &pl->list, list) {
printk("0x%04X", pdo->index);
if (pdo->list.next != &pl->list)
printk(" ");
if (list_empty(&pl->list)) {
printk("(none)");
} else {
list_for_each_entry(pdo, &pl->list, list) {
printk("0x%04X", pdo->index);
if (pdo->list.next != &pl->list)
printk(" ");
}
}
}