Removed MasterDevice::slaveCount().
authorFlorian Pose <fp@igh-essen.com>
Mon, 28 Jul 2008 12:15:25 +0000
changeset 1160 f02ff486b313
parent 1159 25cc77cf3993
child 1161 d1324ac71232
Removed MasterDevice::slaveCount().
TODO
tool/Command.cpp
tool/CommandSlaves.cpp
tool/MasterDevice.cpp
tool/MasterDevice.h
--- a/TODO	Mon Jul 28 12:11:50 2008 +0000
+++ b/TODO	Mon Jul 28 12:15:25 2008 +0000
@@ -20,7 +20,6 @@
     - Data type abbreviations.
     - Add a -n (numeric) switch.
     - Check for options, remove global variables.
-    - Remove MasterDevice::slaveCount().
     - Add 'etherlab version'.
 
 Future issues:
--- a/tool/Command.cpp	Mon Jul 28 12:11:50 2008 +0000
+++ b/tool/Command.cpp	Mon Jul 28 12:15:25 2008 +0000
@@ -108,15 +108,18 @@
 
 Command::SlaveList Command::selectedSlaves(MasterDevice &m)
 {
-    unsigned int numSlaves = m.slaveCount(), i, aliasIndex;
+    ec_ioctl_master_t master;
+    unsigned int i, aliasIndex;
     uint16_t lastAlias;
     ec_ioctl_slave_t slave;
     SlaveList list;
 
+    m.getMaster(&master);
+
     if (alias == -1) { // no alias given
         if (position == -1) { // no alias and position given
             // all items
-            for (i = 0; i < numSlaves; i++) {
+            for (i = 0; i < master.slave_count; i++) {
                 m.getSlave(&slave, i);
                 list.push_back(slave);
             }
@@ -129,7 +132,7 @@
         if (position == -1) { // alias, but no position given
             // take all items with a given alias
             lastAlias = 0;
-            for (i = 0; i < numSlaves; i++) {
+            for (i = 0; i < master.slave_count; i++) {
                 m.getSlave(&slave, i);
                 if (slave.alias) {
                     lastAlias = slave.alias;
@@ -141,7 +144,7 @@
         } else { // alias and position given
             lastAlias = 0;
             aliasIndex = 0;
-            for (i = 0; i < numSlaves; i++) {
+            for (i = 0; i < master.slave_count; i++) {
                 m.getSlave(&slave, i);
                 if (slave.alias && slave.alias == (uint16_t) alias) {
                     lastAlias = slave.alias;
--- a/tool/CommandSlaves.cpp	Mon Jul 28 12:11:50 2008 +0000
+++ b/tool/CommandSlaves.cpp	Mon Jul 28 12:15:25 2008 +0000
@@ -102,7 +102,8 @@
         const SlaveList &slaves
         )
 {
-    unsigned int numSlaves, i;
+    ec_ioctl_master_t master;
+    unsigned int i;
     ec_ioctl_slave_t slave;
     uint16_t lastAlias, aliasIndex;
     Info info;
@@ -113,11 +114,11 @@
     unsigned int maxPosWidth = 0, maxAliasWidth = 0,
                  maxRelPosWidth = 0, maxStateWidth = 0;
     
-    numSlaves = m.slaveCount();
+    m.getMaster(&master);
 
     lastAlias = 0;
     aliasIndex = 0;
-    for (i = 0; i < numSlaves; i++) {
+    for (i = 0; i < master.slave_count; i++) {
         m.getSlave(&slave, i);
         
         if (slave.alias) {
--- a/tool/MasterDevice.cpp	Mon Jul 28 12:11:50 2008 +0000
+++ b/tool/MasterDevice.cpp	Mon Jul 28 12:15:25 2008 +0000
@@ -68,16 +68,6 @@
 
 /****************************************************************************/
 
-unsigned int MasterDevice::slaveCount()
-{
-    ec_ioctl_master_t data;
-
-    getMaster(&data);
-    return data.slave_count;
-}
-
-/****************************************************************************/
-
 void MasterDevice::getMaster(ec_ioctl_master_t *data)
 {
     if (ioctl(fd, EC_IOCTL_MASTER, data) < 0) {
--- a/tool/MasterDevice.h	Mon Jul 28 12:11:50 2008 +0000
+++ b/tool/MasterDevice.h	Mon Jul 28 12:15:25 2008 +0000
@@ -42,8 +42,6 @@
         void open(Permissions);
         void close();
 
-        unsigned int slaveCount();
-
         void getMaster(ec_ioctl_master_t *);
         void getConfig(ec_ioctl_config_t *, unsigned int);
         void getConfigPdo(ec_ioctl_config_pdo_t *, unsigned int, uint8_t,