diff --git a/TODO b/TODO index c0c1ee76..39492697 100644 --- a/TODO +++ b/TODO @@ -20,7 +20,6 @@ Version 1.4.0: - Data type abbreviations. - Add a -n (numeric) switch. - Check for options, remove global variables. - - Remove MasterDevice::slaveCount(). - Add 'etherlab version'. Future issues: diff --git a/tool/Command.cpp b/tool/Command.cpp index 95cd0a69..51f2d5d6 100644 --- a/tool/Command.cpp +++ b/tool/Command.cpp @@ -108,15 +108,18 @@ void Command::throwSingleSlaveRequired(unsigned int size) const 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 @@ Command::SlaveList Command::selectedSlaves(MasterDevice &m) 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 @@ Command::SlaveList Command::selectedSlaves(MasterDevice &m) } 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; diff --git a/tool/CommandSlaves.cpp b/tool/CommandSlaves.cpp index d709990c..8a12dc78 100644 --- a/tool/CommandSlaves.cpp +++ b/tool/CommandSlaves.cpp @@ -102,7 +102,8 @@ void CommandSlaves::listSlaves( 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 @@ void CommandSlaves::listSlaves( 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) { diff --git a/tool/MasterDevice.cpp b/tool/MasterDevice.cpp index 1a195948..4b283a1e 100644 --- a/tool/MasterDevice.cpp +++ b/tool/MasterDevice.cpp @@ -68,16 +68,6 @@ void MasterDevice::close() /****************************************************************************/ -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) { diff --git a/tool/MasterDevice.h b/tool/MasterDevice.h index 8db1c627..7575daac 100644 --- a/tool/MasterDevice.h +++ b/tool/MasterDevice.h @@ -42,8 +42,6 @@ class MasterDevice 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,