author | Florian Pose <fp@igh-essen.com> |
Mon, 26 Jan 2009 16:35:50 +0000 | |
changeset 1344 | e5756d4ed12c |
parent 1327 | 4d179b06dd3c |
child 1363 | 11c0b2caa253 |
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(): |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
16 |
Command("pdos", "List Sync managers, PDO assignment and mapping.") |
1142 | 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 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
40 |
<< "2) Assigned PDOs - PDO direction, hexadecimal index and" << endl |
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
41 |
<< " the PDO name, if avaliable. Note that a 'Tx' and 'Rx'" << endl |
1144
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 |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
44 |
<< " TxPDO 0x1a00 \"Channel1\"" << endl |
1142 | 45 |
<< endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
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 |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
50 |
<< " PDO entry 0x3101:01, 8 bit, \"Status\"" << endl |
1142 | 51 |
<< endl |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
52 |
<< "Note, that the displayed PDO assignment and PDO mapping" << endl |
1142 | 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") |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
118 |
<< "xPDO 0x" |
1142 | 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 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1187
diff
changeset
|
129 |
cout << " PDO entry 0x" |
1142 | 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 |
/*****************************************************************************/ |