author | Florian Pose <fp@igh-essen.com> |
Tue, 22 Jul 2008 08:56:53 +0000 | |
changeset 1123 | 17bef224061d |
parent 1122 | ee305a780a02 |
child 1125 | 9976f7b9fe66 |
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 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
#include <getopt.h> |
1118 | 8 |
#include <libgen.h> // basename() |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
#include <iostream> |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
#include <string> |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
953
diff
changeset
|
12 |
#include <vector> |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
using namespace std; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
15 |
#include "globals.h" |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
16 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
17 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
18 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
19 |
string binaryBaseName; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
20 |
unsigned int masterIndex = 0; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
21 |
int slavePosition = -1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
22 |
int domainIndex = -1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
23 |
string command; |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
953
diff
changeset
|
24 |
vector<string> commandArgs; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
25 |
Verbosity verbosity = Normal; |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
26 |
string dataTypeStr; |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
27 |
bool force = false; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
28 |
|
1121 | 29 |
bool helpRequested = false; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
31 |
MasterDevice masterDev; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
32 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
33 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
34 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
35 |
struct Command { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
36 |
void (*func)(void); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
37 |
const char *helpString; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
38 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
39 |
int execute(void) const; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
40 |
void displayHelp(void) const; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
41 |
}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
42 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
43 |
struct CommandAlias { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
44 |
const char *name; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
45 |
const Command *command; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
46 |
}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
47 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
48 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
49 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
50 |
#define COMMAND(name) \ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
51 |
void command_##name(void); \ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
52 |
extern const char *help_##name; \ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
53 |
const Command cmd_##name = {command_##name, help_##name}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
54 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
55 |
COMMAND(alias); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
56 |
COMMAND(config); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
57 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
58 |
const CommandAlias commandAliases[] = { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
59 |
{"alias", &cmd_alias}, |
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 |
{"config", &cmd_config}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
62 |
{"conf", &cmd_config}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
63 |
{"cf", &cmd_config}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
64 |
}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
65 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
66 |
#if 0 |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
67 |
} else if (command == "data") { |
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
68 |
master.outputData(domainIndex); |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
953
diff
changeset
|
69 |
} else if (command == "debug") { |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
953
diff
changeset
|
70 |
master.setDebug(commandArgs); |
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
71 |
} else if (command == "domain") { |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
72 |
master.showDomains(domainIndex); |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
73 |
} else if (command == "master") { |
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
74 |
master.showMaster(); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
75 |
} else if (command == "pdos") { |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
76 |
master.listPdos(slavePosition); |
965
1aee4aa1def3
Implemented Sdo dictionary info via 'ethercat sdos'.
Florian Pose <fp@igh-essen.com>
parents:
960
diff
changeset
|
77 |
} else if (command == "sdos") { |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
78 |
master.listSdos(slavePosition); |
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
79 |
} else if (command == "sdo_download" || command == "sd") { |
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
80 |
master.sdoDownload(slavePosition, dataTypeStr, commandArgs); |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
81 |
} else if (command == "sdo_upload" || command == "su") { |
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
82 |
master.sdoUpload(slavePosition, dataTypeStr, commandArgs); |
1065
d1d2aa556344
United 'ethercat slaves' and 'ethercat list' with a verbose flag.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
83 |
} else if (command == "slave" || command == "slaves" |
d1d2aa556344
United 'ethercat slaves' and 'ethercat list' with a verbose flag.
Florian Pose <fp@igh-essen.com>
parents:
990
diff
changeset
|
84 |
|| command == "list" || command == "ls") { |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
85 |
master.showSlaves(slavePosition); |
978 | 86 |
} else if (command == "sii_read" || command == "sr") { |
87 |
master.siiRead(slavePosition); |
|
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
88 |
} else if (command == "sii_write" || command == "sw") { |
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
89 |
master.siiWrite(slavePosition, force, commandArgs); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
90 |
} else if (command == "state") { |
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
91 |
master.requestStates(slavePosition, commandArgs); |
938
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
936
diff
changeset
|
92 |
} else if (command == "xml") { |
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
936
diff
changeset
|
93 |
master.generateXml(slavePosition); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
94 |
#endif |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
95 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
96 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
97 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
98 |
void printUsage() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
99 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
100 |
cerr |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
101 |
<< "Usage: " << binaryBaseName << " <COMMAND> [OPTIONS]" << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
102 |
<< "Commands:" << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
103 |
<< " alias Write alias addresses." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
104 |
<< " config Show bus configuration." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
105 |
<< " data Output binary domain process data." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
106 |
<< " debug Set the master's debug level." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
107 |
<< " domain Show domain information." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
108 |
<< " master Show master information." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
109 |
<< " pdos List Pdo assignment/mapping." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
110 |
<< " sdo_download Write an Sdo entry." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
111 |
<< " sdos List Sdo dictionaries." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
112 |
<< " sdo_upload Read an Sdo entry." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
113 |
<< " sii_read Output a slave's SII contents." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
114 |
<< " sii_write Write slave's SII contents." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
115 |
<< " slaves Show slaves." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
116 |
<< " state Request slave states." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
117 |
<< " xml Generate slave information xmls." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
118 |
<< "Global options:" << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
119 |
<< " --master -m <master> Index of the master to use. Default: 0" |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
120 |
<< endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
121 |
<< " --slave -s <index> Positive numerical ring position," |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
122 |
<< endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
123 |
<< " or 'all' for all slaves (default)." |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
124 |
<< endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
125 |
<< " --domain -d <index> Positive numerical index," |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
126 |
<< endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
127 |
<< " or 'all' for all domains (default)." |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
128 |
<< endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
129 |
<< " --type -t <type> Forced Sdo data type." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
130 |
<< " --force -f Force action." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
131 |
<< " --quiet -q Output less information." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
132 |
<< " --verbose -v Output more information." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
133 |
<< " --help -h Show this help." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
134 |
<< "Call '" << binaryBaseName |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
135 |
<< " <COMMAND> --help' for command-specific help." << endl |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
136 |
<< "Send bug reports to " << PACKAGE_BUGREPORT << "." << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
137 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
138 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
139 |
/*****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
140 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
141 |
void getOptions(int argc, char **argv) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
142 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
143 |
int c, argCount, optionIndex, number; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
144 |
char *remainder; |
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 |
static struct option longOptions[] = { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
147 |
//name, has_arg, flag, val |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
148 |
{"master", required_argument, NULL, 'm'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
149 |
{"slave", required_argument, NULL, 's'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
150 |
{"domain", required_argument, NULL, 'd'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
151 |
{"type", required_argument, NULL, 't'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
152 |
{"force", no_argument, NULL, 'f'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
153 |
{"quiet", no_argument, NULL, 'q'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
154 |
{"verbose", no_argument, NULL, 'v'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
155 |
{"help", no_argument, NULL, 'h'}, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
156 |
{} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
157 |
}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
158 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
159 |
do { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
160 |
c = getopt_long(argc, argv, "m:s:d:t:fqvh", longOptions, &optionIndex); |
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 |
switch (c) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
163 |
case 'm': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
164 |
number = strtoul(optarg, &remainder, 0); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
165 |
if (remainder == optarg || *remainder || number < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
166 |
cerr << "Invalid master number " << optarg << "!" << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
167 |
printUsage(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
168 |
exit(1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
169 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
170 |
masterIndex = number; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
171 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
172 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
173 |
case 's': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
174 |
if (!strcmp(optarg, "all")) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
175 |
slavePosition = -1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
176 |
} else { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
177 |
number = strtoul(optarg, &remainder, 0); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
178 |
if (remainder == optarg || *remainder |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
179 |
|| number < 0 || number > 0xFFFF) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
180 |
cerr << "Invalid slave position " |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
181 |
<< optarg << "!" << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
182 |
printUsage(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
183 |
exit(1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
184 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
185 |
slavePosition = number; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
186 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
187 |
break; |
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 |
case 'd': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
190 |
if (!strcmp(optarg, "all")) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
191 |
domainIndex = -1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
192 |
} else { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
193 |
number = strtoul(optarg, &remainder, 0); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
194 |
if (remainder == optarg || *remainder || number < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
195 |
cerr << "Invalid domain index " |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
196 |
<< optarg << "!" << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
197 |
printUsage(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
198 |
exit(1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
199 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
200 |
domainIndex = number; |
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
208 |
case 'f': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
209 |
force = true; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
210 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
211 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
212 |
case 'q': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
213 |
verbosity = Quiet; |
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 'v': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
217 |
verbosity = Verbose; |
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 'h': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
221 |
helpRequested = true; |
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 '?': |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
225 |
printUsage(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
226 |
exit(1); |
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 |
default: |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
229 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
230 |
} |
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 |
while (c != -1); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
233 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
234 |
argCount = argc - optind; |
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 |
if (!argCount) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
237 |
if (!helpRequested) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
238 |
cerr << "Please specify a command!" << endl; |
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 |
printUsage(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
241 |
exit(!helpRequested); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
242 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
243 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
244 |
command = argv[optind]; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
245 |
while (++optind < argc) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
246 |
commandArgs.push_back(string(argv[optind])); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
247 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
248 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
251 |
int Command::execute() const |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
252 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
253 |
try { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
254 |
func(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
255 |
} catch (InvalidUsageException &e) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
256 |
cerr << e.what() << endl << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
257 |
displayHelp(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
258 |
return 1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
259 |
} catch (ExecutionFailureException &e) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
260 |
cerr << e.what() << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
261 |
return 1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
262 |
} catch (MasterDeviceException &e) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
263 |
cerr << e.what() << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
264 |
return 1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
265 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
266 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
267 |
return 0; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
268 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
269 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
270 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
271 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
272 |
void Command::displayHelp() const |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
273 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
274 |
cerr << binaryBaseName << " " << command << " " << helpString; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
275 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
276 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
277 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
278 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
279 |
int main(int argc, char **argv) |
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 |
int retval = 0; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
282 |
const CommandAlias *alias; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
283 |
const CommandAlias *endAlias = |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
284 |
commandAliases + sizeof(commandAliases) / sizeof(CommandAlias); |
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 |
binaryBaseName = basename(argv[0]); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
287 |
getOptions(argc, argv); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
288 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
289 |
// search command alias in alias map |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
290 |
for (alias = commandAliases; alias < endAlias; alias++) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
291 |
if (command == alias->name) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
292 |
break; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
293 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
294 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
295 |
if (alias < endAlias) { // command alias found |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
296 |
if (!helpRequested) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
297 |
masterDev.setIndex(masterIndex); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
298 |
retval = alias->command->execute(); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
299 |
} else { |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
300 |
alias->command->displayHelp(); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
301 |
} |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
302 |
} else { // command not found |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
303 |
cerr << "Unknown command " << command << "!" << endl << endl; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
304 |
printUsage(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
305 |
retval = 1; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
1121
diff
changeset
|
308 |
return retval; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
310 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
/****************************************************************************/ |