Introduced ec_master_domain_count() and ec_master_find_domain().
authorFlorian Pose <fp@igh-essen.com>
Wed, 04 Jun 2008 10:10:05 +0000
changeset 946 6ef20c5de875
parent 945 a5907351e13e
child 947 6ca9c5fb56d5
Introduced ec_master_domain_count() and ec_master_find_domain().
master/master.c
master/master.h
--- a/master/master.c	Wed Jun 04 09:59:23 2008 +0000
+++ b/master/master.c	Wed Jun 04 10:10:05 2008 +0000
@@ -1305,6 +1305,40 @@
     return NULL;
 }
 
+/*****************************************************************************/
+
+unsigned int ec_master_domain_count(
+		const ec_master_t *master /**< EtherCAT master. */
+		)
+{
+	const ec_domain_t *domain;
+	unsigned int count = 0;
+
+	list_for_each_entry(domain, &master->domains, list) {
+		count++;
+	}
+
+	return count;
+}
+
+/*****************************************************************************/
+
+ec_domain_t *ec_master_find_domain(
+		ec_master_t *master, /**< EtherCAT master. */
+		unsigned int index /**< Domain index. */
+		)
+{
+	ec_domain_t *domain;
+
+	list_for_each_entry(domain, &master->domains, list) {
+		if (index--)
+			continue;
+		return domain;
+	}
+
+	return NULL;
+}
+
 /******************************************************************************
  *  Realtime interface
  *****************************************************************************/
--- a/master/master.h	Wed Jun 04 09:59:23 2008 +0000
+++ b/master/master.h	Wed Jun 04 10:10:05 2008 +0000
@@ -197,6 +197,9 @@
 #endif
 void ec_master_destroy_slaves(ec_master_t *);
 
-/*****************************************************************************/
-
-#endif
+unsigned int ec_master_domain_count(const ec_master_t *);
+ec_domain_t *ec_master_find_domain(ec_master_t *, unsigned int);
+
+/*****************************************************************************/
+
+#endif