31 << getBriefDescription() << endl |
31 << getBriefDescription() << endl |
32 << endl |
32 << endl |
33 << "Without the --verbose option, slave configurations are" << endl |
33 << "Without the --verbose option, slave configurations are" << endl |
34 << "output one-per-line. Example:" << endl |
34 << "output one-per-line. Example:" << endl |
35 << endl |
35 << endl |
36 << "1001:0 0x0000003b/0x02010000 - -" << endl |
36 << "1001:0 0x0000003b/0x02010000 3 OP" << endl |
37 << "| | | |" << endl |
37 << "| | | |" << endl |
38 << "| | | \\- Slave is operational." |
38 << "| | | \\- Application-layer" << endl |
39 << endl |
39 << "| | | state of the attached" << endl |
40 << "| | \\- Slave has been found." << endl |
40 << "| | | slave, or '-', if no" << endl |
|
41 << "| | | slave is attached." << endl |
|
42 << "| | \\- Absolute decimal ring" << endl |
|
43 << "| | position of the attached" << endl |
|
44 << "| | slave, or '-' if none" << endl |
|
45 << "| | attached." << endl |
41 << "| \\- Vendor ID and product code (both" << endl |
46 << "| \\- Vendor ID and product code (both" << endl |
42 << "| hexadecimal)." << endl |
47 << "| hexadecimal)." << endl |
43 << "\\- Alias and relative position (both decimal)." << endl |
48 << "\\- Alias and relative position (both decimal)." << endl |
44 << endl |
49 << endl |
45 << "With the --verbose option given, the configured Pdos and" << endl |
50 << "With the --verbose option given, the configured Pdos and" << endl |
84 configList.sort(); |
89 configList.sort(); |
85 |
90 |
86 if (getVerbosity() == Verbose) { |
91 if (getVerbosity() == Verbose) { |
87 showDetailedConfigs(m, configList); |
92 showDetailedConfigs(m, configList); |
88 } else { |
93 } else { |
89 listConfigs(configList); |
94 listConfigs(m, configList); |
90 } |
95 } |
91 } |
96 } |
92 |
97 |
93 /*****************************************************************************/ |
98 /*****************************************************************************/ |
94 |
99 |
99 const ConfigList &configList |
104 const ConfigList &configList |
100 ) |
105 ) |
101 { |
106 { |
102 ConfigList::const_iterator configIter; |
107 ConfigList::const_iterator configIter; |
103 unsigned int j, k, l; |
108 unsigned int j, k, l; |
|
109 ec_ioctl_slave_t slave; |
104 ec_ioctl_config_pdo_t pdo; |
110 ec_ioctl_config_pdo_t pdo; |
105 ec_ioctl_config_pdo_entry_t entry; |
111 ec_ioctl_config_pdo_entry_t entry; |
106 ec_ioctl_config_sdo_t sdo; |
112 ec_ioctl_config_sdo_t sdo; |
107 |
113 |
108 for (configIter = configList.begin(); |
114 for (configIter = configList.begin(); |
115 << "Vendor Id: 0x" |
121 << "Vendor Id: 0x" |
116 << hex << setfill('0') |
122 << hex << setfill('0') |
117 << setw(8) << configIter->vendor_id << endl |
123 << setw(8) << configIter->vendor_id << endl |
118 << "Product code: 0x" |
124 << "Product code: 0x" |
119 << setw(8) << configIter->product_code << endl |
125 << setw(8) << configIter->product_code << endl |
120 << "Attached: " << (configIter->attached ? "yes" : "no") << endl |
126 << "Attached slave: "; |
121 << "Operational: " << (configIter->operational ? "yes" : "no") << endl; |
127 |
|
128 if (configIter->slave_position != -1) { |
|
129 m.getSlave(&slave, configIter->slave_position); |
|
130 cout << configIter->slave_position |
|
131 << " (" << alStateString(slave.state) << ")" << endl; |
|
132 } else { |
|
133 cout << "none" << endl; |
|
134 } |
122 |
135 |
123 for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) { |
136 for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) { |
124 if (configIter->syncs[j].pdo_count) { |
137 if (configIter->syncs[j].pdo_count) { |
125 cout << "SM" << dec << j << " (" |
138 cout << "SM" << dec << j << " (" |
126 << (configIter->syncs[j].dir == EC_DIR_INPUT |
139 << (configIter->syncs[j].dir == EC_DIR_INPUT |
186 |
199 |
187 /*****************************************************************************/ |
200 /*****************************************************************************/ |
188 |
201 |
189 /** Lists the bus configuration. |
202 /** Lists the bus configuration. |
190 */ |
203 */ |
191 void CommandConfig::listConfigs(const ConfigList &configList) |
204 void CommandConfig::listConfigs( |
|
205 MasterDevice &m, |
|
206 const ConfigList &configList |
|
207 ) |
192 { |
208 { |
193 ConfigList::const_iterator configIter; |
209 ConfigList::const_iterator configIter; |
194 stringstream str; |
210 stringstream str; |
195 Info info; |
211 Info info; |
196 typedef list<Info> InfoList; |
212 typedef list<Info> InfoList; |
197 InfoList list; |
213 InfoList list; |
198 InfoList::const_iterator iter; |
214 InfoList::const_iterator iter; |
199 unsigned int maxAliasWidth = 0, maxPosWidth = 0, |
215 unsigned int maxAliasWidth = 0, maxPosWidth = 0, |
200 maxAttWidth = 0, maxOpWidth = 0; |
216 maxSlavePosWidth = 0, maxStateWidth = 0; |
|
217 ec_ioctl_slave_t slave; |
201 |
218 |
202 for (configIter = configList.begin(); |
219 for (configIter = configList.begin(); |
203 configIter != configList.end(); |
220 configIter != configList.end(); |
204 configIter++) { |
221 configIter++) { |
205 |
222 |
218 << "/0x" << setw(8) << configIter->product_code; |
235 << "/0x" << setw(8) << configIter->product_code; |
219 info.ident = str.str(); |
236 info.ident = str.str(); |
220 str.clear(); |
237 str.clear(); |
221 str.str(""); |
238 str.str(""); |
222 |
239 |
223 str << (configIter->attached ? "attached" : "-"); |
240 if (configIter->slave_position != -1) { |
224 info.att = str.str(); |
241 m.getSlave(&slave, configIter->slave_position); |
225 str.clear(); |
242 |
226 str.str(""); |
243 str << configIter->slave_position; |
227 |
244 info.slavePos = str.str(); |
228 str << (configIter->operational ? "operational" : "-"); |
245 str.clear(); |
229 info.op = str.str(); |
246 str.str(""); |
230 str.clear(); |
247 |
231 str.str(""); |
248 str << alStateString(slave.state); |
|
249 info.state = str.str(); |
|
250 str.clear(); |
|
251 str.str(""); |
|
252 } else { |
|
253 str << "-"; |
|
254 info.slavePos = str.str(); |
|
255 str.clear(); |
|
256 str.str(""); |
|
257 |
|
258 str << "-"; |
|
259 info.state = str.str(); |
|
260 str.clear(); |
|
261 str.str(""); |
|
262 } |
232 |
263 |
233 list.push_back(info); |
264 list.push_back(info); |
234 |
265 |
235 if (info.alias.length() > maxAliasWidth) |
266 if (info.alias.length() > maxAliasWidth) |
236 maxAliasWidth = info.alias.length(); |
267 maxAliasWidth = info.alias.length(); |
237 if (info.pos.length() > maxPosWidth) |
268 if (info.pos.length() > maxPosWidth) |
238 maxPosWidth = info.pos.length(); |
269 maxPosWidth = info.pos.length(); |
239 if (info.att.length() > maxAttWidth) |
270 if (info.slavePos.length() > maxSlavePosWidth) |
240 maxAttWidth = info.att.length(); |
271 maxSlavePosWidth = info.slavePos.length(); |
241 if (info.op.length() > maxOpWidth) |
272 if (info.state.length() > maxStateWidth) |
242 maxOpWidth = info.op.length(); |
273 maxStateWidth = info.state.length(); |
243 } |
274 } |
244 |
275 |
245 for (iter = list.begin(); iter != list.end(); iter++) { |
276 for (iter = list.begin(); iter != list.end(); iter++) { |
246 cout << setfill(' ') << right |
277 cout << setfill(' ') << right |
247 << setw(maxAliasWidth) << iter->alias |
278 << setw(maxAliasWidth) << iter->alias |
248 << ":" << left |
279 << ":" << left |
249 << setw(maxPosWidth) << iter->pos |
280 << setw(maxPosWidth) << iter->pos |
250 << " " |
281 << " " |
251 << iter->ident |
282 << iter->ident |
252 << " " |
283 << " " |
253 << setw(maxAttWidth) << iter->att << " " |
284 << setw(maxSlavePosWidth) << iter->slavePos << " " |
254 << setw(maxOpWidth) << iter->op << " " |
285 << setw(maxStateWidth) << iter->state << " " |
255 << endl; |
286 << endl; |
256 } |
287 } |
257 } |
288 } |
258 |
289 |
259 /*****************************************************************************/ |
290 /*****************************************************************************/ |