# HG changeset patch # User Florian Pose # Date 1161347628 0 # Node ID 862ff892cf184476a6022d384f0362dfe2e136f4 # Parent 439cd1650c3673560a46efebb47928d72303220b Better debugging output for SDO dictionaries. diff -r 439cd1650c36 -r 862ff892cf18 master/fsm.c --- a/master/fsm.c Fri Oct 20 12:19:20 2006 +0000 +++ b/master/fsm.c Fri Oct 20 12:33:48 2006 +0000 @@ -614,7 +614,7 @@ || slave->error_flag) continue; if (master->debug_level) { - EC_DBG("Fetching SDO dictionary of slave %i.\n", + EC_DBG("Fetching SDO dictionary from slave %i.\n", slave->ring_position); } @@ -1052,8 +1052,10 @@ // SDO dictionary fetching finished if (master->debug_level) { - EC_DBG("Finished fetching SDO dictionary of slave %i.\n", - slave->ring_position); + unsigned int sdo_count, entry_count; + ec_slave_sdo_dict_info(slave, &sdo_count, &entry_count); + EC_DBG("Fetched %i SDOs and %i entries from slave %i.\n", + sdo_count, entry_count, slave->ring_position); } // restart master state machine. @@ -2320,7 +2322,6 @@ void ec_fsm_coe_dict_response(ec_fsm_t *fsm /**< finite state machine */) { - ec_master_t *master = fsm->master; ec_datagram_t *datagram = &fsm->datagram; ec_slave_t *slave = fsm->slave; uint8_t *data, mbox_prot; @@ -2375,17 +2376,11 @@ sdo_count = (rec_size - 8) / 2; - if (master->debug_level) { - EC_DBG("Fetching %i SDOs.\n", sdo_count); - } - for (i = 0; i < sdo_count; i++) { sdo_index = EC_READ_U16(data + 8 + i * 2); if (!sdo_index) { - // sometimes index is 0... ??? - if (master->debug_level) { - EC_DBG("Received SDO with index 0x0000.\n"); - } + EC_WARN("SDO dictionary of slave %i contains index 0x0000.\n", + slave->ring_position); continue; } @@ -2457,7 +2452,9 @@ if (datagram->state != EC_DATAGRAM_RECEIVED || datagram->working_counter != 1) { fsm->coe_state = ec_fsm_error; - EC_ERR("Reception of CoE SDO description request failed.\n"); + EC_ERR("Reception of CoE SDO description" + " request failed on slave %i.\n", slave->ring_position); + return; } @@ -2482,7 +2479,9 @@ if (datagram->state != EC_DATAGRAM_RECEIVED || datagram->working_counter != 1) { fsm->coe_state = ec_fsm_error; - EC_ERR("Reception of CoE mailbox check datagram failed.\n"); + EC_ERR("Reception of CoE mailbox check datagram failed on slave %i.\n", + slave->ring_position); + return; } @@ -2524,7 +2523,8 @@ if (datagram->state != EC_DATAGRAM_RECEIVED || datagram->working_counter != 1) { fsm->coe_state = ec_fsm_error; - EC_ERR("Reception of CoE SDO description response failed.\n"); + EC_ERR("Reception of CoE SDO description" + "response failed on slave %i.\n", slave->ring_position); return; } @@ -2651,7 +2651,8 @@ if (datagram->state != EC_DATAGRAM_RECEIVED || datagram->working_counter != 1) { fsm->coe_state = ec_fsm_error; - EC_ERR("Reception of CoE SDO entry request failed.\n"); + EC_ERR("Reception of CoE SDO entry request failed on slave %i.\n", + slave->ring_position); return; } @@ -2676,7 +2677,8 @@ if (datagram->state != EC_DATAGRAM_RECEIVED || datagram->working_counter != 1) { fsm->coe_state = ec_fsm_error; - EC_ERR("Reception of CoE mailbox check datagram failed.\n"); + EC_ERR("Reception of CoE mailbox check datagram failed on slave %i.\n", + slave->ring_position); return; } @@ -2708,7 +2710,6 @@ void ec_fsm_coe_dict_entry_response(ec_fsm_t *fsm /**< finite state machine */) { - ec_master_t *master = fsm->master; ec_datagram_t *datagram = &fsm->datagram; ec_slave_t *slave = fsm->slave; ec_sdo_t *sdo = fsm->coe_sdo; @@ -2719,7 +2720,8 @@ if (datagram->state != EC_DATAGRAM_RECEIVED || datagram->working_counter != 1) { fsm->coe_state = ec_fsm_error; - EC_ERR("Reception of CoE SDO description response failed.\n"); + EC_ERR("Reception of CoE SDO description" + " response failed on slave %i.\n", slave->ring_position); return; } @@ -2842,10 +2844,6 @@ return; } - if (master->debug_level) { - EC_DBG("Finished fetching SDO descriptions.\n"); - } - fsm->coe_state = ec_fsm_end; } diff -r 439cd1650c36 -r 862ff892cf18 master/slave.c --- a/master/slave.c Fri Oct 20 12:19:20 2006 +0000 +++ b/master/slave.c Fri Oct 20 12:33:48 2006 +0000 @@ -960,6 +960,33 @@ return 0; } +/*****************************************************************************/ + +/** + Counts the total number of SDOs and entries in the dictionary. +*/ + +void ec_slave_sdo_dict_info(const ec_slave_t *slave, /**< EtherCAT slave */ + unsigned int *sdo_count, /**< number of SDOs */ + unsigned int *entry_count /**< total number of + entries */ + ) +{ + unsigned int sdos = 0, entries = 0; + ec_sdo_t *sdo; + ec_sdo_entry_t *entry; + + list_for_each_entry(sdo, &slave->sdo_dictionary, list) { + sdos++; + list_for_each_entry(entry, &sdo->entries, list) { + entries++; + } + } + + *sdo_count = sdos; + *entry_count = entries; +} + /****************************************************************************** * Realtime interface *****************************************************************************/ diff -r 439cd1650c36 -r 862ff892cf18 master/slave.h --- a/master/slave.h Fri Oct 20 12:19:20 2006 +0000 +++ b/master/slave.h Fri Oct 20 12:33:48 2006 +0000 @@ -281,6 +281,9 @@ int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t); +void ec_slave_sdo_dict_info(const ec_slave_t *, + unsigned int *, unsigned int *); + /*****************************************************************************/ #endif