Added ec_slave_get_sdo() and ec_sdo_get_entry().
--- 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 */
)
--- 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 *);
--- 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
--- 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
*****************************************************************************/
--- 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);
/*****************************************************************************/