author | Florian Pose <fp@igh-essen.com> |
Fri, 25 Jul 2008 08:52:45 +0000 | |
changeset 1146 | f18d124d7fbc |
parent 1144 | 7dbfdd61812c |
child 1151 | 1fc1535dec29 |
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 "CommandPdos.h" |
|
12 |
||
13 |
/*****************************************************************************/ |
|
14 |
||
15 |
CommandPdos::CommandPdos(): |
|
16 |
Command("pdos", "List Sync managers, Pdo assignment and mapping.") |
|
17 |
{ |
|
18 |
} |
|
19 |
||
20 |
/*****************************************************************************/ |
|
21 |
||
22 |
string CommandPdos::helpString() const |
|
23 |
{ |
|
24 |
stringstream str; |
|
25 |
||
26 |
str << getName() << " [OPTIONS]" << endl |
|
27 |
<< endl |
|
28 |
<< getBriefDescription() << endl |
|
29 |
<< endl |
|
30 |
<< "The information is displayed in three layers, which are" << endl |
|
31 |
<< "indented accordingly:" << endl |
|
32 |
<< endl |
|
33 |
<< "1) Sync managers - Contains the sync manager information" << endl |
|
34 |
<< " from the SII: Index, physical start address, default" << endl |
|
35 |
<< " size (value from the SII), control register and enable" << endl |
|
36 |
<< " word. Example:" << endl |
|
37 |
<< endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
38 |
<< " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, " |
1142 | 39 |
<< "Enable 1" << endl |
40 |
<< endl |
|
41 |
<< "2) Assigned Pdos - Pdo direction, hexadecimal index and" << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
42 |
<< " the Pdo name, if avaliable. Note that a 'Tx' and 'Rx'" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
43 |
<< " are seen from the slave's point of view. Example:" << endl |
1142 | 44 |
<< endl |
45 |
<< " TxPdo 0x1a00 \"Channel1\"" << endl |
|
46 |
<< endl |
|
47 |
<< "3) Mapped Pdo entries - Pdo entry index and subindex (both" << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
48 |
<< " hexadecimal), the length in bit and the description, if" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
49 |
<< " available. Example:" << endl |
1142 | 50 |
<< endl |
51 |
<< " Pdo entry 0x3101:01, 8 bit, \"Status\"" << endl |
|
52 |
<< endl |
|
53 |
<< "Note, that the displayed Pdo assignment and Pdo mapping" << endl |
|
54 |
<< "information can either originate from the SII or from the" << endl |
|
55 |
<< "CoE communication area." << endl |
|
56 |
<< endl |
|
57 |
<< "Command-specific options:" << endl |
|
58 |
<< " --slave -s <index> Positive numerical ring position," << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
59 |
<< " or 'all' for all slaves (default)." << endl |
1142 | 60 |
<< endl |
61 |
<< numericInfo(); |
|
62 |
||
63 |
return str.str(); |
|
64 |
} |
|
65 |
||
66 |
/****************************************************************************/ |
|
67 |
||
68 |
void CommandPdos::execute(MasterDevice &m, const StringVector &args) |
|
69 |
{ |
|
70 |
m.open(MasterDevice::Read); |
|
71 |
||
72 |
if (slavePosition == -1) { |
|
73 |
unsigned int numSlaves = m.slaveCount(), i; |
|
74 |
||
75 |
for (i = 0; i < numSlaves; i++) { |
|
76 |
listSlavePdos(m, i, true); |
|
77 |
} |
|
78 |
} else { |
|
79 |
listSlavePdos(m, slavePosition, false); |
|
80 |
} |
|
81 |
} |
|
82 |
||
83 |
/****************************************************************************/ |
|
84 |
||
85 |
void CommandPdos::listSlavePdos( |
|
86 |
MasterDevice &m, |
|
87 |
uint16_t slavePosition, |
|
88 |
bool withHeader |
|
89 |
) |
|
90 |
{ |
|
91 |
ec_ioctl_slave_t slave; |
|
92 |
ec_ioctl_slave_sync_t sync; |
|
93 |
ec_ioctl_slave_sync_pdo_t pdo; |
|
94 |
ec_ioctl_slave_sync_pdo_entry_t entry; |
|
95 |
unsigned int i, j, k; |
|
96 |
||
97 |
m.getSlave(&slave, slavePosition); |
|
98 |
||
99 |
if (withHeader) |
|
100 |
cout << "=== Slave " << slavePosition << " ===" << endl; |
|
101 |
||
102 |
for (i = 0; i < slave.sync_count; i++) { |
|
103 |
m.getSync(&sync, slavePosition, i); |
|
104 |
||
105 |
cout << "SM" << i << ":" |
|
106 |
<< " PhysAddr 0x" |
|
107 |
<< hex << setfill('0') |
|
108 |
<< setw(4) << sync.physical_start_address |
|
109 |
<< ", DefaultSize " |
|
110 |
<< dec << setfill(' ') << setw(4) << sync.default_size |
|
111 |
<< ", ControlRegister 0x" |
|
112 |
<< hex << setfill('0') << setw(2) |
|
113 |
<< (unsigned int) sync.control_register |
|
114 |
<< ", Enable " << dec << (unsigned int) sync.enable |
|
115 |
<< endl; |
|
116 |
||
117 |
for (j = 0; j < sync.pdo_count; j++) { |
|
118 |
m.getPdo(&pdo, slavePosition, i, j); |
|
119 |
||
120 |
cout << " " << (sync.control_register & 0x04 ? "R" : "T") |
|
121 |
<< "xPdo 0x" |
|
122 |
<< hex << setfill('0') |
|
123 |
<< setw(4) << pdo.index |
|
124 |
<< " \"" << pdo.name << "\"" << endl; |
|
125 |
||
126 |
if (getVerbosity() == Quiet) |
|
127 |
continue; |
|
128 |
||
129 |
for (k = 0; k < pdo.entry_count; k++) { |
|
130 |
m.getPdoEntry(&entry, slavePosition, i, j, k); |
|
131 |
||
132 |
cout << " Pdo entry 0x" |
|
133 |
<< hex << setfill('0') |
|
134 |
<< setw(4) << entry.index |
|
135 |
<< ":" << setw(2) << (unsigned int) entry.subindex |
|
136 |
<< ", " << dec << (unsigned int) entry.bit_length |
|
137 |
<< " bit, \"" << entry.name << "\"" << endl; |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
/*****************************************************************************/ |