author | Florian Pose <fp@igh-essen.com> |
Wed, 18 Feb 2009 13:47:08 +0000 | |
changeset 1355 | df9be2b80b9a |
parent 1327 | 4d179b06dd3c |
child 1363 | 11c0b2caa253 |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
****************************************************************************/ |
|
6 |
||
7 |
#include <iostream> |
|
8 |
#include <iomanip> |
|
9 |
using namespace std; |
|
10 |
||
11 |
#include "CommandSdos.h" |
|
12 |
||
13 |
/*****************************************************************************/ |
|
14 |
||
15 |
CommandSdos::CommandSdos(): |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
16 |
SdoCommand("sdos", "List SDO dictionaries.") |
1142 | 17 |
{ |
18 |
} |
|
19 |
||
20 |
/*****************************************************************************/ |
|
21 |
||
22 |
string CommandSdos::helpString() const |
|
23 |
{ |
|
24 |
stringstream str; |
|
25 |
||
26 |
str << getName() << " [OPTIONS]" << endl |
|
27 |
<< endl |
|
28 |
<< getBriefDescription() << endl |
|
29 |
<< endl |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
30 |
<< "SDO dictionary information is displayed in two layers," << endl |
1142 | 31 |
<< "which are indented accordingly:" << endl |
32 |
<< endl |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
33 |
<< "1) SDOs - Hexadecimal SDO index and the name. Example:" << endl |
1142 | 34 |
<< endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
35 |
<< " SDO 0x1018, \"Identity object\"" << endl |
1142 | 36 |
<< endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
37 |
<< "2) SDO entries - SDO index and SDO entry subindex (both" << endl |
1142 | 38 |
<< " hexadecimal) followed by the data type, the length in" << endl |
39 |
<< " bit, and the description. Example:" << endl |
|
40 |
<< endl |
|
41 |
<< " 0x1018:01, uint32, 32 bit, \"Vendor id\"" << endl |
|
42 |
<< endl |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
43 |
<< "If the --quiet option is given, only the SDOs are output." |
1142 | 44 |
<< endl << endl |
45 |
<< "Command-specific options:" << endl |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
46 |
<< " --alias -a <alias>" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
47 |
<< " --position -p <pos> Slave selection. See the help of" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
48 |
<< " the 'slaves' command." << endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
49 |
<< " --quiet -q Only output SDOs (without the" << endl |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
50 |
<< " SDO entries)." << endl |
1142 | 51 |
<< endl |
52 |
<< numericInfo(); |
|
53 |
||
54 |
return str.str(); |
|
55 |
} |
|
56 |
||
57 |
/****************************************************************************/ |
|
58 |
||
59 |
void CommandSdos::execute(MasterDevice &m, const StringVector &args) |
|
60 |
{ |
|
1151 | 61 |
SlaveList slaves; |
62 |
SlaveList::const_iterator si; |
|
63 |
bool showHeader; |
|
64 |
||
1142 | 65 |
m.open(MasterDevice::Read); |
1151 | 66 |
slaves = selectedSlaves(m); |
67 |
showHeader = slaves.size() > 1; |
|
1142 | 68 |
|
1151 | 69 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
70 |
listSlaveSdos(m, *si, showHeader); |
|
1142 | 71 |
} |
72 |
} |
|
73 |
||
74 |
/****************************************************************************/ |
|
75 |
||
76 |
void CommandSdos::listSlaveSdos( |
|
77 |
MasterDevice &m, |
|
1151 | 78 |
const ec_ioctl_slave_t &slave, |
79 |
bool showHeader |
|
1142 | 80 |
) |
81 |
{ |
|
82 |
ec_ioctl_slave_sdo_t sdo; |
|
83 |
ec_ioctl_slave_sdo_entry_t entry; |
|
84 |
unsigned int i, j; |
|
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1157
diff
changeset
|
85 |
const DataType *d; |
1142 | 86 |
|
1151 | 87 |
if (showHeader) |
88 |
cout << "=== Slave " << slave.position << " ===" << endl; |
|
1142 | 89 |
|
90 |
for (i = 0; i < slave.sdo_count; i++) { |
|
1151 | 91 |
m.getSdo(&sdo, slave.position, i); |
1142 | 92 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1184
diff
changeset
|
93 |
cout << "SDO 0x" |
1142 | 94 |
<< hex << setfill('0') |
95 |
<< setw(4) << sdo.sdo_index |
|
96 |
<< ", \"" << sdo.name << "\"" << endl; |
|
97 |
||
98 |
if (getVerbosity() == Quiet) |
|
99 |
continue; |
|
100 |
||
101 |
for (j = 0; j <= sdo.max_subindex; j++) { |
|
1151 | 102 |
m.getSdoEntry(&entry, slave.position, -i, j); |
1142 | 103 |
|
104 |
cout << " 0x" << hex << setfill('0') |
|
105 |
<< setw(4) << sdo.sdo_index << ":" |
|
106 |
<< setw(2) << (unsigned int) entry.sdo_entry_subindex |
|
107 |
<< ", "; |
|
108 |
||
109 |
if ((d = findDataType(entry.data_type))) { |
|
110 |
cout << d->name; |
|
111 |
} else { |
|
112 |
cout << "type " << setw(4) << entry.data_type; |
|
113 |
} |
|
114 |
||
115 |
cout << ", " << dec << entry.bit_length << " bit, \"" |
|
116 |
<< entry.description << "\"" << endl; |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
||
121 |
/*****************************************************************************/ |