Added -q flag (quiet).
--- a/tools/Master.cpp Fri Jun 06 09:27:24 2008 +0000
+++ b/tools/Master.cpp Fri Jun 06 09:34:20 2008 +0000
@@ -209,31 +209,31 @@
/****************************************************************************/
-void Master::listPdos(int slavePosition)
+void Master::listPdos(int slavePosition, bool quiet)
{
if (slavePosition == -1) {
unsigned int numSlaves = slaveCount(), i;
for (i = 0; i < numSlaves; i++) {
- listSlavePdos(i, true);
+ listSlavePdos(i, quiet, true);
}
} else {
- listSlavePdos(slavePosition, false);
- }
-}
-
-/****************************************************************************/
-
-void Master::listSdos(int slavePosition)
+ listSlavePdos(slavePosition, quiet, false);
+ }
+}
+
+/****************************************************************************/
+
+void Master::listSdos(int slavePosition, bool quiet)
{
if (slavePosition == -1) {
unsigned int numSlaves = slaveCount(), i;
for (i = 0; i < numSlaves; i++) {
- listSlaveSdos(i, true);
+ listSlaveSdos(i, quiet, true);
}
} else {
- listSlaveSdos(slavePosition, false);
+ listSlaveSdos(slavePosition, quiet, false);
}
}
@@ -390,7 +390,11 @@
/****************************************************************************/
-void Master::listSlavePdos(uint16_t slavePosition, bool withHeader)
+void Master::listSlavePdos(
+ uint16_t slavePosition,
+ bool quiet,
+ bool withHeader
+ )
{
ec_ioctl_slave_t slave;
ec_ioctl_sync_t sync;
@@ -424,6 +428,9 @@
<< hex << setfill('0') << setw(4) << pdo.index
<< " \"" << pdo.name << "\"" << endl;
+ if (quiet)
+ continue;
+
for (k = 0; k < pdo.entry_count; k++) {
getPdoEntry(&entry, slavePosition, i, j, k);
@@ -440,7 +447,11 @@
/****************************************************************************/
-void Master::listSlaveSdos(uint16_t slavePosition, bool withHeader)
+void Master::listSlaveSdos(
+ uint16_t slavePosition,
+ bool quiet,
+ bool withHeader
+ )
{
ec_ioctl_slave_t slave;
ec_ioctl_sdo_t sdo;
@@ -459,6 +470,9 @@
<< hex << setfill('0') << setw(4) << sdo.sdo_index
<< ", \"" << sdo.name << "\"" << endl;
+ if (quiet)
+ continue;
+
for (j = 0; j <= sdo.max_subindex; j++) {
getSdoEntry(&entry, slavePosition, i, j);
--- a/tools/Master.h Fri Jun 06 09:27:24 2008 +0000
+++ b/tools/Master.h Fri Jun 06 09:34:20 2008 +0000
@@ -47,16 +47,16 @@
void showDomains(int);
void listSlaves();
void showMaster();
- void listPdos(int);
- void listSdos(int);
+ void listPdos(int, bool = false);
+ void listSdos(int, bool = false);
void requestStates(int, const vector<string> &);
void generateXml(int);
protected:
void outputDomainData(unsigned int);
void showDomain(unsigned int);
- void listSlavePdos(uint16_t, bool = false);
- void listSlaveSdos(uint16_t, bool = false);
+ void listSlavePdos(uint16_t, bool = false, bool = false);
+ void listSlaveSdos(uint16_t, bool = false, bool = false);
void generateSlaveXml(uint16_t);
unsigned int domainCount();
unsigned int slaveCount();
--- a/tools/main.cpp Fri Jun 06 09:27:24 2008 +0000
+++ b/tools/main.cpp Fri Jun 06 09:34:20 2008 +0000
@@ -25,6 +25,7 @@
static int domainIndex = DEFAULT_DOMAININDEX;
static string command = DEFAULT_COMMAND;
vector<string> commandArgs;
+static bool quiet = false;
/*****************************************************************************/
@@ -53,6 +54,7 @@
<< endl
<< " or 'all' for all domains (default)."
<< endl
+ << " --quiet -q Show less output." << endl
<< " --help -h Show this help." << endl;
}
@@ -68,12 +70,13 @@
{"master", required_argument, NULL, 'm'},
{"slave", required_argument, NULL, 's'},
{"domain", required_argument, NULL, 'd'},
+ {"quiet", no_argument, NULL, 'q'},
{"help", no_argument, NULL, 'h'},
{}
};
do {
- c = getopt_long(argc, argv, "m:s:d:h", longOptions, &optionIndex);
+ c = getopt_long(argc, argv, "m:s:d:qh", longOptions, &optionIndex);
switch (c) {
case 'm':
@@ -117,6 +120,10 @@
}
break;
+ case 'q':
+ quiet = true;
+ break;
+
case 'h':
case '?':
printUsage();
@@ -163,9 +170,9 @@
} else if (command == "master") {
master.showMaster();
} else if (command == "pdos") {
- master.listPdos(slavePosition);
+ master.listPdos(slavePosition, quiet);
} else if (command == "sdos") {
- master.listSdos(slavePosition);
+ master.listSdos(slavePosition, quiet);
} else if (command == "state") {
master.requestStates(slavePosition, commandArgs);
} else if (command == "xml") {