author | Florian Pose <fp@igh-essen.com> |
Fri, 17 Oct 2008 13:37:29 +0000 | |
changeset 1280 | dc1327c2ef5b |
parent 1187 | aa616c3286ce |
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 "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 |
|
1167 | 35 |
<< " size, control register and enable word. Example:" << endl |
1142 | 36 |
<< endl |
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
37 |
<< " SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, " |
1142 | 38 |
<< "Enable 1" << endl |
39 |
<< endl |
|
40 |
<< "2) Assigned Pdos - Pdo direction, hexadecimal index and" << endl |
|
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
41 |
<< " 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
|
42 |
<< " are seen from the slave's point of view. Example:" << endl |
1142 | 43 |
<< endl |
44 |
<< " TxPdo 0x1a00 \"Channel1\"" << endl |
|
45 |
<< endl |
|
46 |
<< "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
|
47 |
<< " hexadecimal), the length in bit and the description, if" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
48 |
<< " available. Example:" << endl |
1142 | 49 |
<< endl |
50 |
<< " Pdo entry 0x3101:01, 8 bit, \"Status\"" << endl |
|
51 |
<< endl |
|
52 |
<< "Note, that the displayed Pdo assignment and Pdo mapping" << endl |
|
53 |
<< "information can either originate from the SII or from the" << endl |
|
54 |
<< "CoE communication area." << endl |
|
55 |
<< endl |
|
56 |
<< "Command-specific options:" << endl |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
57 |
<< " --alias -a <alias>" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
58 |
<< " --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
|
59 |
<< " the 'slaves' command." << 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 |
{ |
|
1151 | 70 |
SlaveList slaves; |
71 |
SlaveList::const_iterator si; |
|
72 |
bool showHeader; |
|
73 |
||
1142 | 74 |
m.open(MasterDevice::Read); |
1151 | 75 |
slaves = selectedSlaves(m); |
76 |
showHeader = slaves.size() > 1; |
|
1142 | 77 |
|
1151 | 78 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
79 |
listSlavePdos(m, *si, showHeader); |
|
1142 | 80 |
} |
81 |
} |
|
82 |
||
83 |
/****************************************************************************/ |
|
84 |
||
85 |
void CommandPdos::listSlavePdos( |
|
86 |
MasterDevice &m, |
|
1151 | 87 |
const ec_ioctl_slave_t &slave, |
88 |
bool showHeader |
|
1142 | 89 |
) |
90 |
{ |
|
91 |
ec_ioctl_slave_sync_t sync; |
|
92 |
ec_ioctl_slave_sync_pdo_t pdo; |
|
93 |
ec_ioctl_slave_sync_pdo_entry_t entry; |
|
94 |
unsigned int i, j, k; |
|
95 |
||
1151 | 96 |
if (showHeader) |
97 |
cout << "=== Slave " << slave.position << " ===" << endl; |
|
1142 | 98 |
|
99 |
for (i = 0; i < slave.sync_count; i++) { |
|
1151 | 100 |
m.getSync(&sync, slave.position, i); |
1142 | 101 |
|
102 |
cout << "SM" << i << ":" |
|
103 |
<< " PhysAddr 0x" |
|
104 |
<< hex << setfill('0') |
|
105 |
<< setw(4) << sync.physical_start_address |
|
106 |
<< ", DefaultSize " |
|
107 |
<< dec << setfill(' ') << setw(4) << sync.default_size |
|
108 |
<< ", ControlRegister 0x" |
|
109 |
<< hex << setfill('0') << setw(2) |
|
110 |
<< (unsigned int) sync.control_register |
|
111 |
<< ", Enable " << dec << (unsigned int) sync.enable |
|
112 |
<< endl; |
|
113 |
||
114 |
for (j = 0; j < sync.pdo_count; j++) { |
|
1151 | 115 |
m.getPdo(&pdo, slave.position, i, j); |
1142 | 116 |
|
117 |
cout << " " << (sync.control_register & 0x04 ? "R" : "T") |
|
118 |
<< "xPdo 0x" |
|
119 |
<< hex << setfill('0') |
|
120 |
<< setw(4) << pdo.index |
|
121 |
<< " \"" << pdo.name << "\"" << endl; |
|
122 |
||
123 |
if (getVerbosity() == Quiet) |
|
124 |
continue; |
|
125 |
||
126 |
for (k = 0; k < pdo.entry_count; k++) { |
|
1151 | 127 |
m.getPdoEntry(&entry, slave.position, i, j, k); |
1142 | 128 |
|
129 |
cout << " Pdo entry 0x" |
|
130 |
<< hex << setfill('0') |
|
131 |
<< setw(4) << entry.index |
|
132 |
<< ":" << setw(2) << (unsigned int) entry.subindex |
|
1187
aa616c3286ce
Show Pdo bit lengths right-aligned.
Florian Pose <fp@igh-essen.com>
parents:
1167
diff
changeset
|
133 |
<< ", " << dec << setfill(' ') |
aa616c3286ce
Show Pdo bit lengths right-aligned.
Florian Pose <fp@igh-essen.com>
parents:
1167
diff
changeset
|
134 |
<< setw(2) << (unsigned int) entry.bit_length |
1142 | 135 |
<< " bit, \"" << entry.name << "\"" << endl; |
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
||
141 |
/*****************************************************************************/ |