1 /***************************************************************************** |
|
2 * |
|
3 * $Id$ |
|
4 * |
|
5 ****************************************************************************/ |
|
6 |
|
7 #include <iostream> |
|
8 #include <iomanip> |
|
9 using namespace std; |
|
10 |
|
11 #include "globals.h" |
|
12 |
|
13 /*****************************************************************************/ |
|
14 |
|
15 const char *help_domains = |
|
16 "[OPTIONS]\n" |
|
17 "\n" |
|
18 "Show information about the application's configured domains.\n" |
|
19 "\n" |
|
20 "Without the --verbose option, the domains are displayed one-per-line.\n" |
|
21 "Example:\n" |
|
22 "\n" |
|
23 "Domain0: LogBaseAddr 0x00000000, Size 6, WorkingCounter 0/1\n" |
|
24 "\n" |
|
25 "The domain's base address for the logical datagram (LRD/LWR/LRW)\n" |
|
26 "is displayed followed by the domain's process data size in byte.\n" |
|
27 "The last values are the current datagram working counter sum and\n" |
|
28 "the expected working counter sum. If the values are equal, all\n" |
|
29 "Pdos are exchanged.\n" |
|
30 "\n" |
|
31 "If the --verbose option is given, the participating slave\n" |
|
32 "configurations/FMMUs and the current process data are additionally\n" |
|
33 "displayed:\n" |
|
34 "\n" |
|
35 "Domain1: LogBaseAddr 0x00000006, Size 6, WorkingCounter 0/1\n" |
|
36 " SlaveConfig 1001:0, SM3 ( Input), LogAddr 0x00000006, Size 6\n" |
|
37 " 00 00 00 00 00 00\n" |
|
38 "\n" |
|
39 "The process data are displayed as hexadecimal bytes.\n" |
|
40 "\n" |
|
41 "Command-specific options:\n" |
|
42 " --domain -d <index> Positive numerical domain index, or 'all'\n" |
|
43 " for all domains (default).\n" |
|
44 " --verbose -v Show FMMUs and process data additionally.\n" |
|
45 "\n" |
|
46 "Numerical values can be specified either with decimal (no prefix),\n" |
|
47 "octal (prefix '0') or hexadecimal (prefix '0x') base.\n"; |
|
48 |
|
49 /****************************************************************************/ |
|
50 |
|
51 void showDomain(unsigned int); |
|
52 |
|
53 /****************************************************************************/ |
|
54 |
|
55 void command_domains(void) |
|
56 { |
|
57 masterDev.open(MasterDevice::Read); |
|
58 |
|
59 if (domainIndex == -1) { |
|
60 unsigned int i; |
|
61 ec_ioctl_master_t master; |
|
62 |
|
63 masterDev.getMaster(&master); |
|
64 |
|
65 for (i = 0; i < master.domain_count; i++) { |
|
66 showDomain(i); |
|
67 } |
|
68 } else { |
|
69 showDomain(domainIndex); |
|
70 } |
|
71 } |
|
72 |
|
73 /****************************************************************************/ |
|
74 |
|
75 void showDomain(unsigned int domainIndex) |
|
76 { |
|
77 ec_ioctl_domain_t domain; |
|
78 unsigned char *processData; |
|
79 ec_ioctl_domain_data_t data; |
|
80 unsigned int i, j; |
|
81 ec_ioctl_domain_fmmu_t fmmu; |
|
82 unsigned int dataOffset; |
|
83 |
|
84 masterDev.getDomain(&domain, domainIndex); |
|
85 |
|
86 cout << "Domain" << dec << domainIndex << ":" |
|
87 << " LogBaseAddr 0x" |
|
88 << hex << setfill('0') |
|
89 << setw(8) << domain.logical_base_address |
|
90 << ", Size " << dec << setfill(' ') |
|
91 << setw(3) << domain.data_size |
|
92 << ", WorkingCounter " |
|
93 << domain.working_counter << "/" |
|
94 << domain.expected_working_counter << endl; |
|
95 |
|
96 if (!domain.data_size || verbosity != Verbose) |
|
97 return; |
|
98 |
|
99 processData = new unsigned char[domain.data_size]; |
|
100 |
|
101 try { |
|
102 masterDev.getData(&data, domainIndex, domain.data_size, processData); |
|
103 } catch (MasterDeviceException &e) { |
|
104 delete [] processData; |
|
105 throw e; |
|
106 } |
|
107 |
|
108 for (i = 0; i < domain.fmmu_count; i++) { |
|
109 masterDev.getFmmu(&fmmu, domainIndex, i); |
|
110 |
|
111 cout << " SlaveConfig " |
|
112 << dec << fmmu.slave_config_alias |
|
113 << ":" << fmmu.slave_config_position |
|
114 << ", SM" << (unsigned int) fmmu.sync_index << " (" |
|
115 << setfill(' ') << setw(6) |
|
116 << (fmmu.dir == EC_DIR_INPUT ? "Input" : "Output") |
|
117 << "), LogAddr 0x" |
|
118 << hex << setfill('0') |
|
119 << setw(8) << fmmu.logical_address |
|
120 << ", Size " << dec << fmmu.data_size << endl; |
|
121 |
|
122 dataOffset = fmmu.logical_address - domain.logical_base_address; |
|
123 if (dataOffset + fmmu.data_size > domain.data_size) { |
|
124 stringstream err; |
|
125 delete [] processData; |
|
126 err << "Fmmu information corrupted!"; |
|
127 throw CommandException(err); |
|
128 } |
|
129 |
|
130 cout << " " << hex << setfill('0'); |
|
131 for (j = 0; j < fmmu.data_size; j++) { |
|
132 if (j && !(j % BreakAfterBytes)) |
|
133 cout << endl << " "; |
|
134 cout << setw(2) |
|
135 << (unsigned int) *(processData + dataOffset + j) << " "; |
|
136 } |
|
137 cout << endl; |
|
138 } |
|
139 |
|
140 delete [] processData; |
|
141 } |
|
142 |
|
143 /*****************************************************************************/ |
|