author | Florian Pose <fp@igh-essen.com> |
Mon, 28 Jul 2008 14:03:45 +0000 | |
changeset 1164 | bc6a17d40275 |
parent 1157 | 04d1c950cf9d |
child 1184 | 75cd6681eb08 |
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 |
#include "coe_datatypes.h" |
|
13 |
||
14 |
/*****************************************************************************/ |
|
15 |
||
16 |
CommandSdos::CommandSdos(): |
|
17 |
Command("sdos", "List Sdo dictionaries.") |
|
18 |
{ |
|
19 |
} |
|
20 |
||
21 |
/*****************************************************************************/ |
|
22 |
||
23 |
string CommandSdos::helpString() const |
|
24 |
{ |
|
25 |
stringstream str; |
|
26 |
||
27 |
str << getName() << " [OPTIONS]" << endl |
|
28 |
<< endl |
|
29 |
<< getBriefDescription() << endl |
|
30 |
<< endl |
|
31 |
<< "Sdo dictionary information is displayed in two layers," << endl |
|
32 |
<< "which are indented accordingly:" << endl |
|
33 |
<< endl |
|
34 |
<< "1) Sdos - Hexadecimal Sdo index and the name. Example:" << endl |
|
35 |
<< endl |
|
36 |
<< " Sdo 0x1018, \"Identity object\"" << endl |
|
37 |
<< endl |
|
38 |
<< "2) Sdo entries - Sdo index and Sdo entry subindex (both" << endl |
|
39 |
<< " hexadecimal) followed by the data type, the length in" << endl |
|
40 |
<< " bit, and the description. Example:" << endl |
|
41 |
<< endl |
|
42 |
<< " 0x1018:01, uint32, 32 bit, \"Vendor id\"" << endl |
|
43 |
<< endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
44 |
<< "If the --quiet option is given, only the Sdos are output." |
1142 | 45 |
<< endl << endl |
46 |
<< "Command-specific options:" << endl |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
47 |
<< " --alias -a <alias>" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
48 |
<< " --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
|
49 |
<< " the 'slaves' command." << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
50 |
<< " --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
|
51 |
<< " Sdo entries)." << endl |
1142 | 52 |
<< endl |
53 |
<< numericInfo(); |
|
54 |
||
55 |
return str.str(); |
|
56 |
} |
|
57 |
||
58 |
/****************************************************************************/ |
|
59 |
||
60 |
void CommandSdos::execute(MasterDevice &m, const StringVector &args) |
|
61 |
{ |
|
1151 | 62 |
SlaveList slaves; |
63 |
SlaveList::const_iterator si; |
|
64 |
bool showHeader; |
|
65 |
||
1142 | 66 |
m.open(MasterDevice::Read); |
1151 | 67 |
slaves = selectedSlaves(m); |
68 |
showHeader = slaves.size() > 1; |
|
1142 | 69 |
|
1151 | 70 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
71 |
listSlaveSdos(m, *si, showHeader); |
|
1142 | 72 |
} |
73 |
} |
|
74 |
||
75 |
/****************************************************************************/ |
|
76 |
||
77 |
void CommandSdos::listSlaveSdos( |
|
78 |
MasterDevice &m, |
|
1151 | 79 |
const ec_ioctl_slave_t &slave, |
80 |
bool showHeader |
|
1142 | 81 |
) |
82 |
{ |
|
83 |
ec_ioctl_slave_sdo_t sdo; |
|
84 |
ec_ioctl_slave_sdo_entry_t entry; |
|
85 |
unsigned int i, j; |
|
86 |
const CoEDataType *d; |
|
87 |
||
1151 | 88 |
if (showHeader) |
89 |
cout << "=== Slave " << slave.position << " ===" << endl; |
|
1142 | 90 |
|
91 |
for (i = 0; i < slave.sdo_count; i++) { |
|
1151 | 92 |
m.getSdo(&sdo, slave.position, i); |
1142 | 93 |
|
94 |
cout << "Sdo 0x" |
|
95 |
<< hex << setfill('0') |
|
96 |
<< setw(4) << sdo.sdo_index |
|
97 |
<< ", \"" << sdo.name << "\"" << endl; |
|
98 |
||
99 |
if (getVerbosity() == Quiet) |
|
100 |
continue; |
|
101 |
||
102 |
for (j = 0; j <= sdo.max_subindex; j++) { |
|
1151 | 103 |
m.getSdoEntry(&entry, slave.position, -i, j); |
1142 | 104 |
|
105 |
cout << " 0x" << hex << setfill('0') |
|
106 |
<< setw(4) << sdo.sdo_index << ":" |
|
107 |
<< setw(2) << (unsigned int) entry.sdo_entry_subindex |
|
108 |
<< ", "; |
|
109 |
||
110 |
if ((d = findDataType(entry.data_type))) { |
|
111 |
cout << d->name; |
|
112 |
} else { |
|
113 |
cout << "type " << setw(4) << entry.data_type; |
|
114 |
} |
|
115 |
||
116 |
cout << ", " << dec << entry.bit_length << " bit, \"" |
|
117 |
<< entry.description << "\"" << endl; |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
/*****************************************************************************/ |