mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-08-18 17:17:23 +08:00
Common message for single slave selections.
This commit is contained in:
@@ -14,7 +14,6 @@ Version 1.4.0:
|
||||
* Get original driver for r8169.
|
||||
* Race in jiffies frame timeout?
|
||||
* ethercat tool:
|
||||
- Single message for unambiguous slave in SiiRead/Write and Up/Download.
|
||||
- Implement Alias/Position selection for configs.
|
||||
- Update help for --alias and --position.
|
||||
- Show Pdos in 'ethercat slave -v'.
|
||||
|
||||
+14
-2
@@ -80,20 +80,32 @@ string Command::numericInfo()
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::throwInvalidUsageException(const stringstream &s)
|
||||
void Command::throwInvalidUsageException(const stringstream &s) const
|
||||
{
|
||||
throw InvalidUsageException(s);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::throwCommandException(const stringstream &s)
|
||||
void Command::throwCommandException(const stringstream &s) const
|
||||
{
|
||||
throw CommandException(s);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void Command::throwSingleSlaveRequired(unsigned int size) const
|
||||
{
|
||||
stringstream err;
|
||||
|
||||
err << "The slave selection matches " << size << "slaves. '"
|
||||
<< name << "' requires a single slave.";
|
||||
|
||||
throwInvalidUsageException(err);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
Command::SlaveList Command::selectedSlaves(MasterDevice &m)
|
||||
{
|
||||
unsigned int numSlaves = m.slaveCount(), i, aliasIndex;
|
||||
|
||||
+3
-2
@@ -85,8 +85,9 @@ class Command
|
||||
protected:
|
||||
enum {BreakAfterBytes = 16};
|
||||
|
||||
void throwInvalidUsageException(const stringstream &);
|
||||
void throwCommandException(const stringstream &);
|
||||
void throwInvalidUsageException(const stringstream &) const;
|
||||
void throwCommandException(const stringstream &) const;
|
||||
void throwSingleSlaveRequired(unsigned int) const;
|
||||
|
||||
typedef list<ec_ioctl_slave_t> SlaveList;
|
||||
SlaveList selectedSlaves(MasterDevice &);
|
||||
|
||||
@@ -93,8 +93,7 @@ void CommandDownload::execute(MasterDevice &m, const StringVector &args)
|
||||
m.open(MasterDevice::ReadWrite);
|
||||
slaves = selectedSlaves(m);
|
||||
if (slaves.size() != 1) {
|
||||
err << slaves.size() << " slaves selected, single slave required!";
|
||||
throwInvalidUsageException(err);
|
||||
throwSingleSlaveRequired(slaves.size());
|
||||
}
|
||||
data.slave_position = slaves.front().position;
|
||||
|
||||
|
||||
@@ -62,9 +62,7 @@ void CommandSiiRead::execute(MasterDevice &m, const StringVector &args)
|
||||
slaves = selectedSlaves(m);
|
||||
|
||||
if (slaves.size() != 1) {
|
||||
err << "'" << getName() << "' requires a single slave ("
|
||||
<< slaves.size() << " selected).";
|
||||
throwInvalidUsageException(err);
|
||||
throwSingleSlaveRequired(slaves.size());
|
||||
}
|
||||
slave = &slaves.front();
|
||||
data.slave_position = slave->position;
|
||||
|
||||
@@ -63,9 +63,7 @@ void CommandSiiWrite::execute(MasterDevice &m, const StringVector &args)
|
||||
slaves = selectedSlaves(m);
|
||||
|
||||
if (slaves.size() != 1) {
|
||||
err << "'" << getName() << "' requires a single slave ("
|
||||
<< slaves.size() << " selected).";
|
||||
throwInvalidUsageException(err);
|
||||
throwSingleSlaveRequired(slaves.size());
|
||||
}
|
||||
data.slave_position = slaves.front().position;
|
||||
|
||||
|
||||
@@ -92,8 +92,7 @@ void CommandUpload::execute(MasterDevice &m, const StringVector &args)
|
||||
m.open(MasterDevice::Read);
|
||||
slaves = selectedSlaves(m);
|
||||
if (slaves.size() != 1) {
|
||||
err << slaves.size() << " slaves selected, single slave required!";
|
||||
throwInvalidUsageException(err);
|
||||
throwSingleSlaveRequired(slaves.size());
|
||||
}
|
||||
data.slave_position = slaves.front().position;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user