author | Florian Pose <fp@igh-essen.com> |
Wed, 22 Oct 2008 10:35:41 +0000 | |
changeset 1296 | 69582b88e8fd |
parent 1167 | 9e0ebb38e301 |
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 "CommandDomains.h" |
|
12 |
||
13 |
/*****************************************************************************/ |
|
14 |
||
15 |
CommandDomains::CommandDomains(): |
|
16 |
Command("domains", "Show configured domains.") |
|
17 |
{ |
|
18 |
} |
|
19 |
||
20 |
/*****************************************************************************/ |
|
21 |
||
22 |
string CommandDomains::helpString() const |
|
23 |
{ |
|
24 |
stringstream str; |
|
25 |
||
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
26 |
str << getName() << " [OPTIONS]" << endl |
1142 | 27 |
<< endl |
28 |
<< getBriefDescription() << endl |
|
29 |
<< endl |
|
30 |
<< "Without the --verbose option, the domains are displayed" << endl |
|
31 |
<< "one-per-line. Example:" << endl |
|
32 |
<< endl |
|
33 |
<< "Domain0: LogBaseAddr 0x00000000, Size 6, WorkingCounter 0/1" |
|
34 |
<< endl << endl |
|
35 |
<< "The domain's base address for the logical datagram" << endl |
|
36 |
<< "(LRD/LWR/LRW) is displayed followed by the domain's" << endl |
|
37 |
<< "process data size in byte. The last values are the current" << endl |
|
38 |
<< "datagram working counter sum and the expected working" << endl |
|
1167 | 39 |
<< "counter sum. If the values are equal, all Pdos were" << endl |
40 |
<< "exchanged during the last cycle." << endl |
|
41 |
<< endl |
|
1142 | 42 |
<< "If the --verbose option is given, the participating slave" << endl |
43 |
<< "configurations/FMMUs and the current process data are" << endl |
|
44 |
<< "additionally displayed:" << endl |
|
45 |
<< endl |
|
46 |
<< "Domain1: LogBaseAddr 0x00000006, Size 6, WorkingCounter 0/1" |
|
47 |
<< endl |
|
48 |
<< " SlaveConfig 1001:0, SM3 ( Input), LogAddr 0x00000006, Size 6" |
|
49 |
<< endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
50 |
<< " 0x00 0x00 0x00 0x00 0x00 0x00" << endl |
1142 | 51 |
<< endl |
52 |
<< "The process data are displayed as hexadecimal bytes." << endl |
|
53 |
<< endl |
|
54 |
<< "Command-specific options:" << endl |
|
1167 | 55 |
<< " --domain -d <index> Positive numerical domain index." << endl |
56 |
<< " If ommitted, all domains are" << endl |
|
57 |
<< " displayed." << endl |
|
1142 | 58 |
<< endl |
59 |
<< " --verbose -v Show FMMUs and process data" << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
60 |
<< " in addition." << endl |
1142 | 61 |
<< endl |
62 |
<< numericInfo(); |
|
63 |
||
64 |
return str.str(); |
|
65 |
} |
|
66 |
||
67 |
/****************************************************************************/ |
|
68 |
||
69 |
void CommandDomains::execute(MasterDevice &m, const StringVector &args) |
|
70 |
{ |
|
1166 | 71 |
DomainList domains; |
72 |
DomainList::const_iterator di; |
|
73 |
||
1142 | 74 |
m.open(MasterDevice::Read); |
1166 | 75 |
domains = selectedDomains(m); |
1142 | 76 |
|
1166 | 77 |
for (di = domains.begin(); di != domains.end(); di++) { |
78 |
showDomain(m, *di); |
|
79 |
} |
|
1142 | 80 |
} |
81 |
||
82 |
/****************************************************************************/ |
|
83 |
||
1166 | 84 |
void CommandDomains::showDomain( |
85 |
MasterDevice &m, |
|
86 |
const ec_ioctl_domain_t &domain |
|
87 |
) |
|
1142 | 88 |
{ |
89 |
unsigned char *processData; |
|
90 |
ec_ioctl_domain_data_t data; |
|
91 |
unsigned int i, j; |
|
92 |
ec_ioctl_domain_fmmu_t fmmu; |
|
93 |
unsigned int dataOffset; |
|
94 |
||
1166 | 95 |
cout << "Domain" << dec << domain.index << ":" |
1142 | 96 |
<< " LogBaseAddr 0x" |
97 |
<< hex << setfill('0') |
|
98 |
<< setw(8) << domain.logical_base_address |
|
99 |
<< ", Size " << dec << setfill(' ') |
|
100 |
<< setw(3) << domain.data_size |
|
101 |
<< ", WorkingCounter " |
|
102 |
<< domain.working_counter << "/" |
|
103 |
<< domain.expected_working_counter << endl; |
|
104 |
||
105 |
if (!domain.data_size || getVerbosity() != Verbose) |
|
106 |
return; |
|
107 |
||
108 |
processData = new unsigned char[domain.data_size]; |
|
109 |
||
110 |
try { |
|
1166 | 111 |
m.getData(&data, domain.index, domain.data_size, processData); |
1142 | 112 |
} catch (MasterDeviceException &e) { |
113 |
delete [] processData; |
|
114 |
throw e; |
|
115 |
} |
|
116 |
||
117 |
for (i = 0; i < domain.fmmu_count; i++) { |
|
1166 | 118 |
m.getFmmu(&fmmu, domain.index, i); |
1142 | 119 |
|
120 |
cout << " SlaveConfig " |
|
121 |
<< dec << fmmu.slave_config_alias |
|
122 |
<< ":" << fmmu.slave_config_position |
|
123 |
<< ", SM" << (unsigned int) fmmu.sync_index << " (" |
|
124 |
<< setfill(' ') << setw(6) |
|
125 |
<< (fmmu.dir == EC_DIR_INPUT ? "Input" : "Output") |
|
126 |
<< "), LogAddr 0x" |
|
127 |
<< hex << setfill('0') |
|
128 |
<< setw(8) << fmmu.logical_address |
|
129 |
<< ", Size " << dec << fmmu.data_size << endl; |
|
130 |
||
131 |
dataOffset = fmmu.logical_address - domain.logical_base_address; |
|
132 |
if (dataOffset + fmmu.data_size > domain.data_size) { |
|
133 |
stringstream err; |
|
134 |
delete [] processData; |
|
135 |
err << "Fmmu information corrupted!"; |
|
136 |
throwCommandException(err); |
|
137 |
} |
|
138 |
||
139 |
cout << " " << hex << setfill('0'); |
|
140 |
for (j = 0; j < fmmu.data_size; j++) { |
|
141 |
if (j && !(j % BreakAfterBytes)) |
|
142 |
cout << endl << " "; |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
143 |
cout << "0x" << setw(2) |
1142 | 144 |
<< (unsigned int) *(processData + dataOffset + j) << " "; |
145 |
} |
|
146 |
cout << endl; |
|
147 |
} |
|
148 |
||
149 |
delete [] processData; |
|
150 |
} |
|
151 |
||
152 |
/*****************************************************************************/ |