author | Florian Pose <fp@igh-essen.com> |
Mon, 28 Jul 2008 13:23:07 +0000 | |
changeset 1162 | 51a8b41d3dbc |
parent 1157 | 04d1c950cf9d |
child 1167 | 9e0ebb38e301 |
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 |
|
1157
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
58 |
<< " --alias -a <alias>" << endl |
04d1c950cf9d
Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
59 |
<< " --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
|
60 |
<< " the 'slaves' command." << endl |
1142 | 61 |
<< endl |
62 |
<< numericInfo(); |
|
63 |
||
64 |
return str.str(); |
|
65 |
} |
|
66 |
||
67 |
/****************************************************************************/ |
|
68 |
||
69 |
void CommandPdos::execute(MasterDevice &m, const StringVector &args) |
|
70 |
{ |
|
1151 | 71 |
SlaveList slaves; |
72 |
SlaveList::const_iterator si; |
|
73 |
bool showHeader; |
|
74 |
||
1142 | 75 |
m.open(MasterDevice::Read); |
1151 | 76 |
slaves = selectedSlaves(m); |
77 |
showHeader = slaves.size() > 1; |
|
1142 | 78 |
|
1151 | 79 |
for (si = slaves.begin(); si != slaves.end(); si++) { |
80 |
listSlavePdos(m, *si, showHeader); |
|
1142 | 81 |
} |
82 |
} |
|
83 |
||
84 |
/****************************************************************************/ |
|
85 |
||
86 |
void CommandPdos::listSlavePdos( |
|
87 |
MasterDevice &m, |
|
1151 | 88 |
const ec_ioctl_slave_t &slave, |
89 |
bool showHeader |
|
1142 | 90 |
) |
91 |
{ |
|
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 |
||
1151 | 97 |
if (showHeader) |
98 |
cout << "=== Slave " << slave.position << " ===" << endl; |
|
1142 | 99 |
|
100 |
for (i = 0; i < slave.sync_count; i++) { |
|
1151 | 101 |
m.getSync(&sync, slave.position, i); |
1142 | 102 |
|
103 |
cout << "SM" << i << ":" |
|
104 |
<< " PhysAddr 0x" |
|
105 |
<< hex << setfill('0') |
|
106 |
<< setw(4) << sync.physical_start_address |
|
107 |
<< ", DefaultSize " |
|
108 |
<< dec << setfill(' ') << setw(4) << sync.default_size |
|
109 |
<< ", ControlRegister 0x" |
|
110 |
<< hex << setfill('0') << setw(2) |
|
111 |
<< (unsigned int) sync.control_register |
|
112 |
<< ", Enable " << dec << (unsigned int) sync.enable |
|
113 |
<< endl; |
|
114 |
||
115 |
for (j = 0; j < sync.pdo_count; j++) { |
|
1151 | 116 |
m.getPdo(&pdo, slave.position, i, j); |
1142 | 117 |
|
118 |
cout << " " << (sync.control_register & 0x04 ? "R" : "T") |
|
119 |
<< "xPdo 0x" |
|
120 |
<< hex << setfill('0') |
|
121 |
<< setw(4) << pdo.index |
|
122 |
<< " \"" << pdo.name << "\"" << endl; |
|
123 |
||
124 |
if (getVerbosity() == Quiet) |
|
125 |
continue; |
|
126 |
||
127 |
for (k = 0; k < pdo.entry_count; k++) { |
|
1151 | 128 |
m.getPdoEntry(&entry, slave.position, i, j, k); |
1142 | 129 |
|
130 |
cout << " Pdo entry 0x" |
|
131 |
<< hex << setfill('0') |
|
132 |
<< setw(4) << entry.index |
|
133 |
<< ":" << setw(2) << (unsigned int) entry.subindex |
|
134 |
<< ", " << dec << (unsigned int) entry.bit_length |
|
135 |
<< " bit, \"" << entry.name << "\"" << endl; |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
||
141 |
/*****************************************************************************/ |