# HG changeset patch # User Florian Pose # Date 1212403784 0 # Node ID 96241b092fac5bc3e4099901555f3e95de3559d9 # Parent 618ab9e03321c191b6fe0dc8e9c799c884d5a9f0 Added entry access functions. diff -r 618ab9e03321 -r 96241b092fac master/pdo.c --- a/master/pdo.c Mon Jun 02 10:21:20 2008 +0000 +++ b/master/pdo.c Mon Jun 02 10:49:44 2008 +0000 @@ -229,3 +229,43 @@ } /*****************************************************************************/ + +/** + */ +unsigned int ec_pdo_entry_count( + const ec_pdo_t *pdo /**< Pdo. */ + ) +{ + const ec_pdo_entry_t *entry; + unsigned int num = 0; + + list_for_each_entry(entry, &pdo->entries, list) { + num++; + } + + return num; +} + +/*****************************************************************************/ + +/** Finds a Pdo entry via its position in the list. + * + * Const version. + */ +const ec_pdo_entry_t *ec_pdo_find_entry_by_pos_const( + const ec_pdo_t *pdo, /**< Pdo. */ + unsigned int pos /**< Position in the list. */ + ) +{ + const ec_pdo_entry_t *entry; + + list_for_each_entry(entry, &pdo->entries, list) { + if (pos--) + continue; + return entry; + } + + return NULL; +} + +/*****************************************************************************/ diff -r 618ab9e03321 -r 96241b092fac master/pdo.h --- a/master/pdo.h Mon Jun 02 10:21:20 2008 +0000 +++ b/master/pdo.h Mon Jun 02 10:49:44 2008 +0000 @@ -73,6 +73,9 @@ ec_pdo_entry_t *ec_pdo_add_entry(ec_pdo_t *, uint16_t, uint8_t, uint8_t); int ec_pdo_copy_entries(ec_pdo_t *, const ec_pdo_t *); int ec_pdo_equal_entries(const ec_pdo_t *, const ec_pdo_t *); +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); /*****************************************************************************/