diff --git a/TODO b/TODO index c0c1ee76ef78137b703c074b4cb53fb35a3a45d6..3949269715f0e8d826e514e28504428e15931dff 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 95cd0a69974f9365c70b0bedb6c2edbbb9a0d0c6..51f2d5d68ee2cfc096e4f386b131e84770729b52 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 d709990c2726c8c8cad4953c2c5db7aee92cde30..8a12dc78154328a283ced2ae39d3e0531f82db97 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 1a19594829d86cc08c5481518443faf7bf882358..4b283a1ef6c4e6fdd29b18d2846ff45458e1f752 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 8db1c6276a0c3e046bfa2d09010ce6a4c51e5f53..7575daacda668d7f7d6e1e15ec2edb7e21a1210a 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,