master/slave.c
changeset 423 862ff892cf18
parent 421 2b3ce4f51bd6
child 446 8fede404c01f
--- 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
  *****************************************************************************/