# HG changeset patch # User Florian Pose # Date 1190223159 0 # Node ID 68d83b45dfa2bd53cbc4b0f986fa1f52aa096365 # Parent 4a02162a63018b183630063f7977552d8c3abac5 Added ec_slave_get_sdo() and ec_sdo_get_entry(). diff -r 4a02162a6301 -r 68d83b45dfa2 master/canopen.c --- a/master/canopen.c Wed Sep 19 17:25:48 2007 +0000 +++ b/master/canopen.c Wed Sep 19 17:32:39 2007 +0000 @@ -171,6 +171,23 @@ /*****************************************************************************/ +ec_sdo_entry_t *ec_sdo_get_entry( + ec_sdo_t *sdo, + uint8_t subindex + ) +{ + ec_sdo_entry_t *entry; + + list_for_each_entry(entry, &sdo->entries, list) { + if (entry->subindex != subindex) continue; + return entry; + } + + return NULL; +} + +/*****************************************************************************/ + ssize_t ec_sdo_info(ec_sdo_t *sdo, /**< SDO */ char *buffer /**< target buffer */ ) diff -r 4a02162a6301 -r 68d83b45dfa2 master/canopen.h --- a/master/canopen.h Wed Sep 19 17:25:48 2007 +0000 +++ b/master/canopen.h Wed Sep 19 17:32:39 2007 +0000 @@ -53,7 +53,7 @@ CANopen SDO. */ -typedef struct +struct ec_sdo { struct kobject kobj; /**< kobject */ struct list_head list; /**< list item */ @@ -63,8 +63,7 @@ char *name; /**< SDO name */ uint8_t subindices; /**< subindices */ struct list_head entries; /**< entry list */ -} -ec_sdo_t; +}; /*****************************************************************************/ @@ -120,6 +119,7 @@ int ec_sdo_init(ec_sdo_t *, uint16_t, ec_slave_t *); void ec_sdo_destroy(ec_sdo_t *); +ec_sdo_entry_t *ec_sdo_get_entry(ec_sdo_t *, uint8_t); int ec_sdo_entry_init(ec_sdo_entry_t *, uint8_t, ec_sdo_t *); void ec_sdo_entry_destroy(ec_sdo_entry_t *); diff -r 4a02162a6301 -r 68d83b45dfa2 master/globals.h --- a/master/globals.h Wed Sep 19 17:25:48 2007 +0000 +++ b/master/globals.h Wed Sep 19 17:32:39 2007 +0000 @@ -201,4 +201,8 @@ /*****************************************************************************/ +typedef struct ec_sdo ec_sdo_t; + +/*****************************************************************************/ + #endif diff -r 4a02162a6301 -r 68d83b45dfa2 master/slave.c --- a/master/slave.c Wed Sep 19 17:25:48 2007 +0000 +++ b/master/slave.c Wed Sep 19 17:32:39 2007 +0000 @@ -1270,6 +1270,28 @@ *entry_count = entries; } +/*****************************************************************************/ + +/** + * Get an SDO from the dictionary. + * \returns The desired SDO, of NULL. + */ + +ec_sdo_t *ec_slave_get_sdo( + ec_slave_t *slave /**< EtherCAT slave */, + uint16_t index /**< SDO index */ + ) +{ + ec_sdo_t *sdo; + + list_for_each_entry(sdo, &slave->sdo_dictionary, list) { + if (sdo->index != index) continue; + return sdo; + } + + return NULL; +} + /****************************************************************************** * Realtime interface *****************************************************************************/ diff -r 4a02162a6301 -r 68d83b45dfa2 master/slave.h --- a/master/slave.h Wed Sep 19 17:25:48 2007 +0000 +++ b/master/slave.h Wed Sep 19 17:32:39 2007 +0000 @@ -205,6 +205,7 @@ 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 *); +ec_sdo_t *ec_slave_get_sdo(ec_slave_t *, uint16_t); /*****************************************************************************/