author | Florian Pose <fp@igh-essen.com> |
Mon, 15 Jun 2009 15:39:26 +0000 | |
changeset 1470 | cb424feef942 |
parent 1422 | d41e4537b75f |
child 1485 | 5ddc3a455059 |
permissions | -rw-r--r-- |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3 |
* $Id$ |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
4 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
6 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
8 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
11 |
* published by the Free Software Foundation. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
12 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
16 |
* Public License for more details. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
17 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
21 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
#include <getopt.h> |
1118 | 31 |
#include <libgen.h> // basename() |
1222
7348d6abb6cb
Applied patch by Karsten Schwinne, adding a few header files necessary
Florian Pose <fp@igh-essen.com>
parents:
1200
diff
changeset
|
32 |
#include <stdlib.h> |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
#include <iostream> |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
35 |
#include <iomanip> |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
using namespace std; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
|
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
38 |
#include "CommandAlias.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
39 |
#include "CommandConfig.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
40 |
#include "CommandData.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
41 |
#include "CommandDebug.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
42 |
#include "CommandDomains.h" |
1165
c5d6e28eec91
Added 'ethercat version' command.
Florian Pose <fp@igh-essen.com>
parents:
1158
diff
changeset
|
43 |
#include "CommandDownload.h" |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
44 |
#include "CommandFoeRead.h" |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
45 |
#include "CommandFoeWrite.h" |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
46 |
#include "CommandGraph.h" |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
47 |
#include "CommandMaster.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
48 |
#include "CommandPdos.h" |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
49 |
#include "CommandRegRead.h" |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
50 |
#include "CommandRegWrite.h" |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
51 |
#include "CommandSdos.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
52 |
#include "CommandSiiRead.h" |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
53 |
#include "CommandSiiWrite.h" |
1165
c5d6e28eec91
Added 'ethercat version' command.
Florian Pose <fp@igh-essen.com>
parents:
1158
diff
changeset
|
54 |
#include "CommandSlaves.h" |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
55 |
#include "CommandStates.h" |
1165
c5d6e28eec91
Added 'ethercat version' command.
Florian Pose <fp@igh-essen.com>
parents:
1158
diff
changeset
|
56 |
#include "CommandUpload.h" |
c5d6e28eec91
Added 'ethercat version' command.
Florian Pose <fp@igh-essen.com>
parents:
1158
diff
changeset
|
57 |
#include "CommandVersion.h" |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
58 |
#include "CommandXml.h" |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
59 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
60 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
61 |
|
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
62 |
typedef list<Command *> CommandList; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
63 |
CommandList commandList; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
64 |
|
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
65 |
MasterDevice masterDev; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
66 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
67 |
string binaryBaseName; |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
68 |
string commandName; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
69 |
Command::StringVector commandArgs; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
70 |
|
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
71 |
// option variables |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
72 |
unsigned int masterIndex = 0; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
73 |
int slavePosition = -1; |
1151 | 74 |
int slaveAlias = -1; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
75 |
int domainIndex = -1; |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
76 |
string dataTypeStr; |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
77 |
Command::Verbosity verbosity = Command::Normal; |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
78 |
bool force = false; |
1121 | 79 |
bool helpRequested = false; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
80 |
string outputFile; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
82 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
83 |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
84 |
string usage() |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
85 |
{ |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
86 |
stringstream str; |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
87 |
CommandList::const_iterator ci; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
88 |
size_t maxWidth = 0; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
89 |
|
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
90 |
for (ci = commandList.begin(); ci != commandList.end(); ci++) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
91 |
if ((*ci)->getName().length() > maxWidth) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
92 |
maxWidth = (*ci)->getName().length(); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
93 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
94 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
95 |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
96 |
str << "Usage: " << binaryBaseName << " <COMMAND> [OPTIONS] [ARGUMENTS]" |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
97 |
<< endl << endl |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
98 |
<< "Commands (can be abbreviated):" << endl; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
99 |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
100 |
str << left; |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
101 |
for (ci = commandList.begin(); ci != commandList.end(); ci++) { |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
102 |
str << " " << setw(maxWidth) << (*ci)->getName() |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
103 |
<< " " << (*ci)->getBriefDescription() << endl; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
104 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1125
diff
changeset
|
105 |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
106 |
str << endl |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
107 |
<< "Global options:" << endl |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
108 |
<< " --master -m <master> Index of the master to use. Default: 0." |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
109 |
<< endl |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
110 |
<< " --force -f Force a command." << endl |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
111 |
<< " --quiet -q Output less information." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
112 |
<< " --verbose -v Output more information." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
113 |
<< " --help -h Show this help." << endl |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
114 |
<< endl |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
115 |
<< Command::numericInfo() |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
116 |
<< endl |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
117 |
<< "Call '" << binaryBaseName |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
118 |
<< " <COMMAND> --help' for command-specific help." << endl |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
119 |
<< endl |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
120 |
<< "Send bug reports to " << PACKAGE_BUGREPORT << "." << endl; |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
121 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
122 |
return str.str(); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
123 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
124 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
125 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
126 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
127 |
void getOptions(int argc, char **argv) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
128 |
{ |
1158
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
129 |
int c, argCount; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
130 |
stringstream str; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
131 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
132 |
static struct option longOptions[] = { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
133 |
//name, has_arg, flag, val |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
134 |
{"master", required_argument, NULL, 'm'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
135 |
{"alias", required_argument, NULL, 'a'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
136 |
{"position", required_argument, NULL, 'p'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
137 |
{"domain", required_argument, NULL, 'd'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
138 |
{"type", required_argument, NULL, 't'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
139 |
{"output-file", required_argument, NULL, 'o'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
140 |
{"force", no_argument, NULL, 'f'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
141 |
{"quiet", no_argument, NULL, 'q'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
142 |
{"verbose", no_argument, NULL, 'v'}, |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
143 |
{"help", no_argument, NULL, 'h'}, |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
144 |
{} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
145 |
}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
146 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
147 |
do { |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
148 |
c = getopt_long(argc, argv, "m:a:p:d:t:o:fqvh", longOptions, NULL); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
149 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
150 |
switch (c) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
151 |
case 'm': |
1158
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
152 |
str.clear(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
153 |
str.str(""); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
154 |
str << optarg; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
155 |
str >> resetiosflags(ios::basefield) // guess base from prefix |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
156 |
>> masterIndex; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
157 |
if (str.fail() || masterIndex < 0) { |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
158 |
cerr << "Invalid master number " << optarg << "!" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
159 |
<< endl << usage(); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
160 |
exit(1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
161 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
162 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
163 |
|
1151 | 164 |
case 'a': |
1158
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
165 |
str.clear(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
166 |
str.str(""); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
167 |
str << optarg; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
168 |
str >> resetiosflags(ios::basefield) // guess base from prefix |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
169 |
>> slaveAlias; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
170 |
if (str.fail() || slaveAlias < 0 || slaveAlias > 0xFFFF) { |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
171 |
cerr << "Invalid slave alias " << optarg << "!" << endl |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
172 |
<< endl << usage(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
173 |
exit(1); |
1151 | 174 |
} |
175 |
break; |
|
176 |
||
177 |
case 'p': |
|
1158
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
178 |
str.clear(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
179 |
str.str(""); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
180 |
str << optarg; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
181 |
str >> resetiosflags(ios::basefield) // guess base from prefix |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
182 |
>> slavePosition; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
183 |
if (str.fail() |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
184 |
|| slavePosition < 0 || slavePosition > 0xFFFF) { |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
185 |
cerr << "Invalid slave position " << optarg << "!" << endl |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
186 |
<< endl << usage(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
187 |
exit(1); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
188 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
189 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
190 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
191 |
case 'd': |
1158
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
192 |
str.clear(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
193 |
str.str(""); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
194 |
str << optarg; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
195 |
str >> resetiosflags(ios::basefield) // guess base from prefix |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
196 |
>> domainIndex; |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
197 |
if (str.fail() || domainIndex < 0) { |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
198 |
cerr << "Invalid domain index " << optarg << "!" << endl |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
199 |
<< endl << usage(); |
f65164fa4a58
Removed parameter values 'all'.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
200 |
exit(1); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
201 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
202 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
203 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
204 |
case 't': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
205 |
dataTypeStr = optarg; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
206 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
207 |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
208 |
case 'o': |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
209 |
outputFile = optarg; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
210 |
break; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
211 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
212 |
case 'f': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
213 |
force = true; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
214 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
215 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
216 |
case 'q': |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
217 |
verbosity = Command::Quiet; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
218 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
219 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
220 |
case 'v': |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
221 |
verbosity = Command::Verbose; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
222 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
223 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
224 |
case 'h': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
225 |
helpRequested = true; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
226 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
227 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
228 |
case '?': |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
229 |
cerr << endl << usage(); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
230 |
exit(1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
231 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
232 |
default: |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
233 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
234 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
235 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
236 |
while (c != -1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
237 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
238 |
argCount = argc - optind; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
239 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
240 |
if (!argCount) { |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
241 |
if (helpRequested) { |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
242 |
cout << usage(); |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
243 |
exit(0); |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
244 |
} else { |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
245 |
cerr << "Please specify a command!" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
246 |
<< endl << usage(); |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
247 |
exit(1); |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
248 |
} |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
249 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
250 |
|
1125 | 251 |
commandName = argv[optind]; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
252 |
while (++optind < argc) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
253 |
commandArgs.push_back(string(argv[optind])); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
254 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
255 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
256 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
257 |
|
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
258 |
list<Command *> getMatchingCommands(const string &cmdStr) |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
259 |
{ |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
260 |
CommandList::iterator ci; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
261 |
list<Command *> res; |
1125 | 262 |
|
1127 | 263 |
// find matching commands from beginning of the string |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
264 |
for (ci = commandList.begin(); ci != commandList.end(); ci++) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
265 |
if ((*ci)->matchesSubstr(cmdStr)) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
266 |
res.push_back(*ci); |
1125 | 267 |
} |
268 |
} |
|
269 |
||
1127 | 270 |
if (!res.size()) { // nothing found |
271 |
// find /any/ matching commands |
|
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
272 |
for (ci = commandList.begin(); ci != commandList.end(); ci++) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
273 |
if ((*ci)->matchesAbbrev(cmdStr)) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
274 |
res.push_back(*ci); |
1127 | 275 |
} |
276 |
} |
|
277 |
} |
|
278 |
||
1125 | 279 |
return res; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
280 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
281 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
282 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
283 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
284 |
int main(int argc, char **argv) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
285 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
286 |
int retval = 0; |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
287 |
list<Command *> matchingCommands; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
288 |
list<Command *>::const_iterator ci; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
289 |
Command *cmd; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
290 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
291 |
binaryBaseName = basename(argv[0]); |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
292 |
|
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
293 |
commandList.push_back(new CommandAlias()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
294 |
commandList.push_back(new CommandConfig()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
295 |
commandList.push_back(new CommandData()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
296 |
commandList.push_back(new CommandDebug()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
297 |
commandList.push_back(new CommandDomains()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
298 |
commandList.push_back(new CommandDownload()); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
299 |
commandList.push_back(new CommandFoeRead()); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
300 |
commandList.push_back(new CommandFoeWrite()); |
1422
d41e4537b75f
Added 'ethercat graph' command.
Florian Pose <fp@igh-essen.com>
parents:
1388
diff
changeset
|
301 |
commandList.push_back(new CommandGraph()); |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
302 |
commandList.push_back(new CommandMaster()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
303 |
commandList.push_back(new CommandPdos()); |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
304 |
commandList.push_back(new CommandRegRead()); |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
305 |
commandList.push_back(new CommandRegWrite()); |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
306 |
commandList.push_back(new CommandSdos()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
307 |
commandList.push_back(new CommandSiiRead()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
308 |
commandList.push_back(new CommandSiiWrite()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
309 |
commandList.push_back(new CommandSlaves()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
310 |
commandList.push_back(new CommandStates()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
311 |
commandList.push_back(new CommandUpload()); |
1165
c5d6e28eec91
Added 'ethercat version' command.
Florian Pose <fp@igh-essen.com>
parents:
1158
diff
changeset
|
312 |
commandList.push_back(new CommandVersion()); |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
313 |
commandList.push_back(new CommandXml()); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
314 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
315 |
getOptions(argc, argv); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
316 |
|
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
317 |
matchingCommands = getMatchingCommands(commandName); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
318 |
masterDev.setIndex(masterIndex); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
319 |
|
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
320 |
if (matchingCommands.size()) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
321 |
if (matchingCommands.size() == 1) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
322 |
cmd = matchingCommands.front(); |
1125 | 323 |
if (!helpRequested) { |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
324 |
try { |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
325 |
cmd->setVerbosity(verbosity); |
1151 | 326 |
cmd->setAlias(slaveAlias); |
327 |
cmd->setPosition(slavePosition); |
|
1166 | 328 |
cmd->setDomain(domainIndex); |
329 |
cmd->setDataType(dataTypeStr); |
|
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
330 |
cmd->setOutputFile(outputFile); |
1166 | 331 |
cmd->setForce(force); |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
332 |
cmd->execute(masterDev, commandArgs); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
333 |
} catch (InvalidUsageException &e) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
334 |
cerr << e.what() << endl << endl; |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
335 |
cerr << binaryBaseName << " " << cmd->helpString(); |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
336 |
retval = 1; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
337 |
} catch (CommandException &e) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
338 |
cerr << e.what() << endl; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
339 |
retval = 1; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
340 |
} catch (MasterDeviceException &e) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
341 |
cerr << e.what() << endl; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
342 |
retval = 1; |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
343 |
} |
1125 | 344 |
} else { |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
345 |
cout << binaryBaseName << " " << cmd->helpString(); |
1125 | 346 |
} |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
347 |
} else { |
1128 | 348 |
cerr << "Ambiguous command abbreviation! Matching:" << endl; |
1142
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
349 |
for (ci = matchingCommands.begin(); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
350 |
ci != matchingCommands.end(); |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
351 |
ci++) { |
59be91dfcbe1
Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
1139
diff
changeset
|
352 |
cerr << (*ci)->getName() << endl; |
1125 | 353 |
} |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
354 |
cerr << endl << usage(); |
1125 | 355 |
retval = 1; |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
356 |
} |
1125 | 357 |
} else { |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
358 |
cerr << "Unknown command " << commandName << "!" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
359 |
<< endl << usage(); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
360 |
retval = 1; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
361 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
362 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
363 |
return retval; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
364 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
365 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
366 |
/****************************************************************************/ |