diff -r 6ca9c5fb56d5 -r 1cfab7161491 tools/main.cpp --- a/tools/main.cpp Wed Jun 04 10:10:50 2008 +0000 +++ b/tools/main.cpp Wed Jun 04 10:13:07 2008 +0000 @@ -17,9 +17,11 @@ #define DEFAULT_MASTER 0 #define DEFAULT_COMMAND "slaves" #define DEFAULT_SLAVEPOSITION -1 +#define DEFAULT_DOMAININDEX -1 static unsigned int masterIndex = DEFAULT_MASTER; static int slavePosition = DEFAULT_SLAVEPOSITION; +static int domainIndex = DEFAULT_DOMAININDEX; static string command = DEFAULT_COMMAND; /*****************************************************************************/ @@ -29,16 +31,21 @@ cerr << "Usage: ethercat [OPTIONS]" << endl << "Commands:" << endl + << " domain Show domain information." << endl << " list (ls, slaves) List all slaves (former 'lsec')." << endl << " pdos List Pdo mapping of given slaves." << endl << " xml Generate slave information xml." << endl << "Global options:" << endl << " --master -m Index of the master to use. Default: " << DEFAULT_MASTER << endl - << " --slave -s Positive numerical ring position," + << " --slave -s Positive numerical ring position," << endl << " or 'all' for all slaves. Default: 'all'." << endl + << " --domain -d Positive numerical index," + << endl + << " or 'all' for all domains. Default: " + << "'all'." << endl << " --help -h Show this help." << endl; } @@ -53,12 +60,13 @@ //name, has_arg, flag, val {"master", required_argument, NULL, 'm'}, {"slave", required_argument, NULL, 's'}, + {"domain", required_argument, NULL, 'd'}, {"help", no_argument, NULL, 'h'}, {} }; do { - c = getopt_long(argc, argv, "m:s:h", longOptions, &optionIndex); + c = getopt_long(argc, argv, "m:s:d:h", longOptions, &optionIndex); switch (c) { case 'm': @@ -87,6 +95,21 @@ } break; + case 'd': + if (!strcmp(optarg, "all")) { + domainIndex = -1; + } else { + number = strtoul(optarg, &remainder, 0); + if (remainder == optarg || *remainder || number < 0) { + cerr << "Invalid domain index " + << optarg << "!" << endl; + printUsage(); + exit(1); + } + domainIndex = number; + } + break; + case 'h': case '?': printUsage(); @@ -120,7 +143,9 @@ try { master.open(masterIndex); - if (command == "list" || command == "ls" || command == "slaves") { + if (command == "domain") { + master.showDomains(domainIndex); + } else if (command == "list" || command == "ls" || command == "slaves") { master.listSlaves(); } else if (command == "pdos") { master.listPdos(slavePosition);