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