diff --git a/master/slave.c b/master/slave.c index d2ab8495f37b4ac4bf512fbd83846bd15a449423..9b65e58452de21463c4f2ba94d74a8313858e9d8 100644 --- a/master/slave.c +++ b/master/slave.c @@ -1200,7 +1200,34 @@ ec_sdo_t *ec_slave_get_sdo( ec_sdo_t *sdo; list_for_each_entry(sdo, &slave->sdo_dictionary, list) { - if (sdo->index != index) continue; + if (sdo->index != index) + continue; + return sdo; + } + + return NULL; +} + +/*****************************************************************************/ + +/** + * Get an Sdo from the dictionary. + * + * const version. + * + * \returns The desired Sdo, or NULL. + */ + +const ec_sdo_t *ec_slave_get_sdo_const( + const ec_slave_t *slave, /**< EtherCAT slave */ + uint16_t index /**< Sdo index */ + ) +{ + const ec_sdo_t *sdo; + + list_for_each_entry(sdo, &slave->sdo_dictionary, list) { + if (sdo->index != index) + continue; return sdo; } diff --git a/master/slave.h b/master/slave.h index d2dc25f8a9ab48c59fff25fdda62d7fe9a67220b..5d822fe7c37e8b29cd73e45204ffc3379e18c599 100644 --- a/master/slave.h +++ b/master/slave.h @@ -223,6 +223,7 @@ ec_sync_t *ec_slave_get_pdo_sync(ec_slave_t *, ec_direction_t); void ec_slave_sdo_dict_info(const ec_slave_t *, unsigned int *, unsigned int *); ec_sdo_t *ec_slave_get_sdo(ec_slave_t *, uint16_t); +const ec_sdo_t *ec_slave_get_sdo_const(const ec_slave_t *, uint16_t); const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t); uint16_t ec_slave_sdo_count(const ec_slave_t *); const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);