author | Florian Pose <fp@igh-essen.com> |
Wed, 23 Jul 2008 07:26:19 +0000 | |
changeset 1134 | 3356141fa2f8 |
parent 1130 | bb1c11adb2db |
child 1137 | a73c0f54be42 |
permissions | -rw-r--r-- |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
#include <iostream> |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
#include <iomanip> |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
using namespace std; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
#include "globals.h" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
|
1130
bb1c11adb2db
Updated first part of command documentation.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
15 |
// FIXME |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
const char *help_pdos = |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
"[OPTIONS]\n" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
"\n" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
"\n" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
"Command-specific options:\n"; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
void listSlavePdos(uint16_t, bool); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
void command_pdos(void) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
masterDev.open(MasterDevice::Read); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
if (slavePosition == -1) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
unsigned int numSlaves = masterDev.slaveCount(), i; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
for (i = 0; i < numSlaves; i++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
listSlavePdos(i, true); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
} else { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
listSlavePdos(slavePosition, false); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
void listSlavePdos(uint16_t slavePosition, bool withHeader) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
ec_ioctl_slave_t slave; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
ec_ioctl_slave_sync_t sync; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
ec_ioctl_slave_sync_pdo_t pdo; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
ec_ioctl_slave_sync_pdo_entry_t entry; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
unsigned int i, j, k; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
masterDev.getSlave(&slave, slavePosition); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
if (withHeader) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
cout << "=== Slave " << slavePosition << " ===" << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
for (i = 0; i < slave.sync_count; i++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
masterDev.getSync(&sync, slavePosition, i); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
cout << "SM" << i << ":" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
<< " PhysAddr 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
<< hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
<< setw(4) << sync.physical_start_address |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
<< ", DefaultSize " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
<< dec << setfill(' ') << setw(4) << sync.default_size |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
<< ", ControlRegister 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
<< hex << setfill('0') << setw(2) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
<< (unsigned int) sync.control_register |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
<< ", Enable " << dec << (unsigned int) sync.enable |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
<< endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
for (j = 0; j < sync.pdo_count; j++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
masterDev.getPdo(&pdo, slavePosition, i, j); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
cout << " " << (sync.control_register & 0x04 ? "R" : "T") |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
<< "xPdo 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
<< hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
<< setw(4) << pdo.index |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
<< " \"" << pdo.name << "\"" << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
if (verbosity == Quiet) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
continue; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
for (k = 0; k < pdo.entry_count; k++) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
masterDev.getPdoEntry(&entry, slavePosition, i, j, k); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
cout << " Pdo entry 0x" |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
<< hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
<< setw(4) << entry.index |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
<< ":" << setw(2) << (unsigned int) entry.subindex |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
<< ", " << dec << (unsigned int) entry.bit_length |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
<< " bit, \"" << entry.name << "\"" << endl; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
/*****************************************************************************/ |