author | Florian Pose <fp@igh-essen.com> |
Thu, 02 Oct 2008 13:40:23 +0000 | |
changeset 1247 | 5f1f1a3e6636 |
parent 1184 | 75cd6681eb08 |
child 1327 | 4d179b06dd3c |
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(): |
|
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
|
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 |
|
30 |
<< "Sdo dictionary information is displayed in two layers," << endl |
|
31 |
<< "which are indented accordingly:" << endl |
|
32 |
<< endl |
|
33 |
<< "1) Sdos - Hexadecimal Sdo index and the name. Example:" << endl |
|
34 |
<< endl |
|
35 |
<< " Sdo 0x1018, \"Identity object\"" << endl |
|
36 |
<< endl |
|
37 |
<< "2) Sdo entries - Sdo index and Sdo entry subindex (both" << endl |
|
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 |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
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 |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
49 |
<< " --quiet -q Only output Sdos (without the" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
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 |
|
93 |
cout << "Sdo 0x" |
|
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 |
/*****************************************************************************/ |