author | Florian Pose <fp@igh-essen.com> |
Thu, 24 Jul 2008 07:40:45 +0000 | |
changeset 1139 | 074caa25365e |
parent 1137 | a73c0f54be42 |
permissions | -rw-r--r-- |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
#include <iostream> |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
#include <iomanip> |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
#include <list> |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
using namespace std; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
#include "globals.h" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
const char *help_slaves = |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
"[OPTIONS]\n" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
"\n" |
1137
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
19 |
"Display slaves on the bus.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
20 |
"\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
21 |
"If the --verbose option is not given, the slaves are displayed\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
22 |
"one-per-line. Example:\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
23 |
"\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
24 |
"1 5555:0 PREOP + EL3162 2C. Ana. Input 0-10V\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
25 |
"| | | | | |\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
26 |
"| | | | | \\- Name from SII if avaliable, otherwise\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
27 |
"| | | | | hexadecimal vendor ID and product code\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
28 |
"| | | | | separated by a colon.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
29 |
"| | | | \\- Error flag. '+' means no error, 'E' means,\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
30 |
"| | | | that scanning or configuration failed.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
31 |
"| | | \\- Current slave state.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
32 |
"| | \\- Relative position (decimal) after the last slave with an\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
33 |
"| | alias address set.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
34 |
"| \\- Alias address of the slave (if set to non-zero), or the alias\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
35 |
"| of the last slave with an alias set, or zero if there is none.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
36 |
"\\- Ring position (use this with any --slave option).\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
37 |
"\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
38 |
"If the --verbose option is given, a detailed (multi-line) description\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
39 |
"is output for each slave.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
40 |
"\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
41 |
"Command-specific options:\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
42 |
" --slave -s <index> Positive numerical ring position, or 'all' for\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
43 |
" all slaves (default).\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
44 |
" --verbose -v Show detailed slave information.\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
45 |
"\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
46 |
"Numerical values can be specified either with decimal (no prefix),\n" |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
47 |
"octal (prefix '0') or hexadecimal (prefix '0x') base.\n"; |
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
48 |
|
a73c0f54be42
Added command-line help for every ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
1130
diff
changeset
|
49 |
/****************************************************************************/ |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
void listSlaves(int); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
void showSlave(uint16_t); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
void command_slaves() |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
masterDev.open(MasterDevice::Read); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
if (verbosity == Verbose) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
if (slavePosition == -1) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
unsigned int numSlaves = masterDev.slaveCount(), i; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
for (i = 0; i < numSlaves; i++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
showSlave(i); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
} else { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
showSlave(slavePosition); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
} else { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
listSlaves(slavePosition); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
string slaveState(uint8_t state) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
switch (state) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
case 1: return "INIT"; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
case 2: return "PREOP"; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
case 4: return "SAFEOP"; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
case 8: return "OP"; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
default: return "???"; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
struct SlaveInfo { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
string pos; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
string alias; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
string relPos; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
string state; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
string flag; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
string name; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
}; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
void listSlaves(int slavePosition) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
unsigned int numSlaves, i; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
ec_ioctl_slave_t slave; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
uint16_t lastAlias, aliasIndex; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
SlaveInfo slaveInfo; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
typedef list<SlaveInfo> SlaveInfoList; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
SlaveInfoList slaveInfoList; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
SlaveInfoList::const_iterator iter; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
stringstream str; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
unsigned int maxPosWidth = 0, maxAliasWidth = 0, |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
maxRelPosWidth = 0, maxStateWidth = 0; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
numSlaves = masterDev.slaveCount(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
lastAlias = 0; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
aliasIndex = 0; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
for (i = 0; i < numSlaves; i++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
masterDev.getSlave(&slave, i); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
if (slave.alias) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
lastAlias = slave.alias; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
aliasIndex = 0; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
if (slavePosition == -1 || i == (unsigned int) slavePosition) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
str << dec << i; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
slaveInfo.pos = str.str(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
str.clear(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
str.str(""); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
str << lastAlias; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
slaveInfo.alias = str.str(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
str.str(""); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
str << aliasIndex; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
slaveInfo.relPos = str.str(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
str.str(""); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
slaveInfo.state = slaveState(slave.state); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
slaveInfo.flag = (slave.error_flag ? 'E' : '+'); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
if (strlen(slave.name)) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
slaveInfo.name = slave.name; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
} else { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
str << "0x" << hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
<< setw(8) << slave.vendor_id << ":0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
<< setw(8) << slave.product_code; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
slaveInfo.name = str.str(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
str.str(""); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
slaveInfoList.push_back(slaveInfo); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
if (slaveInfo.pos.length() > maxPosWidth) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
maxPosWidth = slaveInfo.pos.length(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
if (slaveInfo.alias.length() > maxAliasWidth) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
maxAliasWidth = slaveInfo.alias.length(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
if (slaveInfo.relPos.length() > maxRelPosWidth) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
maxRelPosWidth = slaveInfo.relPos.length(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
if (slaveInfo.state.length() > maxStateWidth) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
maxStateWidth = slaveInfo.state.length(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
aliasIndex++; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
for (iter = slaveInfoList.begin(); iter != slaveInfoList.end(); iter++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
cout << setfill(' ') << right |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
<< setw(maxPosWidth) << iter->pos << " " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
<< setw(maxAliasWidth) << iter->alias |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
<< ":" << left |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
<< setw(maxRelPosWidth) << iter->relPos << " " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
<< setw(maxStateWidth) << iter->state << " " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
<< iter->flag << " " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
<< iter->name << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
void showSlave(uint16_t slavePosition) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
ec_ioctl_slave_t slave; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
list<string> protoList; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
list<string>::const_iterator protoIter; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
masterDev.getSlave(&slave, slavePosition); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
cout << "=== Slave " << dec << slavePosition << " ===" << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
if (slave.alias) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
cout << "Alias: " << slave.alias << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
cout |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
<< "State: " << slaveState(slave.state) << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
<< "Flag: " << (slave.error_flag ? 'E' : '+') << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
<< "Identity:" << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
<< " Vendor Id: 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
<< hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
<< setw(8) << slave.vendor_id << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
<< " Product code: 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
<< setw(8) << slave.product_code << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
<< " Revision number: 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
<< setw(8) << slave.revision_number << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
<< " Serial number: 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
<< setw(8) << slave.serial_number << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
if (slave.mailbox_protocols) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
cout << "Mailboxes:" << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
<< " RX: 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
<< hex << setw(4) << slave.rx_mailbox_offset << "/" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
<< dec << slave.rx_mailbox_size |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
<< ", TX: 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
<< hex << setw(4) << slave.tx_mailbox_offset << "/" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
<< dec << slave.tx_mailbox_size << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
<< " Supported protocols: "; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
if (slave.mailbox_protocols & EC_MBOX_AOE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
protoList.push_back("AoE"); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
if (slave.mailbox_protocols & EC_MBOX_EOE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
protoList.push_back("EoE"); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
if (slave.mailbox_protocols & EC_MBOX_COE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
protoList.push_back("CoE"); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
if (slave.mailbox_protocols & EC_MBOX_FOE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
protoList.push_back("FoE"); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
if (slave.mailbox_protocols & EC_MBOX_SOE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
protoList.push_back("SoE"); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
if (slave.mailbox_protocols & EC_MBOX_VOE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
protoList.push_back("VoE"); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
for (protoIter = protoList.begin(); protoIter != protoList.end(); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
protoIter++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
if (protoIter != protoList.begin()) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
cout << ", "; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
cout << *protoIter; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
cout << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
if (slave.has_general_category) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
cout << "General:" << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
<< " Group: " << slave.group << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
<< " Image name: " << slave.image << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
<< " Order number: " << slave.order << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
<< " Device name: " << slave.name << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
if (slave.mailbox_protocols & EC_MBOX_COE) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
cout << " CoE details:" << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
<< " Enable Sdo: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
<< (slave.coe_details.enable_sdo ? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
<< " Enable Sdo Info: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
<< (slave.coe_details.enable_sdo_info ? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
<< " Enable Pdo Assign: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
<< (slave.coe_details.enable_pdo_assign |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
<< " Enable Pdo Configuration: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
<< (slave.coe_details.enable_pdo_configuration |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
<< " Enable Upload at startup: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
<< (slave.coe_details.enable_upload_at_startup |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
<< " Enable Sdo complete access: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
<< (slave.coe_details.enable_sdo_complete_access |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
? "yes" : "no") << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
cout << " Flags:" << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
<< " Enable SafeOp: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
<< (slave.general_flags.enable_safeop ? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
<< " Enable notLRW: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
<< (slave.general_flags.enable_not_lrw ? "yes" : "no") << endl |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
<< " Current consumption: " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
<< dec << slave.current_on_ebus << " mA" << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
/*****************************************************************************/ |