author | Florian Pose <fp@igh-essen.com> |
Thu, 15 Oct 2009 17:38:53 +0200 | |
changeset 1541 | 26ac1c611100 |
parent 1526 | 66edd310830c |
child 1804 | 742607c464c4 |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
3 |
* $Id$ |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
4 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
6 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
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:
1327
diff
changeset
|
8 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
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:
1327
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:
1327
diff
changeset
|
11 |
* published by the Free Software Foundation. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
12 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
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:
1327
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:
1327
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:
1327
diff
changeset
|
16 |
* Public License for more details. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
17 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
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:
1327
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:
1327
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:
1327
diff
changeset
|
21 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
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:
1327
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:
1327
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1142 | 27 |
* |
28 |
****************************************************************************/ |
|
29 |
||
30 |
#include <list> |
|
31 |
#include <iostream> |
|
32 |
#include <iomanip> |
|
33 |
#include <sstream> |
|
34 |
using namespace std; |
|
35 |
||
36 |
#include "CommandConfig.h" |
|
37 |
||
38 |
/*****************************************************************************/ |
|
39 |
||
40 |
CommandConfig::CommandConfig(): |
|
41 |
Command("config", "Show slave configurations.") |
|
42 |
{ |
|
43 |
} |
|
44 |
||
45 |
/*****************************************************************************/ |
|
46 |
||
47 |
string CommandConfig::helpString() const |
|
48 |
{ |
|
49 |
stringstream str; |
|
50 |
||
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
51 |
str << getName() << " [OPTIONS]" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
52 |
<< endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
53 |
<< getBriefDescription() << endl |
1142 | 54 |
<< endl |
55 |
<< "Without the --verbose option, slave configurations are" << endl |
|
56 |
<< "output one-per-line. Example:" << endl |
|
57 |
<< endl |
|
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
58 |
<< "1001:0 0x0000003b/0x02010000 3 OP" << endl |
1142 | 59 |
<< "| | | |" << endl |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
60 |
<< "| | | \\- Application-layer" << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
61 |
<< "| | | state of the attached" << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
62 |
<< "| | | slave, or '-', if no" << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
63 |
<< "| | | slave is attached." << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
64 |
<< "| | \\- Absolute decimal ring" << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
65 |
<< "| | position of the attached" << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
66 |
<< "| | slave, or '-' if none" << endl |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
67 |
<< "| | attached." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
68 |
<< "| \\- Expected vendor ID and product code (both" << endl |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
69 |
<< "| hexadecimal)." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
70 |
<< "\\- Alias address and relative position (both decimal)." << endl |
1142 | 71 |
<< endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1254
diff
changeset
|
72 |
<< "With the --verbose option given, the configured PDOs and" << endl |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1254
diff
changeset
|
73 |
<< "SDOs are output in addition." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
74 |
<< endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
75 |
<< "Configuration selection:" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
76 |
<< " Slave configurations can be selected with" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
77 |
<< " the --alias and --position parameters as follows:" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
78 |
<< endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
79 |
<< " 1) If neither the --alias nor the --position option" << endl |
1167 | 80 |
<< " is given, all slave configurations are displayed." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
81 |
<< " 2) If only the --position option is given, an alias" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
82 |
<< " of zero is assumed (see 4))." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
83 |
<< " 3) If only the --alias option is given, all slave" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
84 |
<< " configurations with the given alias address" << endl |
1167 | 85 |
<< " are displayed." << endl |
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
86 |
<< " 4) If both the --alias and the --position option are" << endl |
1167 | 87 |
<< " given, the selection can match a single" << endl |
88 |
<< " configuration, that is displayed, if it exists." << endl |
|
1142 | 89 |
<< endl |
90 |
<< "Command-specific options:" << endl |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
91 |
<< " --alias -a <alias> Configuration alias (see above)." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
92 |
<< " --position -p <pos> Relative position (see above)." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
93 |
<< " --verbose -v Show detailed configurations." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
94 |
<< endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1156
diff
changeset
|
95 |
<< numericInfo(); |
1142 | 96 |
|
97 |
return str.str(); |
|
98 |
} |
|
99 |
||
100 |
/*****************************************************************************/ |
|
101 |
||
102 |
/** Lists the bus configuration. |
|
103 |
*/ |
|
104 |
void CommandConfig::execute(MasterDevice &m, const StringVector &args) |
|
105 |
{ |
|
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1148
diff
changeset
|
106 |
ConfigList configs; |
1142 | 107 |
|
1373
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
108 |
if (args.size()) { |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
109 |
stringstream err; |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
110 |
err << "'" << getName() << "' takes no arguments!"; |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
111 |
throwInvalidUsageException(err); |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
112 |
} |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
113 |
|
1142 | 114 |
m.open(MasterDevice::Read); |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1148
diff
changeset
|
115 |
configs = selectedConfigs(m); |
1142 | 116 |
|
117 |
if (getVerbosity() == Verbose) { |
|
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1148
diff
changeset
|
118 |
showDetailedConfigs(m, configs); |
1142 | 119 |
} else { |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1148
diff
changeset
|
120 |
listConfigs(m, configs); |
1142 | 121 |
} |
122 |
} |
|
123 |
||
124 |
/*****************************************************************************/ |
|
125 |
||
126 |
/** Lists the complete bus configuration. |
|
127 |
*/ |
|
128 |
void CommandConfig::showDetailedConfigs( |
|
129 |
MasterDevice &m, |
|
130 |
const ConfigList &configList |
|
131 |
) |
|
132 |
{ |
|
133 |
ConfigList::const_iterator configIter; |
|
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
134 |
unsigned int i, j, k, l; |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
135 |
ec_ioctl_slave_t slave; |
1142 | 136 |
ec_ioctl_config_pdo_t pdo; |
137 |
ec_ioctl_config_pdo_entry_t entry; |
|
138 |
ec_ioctl_config_sdo_t sdo; |
|
139 |
||
140 |
for (configIter = configList.begin(); |
|
141 |
configIter != configList.end(); |
|
142 |
configIter++) { |
|
143 |
||
144 |
cout << "Alias: " |
|
145 |
<< dec << configIter->alias << endl |
|
146 |
<< "Position: " << configIter->position << endl |
|
147 |
<< "Vendor Id: 0x" |
|
148 |
<< hex << setfill('0') |
|
149 |
<< setw(8) << configIter->vendor_id << endl |
|
150 |
<< "Product code: 0x" |
|
151 |
<< setw(8) << configIter->product_code << endl |
|
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
152 |
<< "Attached slave: "; |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
153 |
|
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
154 |
if (configIter->slave_position != -1) { |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
155 |
m.getSlave(&slave, configIter->slave_position); |
1172
74ee632c3b5e
Fixed attached slave position in 'ethercat config' -> decimal.
Florian Pose <fp@igh-essen.com>
parents:
1167
diff
changeset
|
156 |
cout << dec << configIter->slave_position |
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1147
diff
changeset
|
157 |
<< " (" << alStateString(slave.al_state) << ")" << endl; |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
158 |
} else { |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
159 |
cout << "none" << endl; |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
160 |
} |
1142 | 161 |
|
1519 | 162 |
cout << "Watchdog divider: "; |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
163 |
if (configIter->watchdog_divider) { |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
164 |
cout << dec << configIter->watchdog_divider; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
165 |
} else { |
1519 | 166 |
cout << "(Default)"; |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
167 |
} |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
168 |
cout << endl |
1519 | 169 |
<< "Watchdog intervals: "; |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
170 |
if (configIter->watchdog_intervals) { |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
171 |
cout << dec << configIter->watchdog_intervals; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
172 |
} else { |
1519 | 173 |
cout << "(Default)"; |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
174 |
} |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
175 |
cout << endl; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
176 |
|
1142 | 177 |
for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) { |
178 |
if (configIter->syncs[j].pdo_count) { |
|
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
179 |
cout << "SM" << dec << j << ", Dir: " |
1142 | 180 |
<< (configIter->syncs[j].dir == EC_DIR_INPUT |
1518
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
181 |
? "Input" : "Output") << ", Watchdog: "; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
182 |
switch (configIter->syncs[j].watchdog_mode) { |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
183 |
case EC_WD_DEFAULT: cout << "Default"; break; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
184 |
case EC_WD_ENABLE: cout << "Enable"; break; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
185 |
case EC_WD_DISABLE: cout << "Disable"; break; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
186 |
default: cout << "???"; break; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
187 |
} |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
188 |
cout << endl; |
ab5694a51826
Output watchdog configuration in ethercat config.
Florian Pose <fp@igh-essen.com>
parents:
1467
diff
changeset
|
189 |
|
1142 | 190 |
for (k = 0; k < configIter->syncs[j].pdo_count; k++) { |
191 |
m.getConfigPdo(&pdo, configIter->config_index, j, k); |
|
192 |
||
1467
013a4e42a9fb
Minor fix in 'ethercat config' output.
Florian Pose <fp@igh-essen.com>
parents:
1456
diff
changeset
|
193 |
cout << " PDO 0x" << hex << setfill('0') |
013a4e42a9fb
Minor fix in 'ethercat config' output.
Florian Pose <fp@igh-essen.com>
parents:
1456
diff
changeset
|
194 |
<< setw(4) << pdo.index << endl; |
1142 | 195 |
|
196 |
for (l = 0; l < pdo.entry_count; l++) { |
|
197 |
m.getConfigPdoEntry(&entry, |
|
198 |
configIter->config_index, j, k, l); |
|
199 |
||
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1254
diff
changeset
|
200 |
cout << " PDO entry 0x" << hex << setfill('0') |
1142 | 201 |
<< setw(4) << entry.index << ":" |
202 |
<< setw(2) << (unsigned int) entry.subindex |
|
1188
3b4e82d9904b
Don't show Pdo (entry) names in configuration output.
Florian Pose <fp@igh-essen.com>
parents:
1172
diff
changeset
|
203 |
<< ", " << dec << setfill(' ') |
3b4e82d9904b
Don't show Pdo (entry) names in configuration output.
Florian Pose <fp@igh-essen.com>
parents:
1172
diff
changeset
|
204 |
<< setw(2) << (unsigned int) entry.bit_length |
3b4e82d9904b
Don't show Pdo (entry) names in configuration output.
Florian Pose <fp@igh-essen.com>
parents:
1172
diff
changeset
|
205 |
<< " bit" << endl; |
1142 | 206 |
} |
207 |
} |
|
208 |
} |
|
209 |
} |
|
210 |
||
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1254
diff
changeset
|
211 |
cout << "SDO configuration:" << endl; |
1142 | 212 |
if (configIter->sdo_count) { |
213 |
for (j = 0; j < configIter->sdo_count; j++) { |
|
214 |
m.getConfigSdo(&sdo, configIter->config_index, j); |
|
215 |
||
216 |
cout << " 0x" |
|
217 |
<< hex << setfill('0') |
|
218 |
<< setw(4) << sdo.index << ":" |
|
219 |
<< setw(2) << (unsigned int) sdo.subindex |
|
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
220 |
<< ", " << dec << sdo.size << " byte" << endl; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
221 |
|
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
222 |
cout << " " << hex; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
223 |
for (i = 0; i < min((uint32_t) sdo.size, |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
224 |
(uint32_t) EC_MAX_SDO_DATA_SIZE); i++) { |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
225 |
cout << setw(2) << (unsigned int) sdo.data[i]; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
226 |
if ((i + 1) % 16 == 0 && i < sdo.size - 1) { |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
227 |
cout << endl << " "; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
228 |
} else { |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
229 |
cout << " "; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
230 |
} |
1142 | 231 |
} |
232 |
||
233 |
cout << endl; |
|
1526
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
234 |
if (sdo.size > EC_MAX_SDO_DATA_SIZE) { |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
235 |
cout << " ..." << endl; |
66edd310830c
Implemented CompleteAccess for SDO downloads.
Florian Pose <fp@igh-essen.com>
parents:
1519
diff
changeset
|
236 |
} |
1142 | 237 |
} |
238 |
} else { |
|
239 |
cout << " None." << endl; |
|
240 |
} |
|
241 |
||
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
242 |
if (configIter->dc_assign_activate) { |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
243 |
int i; |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
244 |
|
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
245 |
cout << "DC configuration:" << endl |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
246 |
<< " AssignActivate: 0x" << hex << setfill('0') |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
247 |
<< setw(4) << configIter->dc_assign_activate << endl; |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
248 |
|
1456
bd1f69a429f3
Fixed output of 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1455
diff
changeset
|
249 |
cout << " Cycle [ns] Shift [ns]" << endl; |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
250 |
for (i = 0; i < EC_SYNC_SIGNAL_COUNT; i++) { |
1456
bd1f69a429f3
Fixed output of 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1455
diff
changeset
|
251 |
cout << " SYNC" << dec << i << " " |
bd1f69a429f3
Fixed output of 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1455
diff
changeset
|
252 |
<< setfill(' ') << right |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
253 |
<< setw(11) << configIter->dc_sync[i].cycle_time |
1456
bd1f69a429f3
Fixed output of 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1455
diff
changeset
|
254 |
<< " " |
1455
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
255 |
<< setw(11) << configIter->dc_sync[i].shift_time |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
256 |
<< endl; |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
257 |
} |
aa18fcfe0fd1
Output DC config in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1373
diff
changeset
|
258 |
} |
1142 | 259 |
cout << endl; |
260 |
} |
|
261 |
} |
|
262 |
||
263 |
/*****************************************************************************/ |
|
264 |
||
265 |
/** Lists the bus configuration. |
|
266 |
*/ |
|
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
267 |
void CommandConfig::listConfigs( |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
268 |
MasterDevice &m, |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
269 |
const ConfigList &configList |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
270 |
) |
1142 | 271 |
{ |
272 |
ConfigList::const_iterator configIter; |
|
273 |
stringstream str; |
|
274 |
Info info; |
|
275 |
typedef list<Info> InfoList; |
|
276 |
InfoList list; |
|
277 |
InfoList::const_iterator iter; |
|
278 |
unsigned int maxAliasWidth = 0, maxPosWidth = 0, |
|
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
279 |
maxSlavePosWidth = 0, maxStateWidth = 0; |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
280 |
ec_ioctl_slave_t slave; |
1142 | 281 |
|
282 |
for (configIter = configList.begin(); |
|
283 |
configIter != configList.end(); |
|
284 |
configIter++) { |
|
285 |
||
286 |
str << dec << configIter->alias; |
|
287 |
info.alias = str.str(); |
|
288 |
str.clear(); |
|
289 |
str.str(""); |
|
290 |
||
291 |
str << configIter->position; |
|
292 |
info.pos = str.str(); |
|
293 |
str.clear(); |
|
294 |
str.str(""); |
|
295 |
||
296 |
str << hex << setfill('0') |
|
297 |
<< "0x" << setw(8) << configIter->vendor_id |
|
298 |
<< "/0x" << setw(8) << configIter->product_code; |
|
299 |
info.ident = str.str(); |
|
300 |
str.clear(); |
|
301 |
str.str(""); |
|
302 |
||
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
303 |
if (configIter->slave_position != -1) { |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
304 |
m.getSlave(&slave, configIter->slave_position); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
305 |
|
1172
74ee632c3b5e
Fixed attached slave position in 'ethercat config' -> decimal.
Florian Pose <fp@igh-essen.com>
parents:
1167
diff
changeset
|
306 |
str << dec << configIter->slave_position; |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
307 |
info.slavePos = str.str(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
308 |
str.clear(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
309 |
str.str(""); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
310 |
|
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1147
diff
changeset
|
311 |
str << alStateString(slave.al_state); |
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
312 |
info.state = str.str(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
313 |
str.clear(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
314 |
str.str(""); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
315 |
} else { |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
316 |
str << "-"; |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
317 |
info.slavePos = str.str(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
318 |
str.clear(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
319 |
str.str(""); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
320 |
|
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
321 |
str << "-"; |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
322 |
info.state = str.str(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
323 |
str.clear(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
324 |
str.str(""); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
325 |
} |
1142 | 326 |
|
327 |
list.push_back(info); |
|
328 |
||
329 |
if (info.alias.length() > maxAliasWidth) |
|
330 |
maxAliasWidth = info.alias.length(); |
|
331 |
if (info.pos.length() > maxPosWidth) |
|
332 |
maxPosWidth = info.pos.length(); |
|
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
333 |
if (info.slavePos.length() > maxSlavePosWidth) |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
334 |
maxSlavePosWidth = info.slavePos.length(); |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
335 |
if (info.state.length() > maxStateWidth) |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
336 |
maxStateWidth = info.state.length(); |
1142 | 337 |
} |
338 |
||
339 |
for (iter = list.begin(); iter != list.end(); iter++) { |
|
340 |
cout << setfill(' ') << right |
|
341 |
<< setw(maxAliasWidth) << iter->alias |
|
342 |
<< ":" << left |
|
343 |
<< setw(maxPosWidth) << iter->pos |
|
344 |
<< " " |
|
345 |
<< iter->ident |
|
346 |
<< " " |
|
1147
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
347 |
<< setw(maxSlavePosWidth) << iter->slavePos << " " |
0eac1ee8512a
Show attached slave position and state in 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
348 |
<< setw(maxStateWidth) << iter->state << " " |
1142 | 349 |
<< endl; |
350 |
} |
|
351 |
} |
|
352 |
||
353 |
/*****************************************************************************/ |