author | Florian Pose <fp@igh-essen.com> |
Wed, 08 Apr 2009 14:49:36 +0000 | |
changeset 1390 | 7e600a39a91b |
parent 1379 | cbceb0e2f2a0 |
child 1419 | 8fc38c37d86e |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
3 |
* $Id$ |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
4 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
6 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
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:
1337
diff
changeset
|
8 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
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:
1337
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:
1337
diff
changeset
|
11 |
* published by the Free Software Foundation. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
12 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
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:
1337
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:
1337
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:
1337
diff
changeset
|
16 |
* Public License for more details. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
17 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
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:
1337
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:
1337
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:
1337
diff
changeset
|
21 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
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:
1337
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:
1337
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1142 | 27 |
* |
28 |
****************************************************************************/ |
|
29 |
||
30 |
#include <iostream> |
|
31 |
#include <iomanip> |
|
32 |
#include <list> |
|
1222
7348d6abb6cb
Applied patch by Karsten Schwinne, adding a few header files necessary
Florian Pose <fp@igh-essen.com>
parents:
1220
diff
changeset
|
33 |
#include <string.h> |
1142 | 34 |
using namespace std; |
35 |
||
36 |
#include "CommandSlaves.h" |
|
37 |
||
38 |
/*****************************************************************************/ |
|
39 |
||
40 |
CommandSlaves::CommandSlaves(): |
|
41 |
Command("slaves", "Display slaves on the bus.") |
|
42 |
{ |
|
43 |
} |
|
44 |
||
45 |
/*****************************************************************************/ |
|
46 |
||
47 |
string CommandSlaves::helpString() const |
|
48 |
{ |
|
49 |
stringstream str; |
|
50 |
||
51 |
str << getName() << " [OPTIONS]" << endl |
|
52 |
<< endl |
|
53 |
<< getBriefDescription() << endl |
|
54 |
<< endl |
|
55 |
<< "If the --verbose option is not given, the slaves are" << endl |
|
56 |
<< "displayed one-per-line. Example:" << endl |
|
57 |
<< endl |
|
58 |
<< "1 5555:0 PREOP + EL3162 2C. Ana. Input 0-10V" << endl |
|
59 |
<< "| | | | | |" << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
60 |
<< "| | | | | \\- Name from the SII if avaliable," << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
61 |
<< "| | | | | otherwise vendor ID and product" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
62 |
<< "| | | | | code (both hexadecimal)." << endl |
1142 | 63 |
<< "| | | | \\- Error flag. '+' means no error," << endl |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
64 |
<< "| | | | 'E' means that scan or" << endl |
1142 | 65 |
<< "| | | | configuration failed." << endl |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
66 |
<< "| | | \\- Current application-layer state." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
67 |
<< "| | \\- Decimal relative position to the last" << endl |
1142 | 68 |
<< "| | slave with an alias address set." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
69 |
<< "| \\- Decimal alias address of this slave (if set)," << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
70 |
<< "| otherwise of the last slave with an alias set," << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
71 |
<< "| or zero, if no alias was encountered up to this" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
72 |
<< "| position." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
73 |
<< "\\- Absolute ring position in the bus." << endl |
1142 | 74 |
<< endl |
75 |
<< "If the --verbose option is given, a detailed (multi-line)" << endl |
|
76 |
<< "description is output for each slave." << endl |
|
77 |
<< endl |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
78 |
<< "Slave selection:" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
79 |
<< " Slaves for this and other commands can be selected with" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
80 |
<< " the --alias and --position parameters as follows:" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
81 |
<< endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
82 |
<< " 1) If neither the --alias nor the --position option" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
83 |
<< " is given, all slaves are selected." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
84 |
<< " 2) If only the --position option is given, it is" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
85 |
<< " interpreted as an absolute ring position and" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
86 |
<< " a slave with this position is matched." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
87 |
<< " 3) If only the --alias option is given, all slaves" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
88 |
<< " with the given alias address and subsequent" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
89 |
<< " slaves before a slave with a different alias" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
90 |
<< " address match (use -p0 if only the slaves" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
91 |
<< " with the given alias are desired, see 4))." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
92 |
<< " 4) If both the --alias and the --position option are" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
93 |
<< " given, the latter is interpreted as relative" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
94 |
<< " position behind any slave with the given alias." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
95 |
<< endl |
1142 | 96 |
<< "Command-specific options:" << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
97 |
<< " --alias -a <alias> Slave alias (see above)." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
98 |
<< " --position -p <pos> Slave position (see above)." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
99 |
<< " --verbose -v Show detailed slave information." << endl |
1142 | 100 |
<< endl |
101 |
<< numericInfo(); |
|
102 |
||
103 |
return str.str(); |
|
104 |
} |
|
105 |
||
106 |
/****************************************************************************/ |
|
107 |
||
108 |
void CommandSlaves::execute(MasterDevice &m, const StringVector &args) |
|
109 |
{ |
|
1151 | 110 |
SlaveList slaves; |
111 |
||
1373
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
112 |
if (args.size()) { |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
113 |
stringstream err; |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
114 |
err << "'" << getName() << "' takes no arguments!"; |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
115 |
throwInvalidUsageException(err); |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
116 |
} |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
117 |
|
1142 | 118 |
m.open(MasterDevice::Read); |
1151 | 119 |
slaves = selectedSlaves(m); |
1142 | 120 |
|
121 |
if (getVerbosity() == Verbose) { |
|
1151 | 122 |
showSlaves(m, slaves); |
1142 | 123 |
} else { |
1151 | 124 |
listSlaves(m, slaves); |
1142 | 125 |
} |
126 |
} |
|
127 |
||
128 |
/****************************************************************************/ |
|
129 |
||
130 |
void CommandSlaves::listSlaves( |
|
131 |
MasterDevice &m, |
|
1151 | 132 |
const SlaveList &slaves |
1142 | 133 |
) |
134 |
{ |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
135 |
ec_ioctl_master_t master; |
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
136 |
unsigned int i; |
1142 | 137 |
ec_ioctl_slave_t slave; |
138 |
uint16_t lastAlias, aliasIndex; |
|
139 |
Info info; |
|
140 |
typedef list<Info> InfoList; |
|
141 |
InfoList infoList; |
|
142 |
InfoList::const_iterator iter; |
|
143 |
stringstream str; |
|
144 |
unsigned int maxPosWidth = 0, maxAliasWidth = 0, |
|
145 |
maxRelPosWidth = 0, maxStateWidth = 0; |
|
146 |
||
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
147 |
m.getMaster(&master); |
1142 | 148 |
|
149 |
lastAlias = 0; |
|
150 |
aliasIndex = 0; |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
151 |
for (i = 0; i < master.slave_count; i++) { |
1142 | 152 |
m.getSlave(&slave, i); |
153 |
||
154 |
if (slave.alias) { |
|
155 |
lastAlias = slave.alias; |
|
156 |
aliasIndex = 0; |
|
157 |
} |
|
158 |
||
1151 | 159 |
if (slaveInList(slave, slaves)) { |
1142 | 160 |
str << dec << i; |
161 |
info.pos = str.str(); |
|
162 |
str.clear(); |
|
163 |
str.str(""); |
|
164 |
||
165 |
str << lastAlias; |
|
166 |
info.alias = str.str(); |
|
167 |
str.str(""); |
|
168 |
||
169 |
str << aliasIndex; |
|
170 |
info.relPos = str.str(); |
|
171 |
str.str(""); |
|
172 |
||
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1146
diff
changeset
|
173 |
info.state = alStateString(slave.al_state); |
1142 | 174 |
info.flag = (slave.error_flag ? 'E' : '+'); |
175 |
||
176 |
if (strlen(slave.name)) { |
|
177 |
info.name = slave.name; |
|
178 |
} else { |
|
179 |
str << "0x" << hex << setfill('0') |
|
180 |
<< setw(8) << slave.vendor_id << ":0x" |
|
181 |
<< setw(8) << slave.product_code; |
|
182 |
info.name = str.str(); |
|
183 |
str.str(""); |
|
184 |
} |
|
185 |
||
186 |
||
187 |
infoList.push_back(info); |
|
188 |
||
189 |
if (info.pos.length() > maxPosWidth) |
|
190 |
maxPosWidth = info.pos.length(); |
|
191 |
if (info.alias.length() > maxAliasWidth) |
|
192 |
maxAliasWidth = info.alias.length(); |
|
193 |
if (info.relPos.length() > maxRelPosWidth) |
|
194 |
maxRelPosWidth = info.relPos.length(); |
|
195 |
if (info.state.length() > maxStateWidth) |
|
196 |
maxStateWidth = info.state.length(); |
|
197 |
} |
|
198 |
||
199 |
aliasIndex++; |
|
200 |
} |
|
201 |
||
202 |
for (iter = infoList.begin(); iter != infoList.end(); iter++) { |
|
203 |
cout << setfill(' ') << right |
|
204 |
<< setw(maxPosWidth) << iter->pos << " " |
|
205 |
<< setw(maxAliasWidth) << iter->alias |
|
206 |
<< ":" << left |
|
207 |
<< setw(maxRelPosWidth) << iter->relPos << " " |
|
208 |
<< setw(maxStateWidth) << iter->state << " " |
|
209 |
<< iter->flag << " " |
|
210 |
<< iter->name << endl; |
|
211 |
} |
|
212 |
} |
|
213 |
||
214 |
/****************************************************************************/ |
|
215 |
||
1151 | 216 |
void CommandSlaves::showSlaves( |
1142 | 217 |
MasterDevice &m, |
1151 | 218 |
const SlaveList &slaves |
1142 | 219 |
) |
220 |
{ |
|
1151 | 221 |
SlaveList::const_iterator si; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
222 |
int i; |
1151 | 223 |
|
224 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
|
225 |
cout << "=== Slave " << dec << si->position << " ===" << endl; |
|
226 |
||
227 |
if (si->alias) |
|
228 |
cout << "Alias: " << si->alias << endl; |
|
229 |
||
230 |
cout |
|
231 |
<< "State: " << alStateString(si->al_state) << endl |
|
232 |
<< "Flag: " << (si->error_flag ? 'E' : '+') << endl |
|
233 |
<< "Identity:" << endl |
|
234 |
<< " Vendor Id: 0x" |
|
235 |
<< hex << setfill('0') |
|
236 |
<< setw(8) << si->vendor_id << endl |
|
237 |
<< " Product code: 0x" |
|
238 |
<< setw(8) << si->product_code << endl |
|
239 |
<< " Revision number: 0x" |
|
240 |
<< setw(8) << si->revision_number << endl |
|
241 |
<< " Serial number: 0x" |
|
242 |
<< setw(8) << si->serial_number << endl; |
|
243 |
||
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
244 |
cout << "Ports:" << endl; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
245 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
246 |
cout << " " << i << ": "; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
247 |
switch (si->ports[i]) { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
248 |
case EC_PORT_NOT_IMPLEMENTED: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
249 |
cout << "Not implemented."; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
250 |
break; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
251 |
case EC_PORT_NOT_CONFIGURED: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
252 |
cout << "Not configured."; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
253 |
break; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
254 |
case EC_PORT_EBUS: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
255 |
cout << "EBUS."; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
256 |
break; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
257 |
case EC_PORT_MII: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
258 |
cout << "MII."; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
259 |
break; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
260 |
default: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
261 |
cout << "???"; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
262 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
263 |
cout << endl; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
264 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
265 |
|
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
266 |
cout << "DL information:" << endl |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
267 |
<< " FMMU bit operation: " |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
268 |
<< (si->fmmu_bit ? "yes" : "no") << endl |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
269 |
<< " Distributed clocks: "; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
270 |
if (si->dc_supported) { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
271 |
cout << "yes ("; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
272 |
switch (si->dc_range) { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
273 |
case EC_DC_32: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
274 |
cout << "32 bit"; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
275 |
break; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
276 |
case EC_DC_64: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
277 |
cout << "64 bit"; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
278 |
break; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
279 |
default: |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
280 |
cout << "???"; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
281 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
282 |
cout << ")"; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
283 |
} else { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
284 |
cout << "no"; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
285 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
286 |
cout << endl; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
287 |
|
1151 | 288 |
if (si->mailbox_protocols) { |
1220
15e8768b304f
Fixed minor supported mailbox protocol display bug.
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
289 |
list<string> protoList; |
15e8768b304f
Fixed minor supported mailbox protocol display bug.
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
290 |
list<string>::const_iterator protoIter; |
15e8768b304f
Fixed minor supported mailbox protocol display bug.
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
291 |
|
1151 | 292 |
cout << "Mailboxes:" << endl |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
293 |
<< " Bootstrap RX: 0x" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
294 |
<< hex << setw(4) << si->boot_rx_mailbox_offset << "/" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
295 |
<< dec << si->boot_rx_mailbox_size |
1151 | 296 |
<< ", TX: 0x" |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
297 |
<< hex << setw(4) << si->boot_tx_mailbox_offset << "/" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
298 |
<< dec << si->boot_tx_mailbox_size << endl |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
299 |
<< " Standard RX: 0x" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
300 |
<< hex << setw(4) << si->std_rx_mailbox_offset << "/" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
301 |
<< dec << si->std_rx_mailbox_size |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
302 |
<< ", TX: 0x" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
303 |
<< hex << setw(4) << si->std_tx_mailbox_offset << "/" |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
304 |
<< dec << si->std_tx_mailbox_size << endl |
1151 | 305 |
<< " Supported protocols: "; |
306 |
||
307 |
if (si->mailbox_protocols & EC_MBOX_AOE) { |
|
308 |
protoList.push_back("AoE"); |
|
309 |
} |
|
310 |
if (si->mailbox_protocols & EC_MBOX_EOE) { |
|
311 |
protoList.push_back("EoE"); |
|
312 |
} |
|
313 |
if (si->mailbox_protocols & EC_MBOX_COE) { |
|
314 |
protoList.push_back("CoE"); |
|
315 |
} |
|
316 |
if (si->mailbox_protocols & EC_MBOX_FOE) { |
|
317 |
protoList.push_back("FoE"); |
|
318 |
} |
|
319 |
if (si->mailbox_protocols & EC_MBOX_SOE) { |
|
320 |
protoList.push_back("SoE"); |
|
321 |
} |
|
322 |
if (si->mailbox_protocols & EC_MBOX_VOE) { |
|
323 |
protoList.push_back("VoE"); |
|
324 |
} |
|
325 |
||
326 |
for (protoIter = protoList.begin(); protoIter != protoList.end(); |
|
327 |
protoIter++) { |
|
328 |
if (protoIter != protoList.begin()) |
|
329 |
cout << ", "; |
|
330 |
cout << *protoIter; |
|
331 |
} |
|
332 |
cout << endl; |
|
333 |
} |
|
334 |
||
335 |
if (si->has_general_category) { |
|
336 |
cout << "General:" << endl |
|
337 |
<< " Group: " << si->group << endl |
|
338 |
<< " Image name: " << si->image << endl |
|
339 |
<< " Order number: " << si->order << endl |
|
340 |
<< " Device name: " << si->name << endl; |
|
341 |
||
342 |
if (si->mailbox_protocols & EC_MBOX_COE) { |
|
343 |
cout << " CoE details:" << endl |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
344 |
<< " Enable SDO: " |
1151 | 345 |
<< (si->coe_details.enable_sdo ? "yes" : "no") << endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
346 |
<< " Enable SDO Info: " |
1151 | 347 |
<< (si->coe_details.enable_sdo_info ? "yes" : "no") << endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
348 |
<< " Enable PDO Assign: " |
1151 | 349 |
<< (si->coe_details.enable_pdo_assign |
350 |
? "yes" : "no") << endl |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
351 |
<< " Enable PDO Configuration: " |
1151 | 352 |
<< (si->coe_details.enable_pdo_configuration |
353 |
? "yes" : "no") << endl |
|
354 |
<< " Enable Upload at startup: " |
|
355 |
<< (si->coe_details.enable_upload_at_startup |
|
356 |
? "yes" : "no") << endl |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1222
diff
changeset
|
357 |
<< " Enable SDO complete access: " |
1151 | 358 |
<< (si->coe_details.enable_sdo_complete_access |
359 |
? "yes" : "no") << endl; |
|
360 |
} |
|
361 |
||
362 |
cout << " Flags:" << endl |
|
363 |
<< " Enable SafeOp: " |
|
364 |
<< (si->general_flags.enable_safeop ? "yes" : "no") << endl |
|
365 |
<< " Enable notLRW: " |
|
366 |
<< (si->general_flags.enable_not_lrw ? "yes" : "no") << endl |
|
367 |
<< " Current consumption: " |
|
368 |
<< dec << si->current_on_ebus << " mA" << endl; |
|
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
/****************************************************************************/ |
|
374 |
||
375 |
bool CommandSlaves::slaveInList( |
|
376 |
const ec_ioctl_slave_t &slave, |
|
377 |
const SlaveList &slaves |
|
378 |
) |
|
379 |
{ |
|
380 |
SlaveList::const_iterator si; |
|
381 |
||
382 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
|
383 |
if (si->position == slave.position) { |
|
384 |
return true; |
|
385 |
} |
|
386 |
} |
|
387 |
||
388 |
return false; |
|
1142 | 389 |
} |
390 |
||
391 |
/*****************************************************************************/ |