author | Florian Pose <fp@igh-essen.com> |
Wed, 05 Nov 2008 10:36:18 +0000 | |
branch | stable-1.4 |
changeset 1657 | 3dbdb7392d7b |
parent 1166 | 006244d53f68 |
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 "CommandMaster.h" |
|
12 |
||
13 |
/*****************************************************************************/ |
|
14 |
||
15 |
CommandMaster::CommandMaster(): |
|
1143
09ee878d7214
Fixed duplicate alias command.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
16 |
Command("master", "Show master and Ethernet device information.") |
1142 | 17 |
{ |
18 |
} |
|
19 |
||
20 |
/****************************************************************************/ |
|
21 |
||
22 |
string CommandMaster::helpString() const |
|
23 |
{ |
|
24 |
stringstream str; |
|
25 |
||
26 |
str << getName() << " [OPTIONS]" << endl |
|
27 |
<< endl |
|
28 |
<< getBriefDescription() << endl |
|
29 |
<< endl |
|
30 |
<< "Command-specific options:" << endl |
|
31 |
<< " --master -m <index> Index of the master to use. Default: 0." |
|
32 |
<< endl << endl |
|
33 |
<< numericInfo(); |
|
34 |
||
35 |
return str.str(); |
|
36 |
} |
|
37 |
||
38 |
/****************************************************************************/ |
|
39 |
||
40 |
void CommandMaster::execute(MasterDevice &m, const StringVector &args) |
|
41 |
{ |
|
42 |
ec_ioctl_master_t data; |
|
43 |
stringstream err; |
|
44 |
unsigned int i; |
|
45 |
||
46 |
m.open(MasterDevice::Read); |
|
47 |
m.getMaster(&data); |
|
48 |
||
49 |
cout |
|
1166 | 50 |
<< "Master" << m.getIndex() << endl |
1142 | 51 |
<< " Phase: "; |
52 |
||
53 |
switch (data.phase) { |
|
54 |
case 0: cout << "Waiting for device..."; break; |
|
55 |
case 1: cout << "Idle"; break; |
|
56 |
case 2: cout << "Operation"; break; |
|
57 |
default: cout << "???"; |
|
58 |
} |
|
59 |
||
60 |
cout << endl |
|
61 |
<< " Slaves: " << data.slave_count << endl; |
|
62 |
||
63 |
for (i = 0; i < 2; i++) { |
|
64 |
cout << " Device" << i << ": "; |
|
65 |
if (data.devices[i].address[0] == 0x00 |
|
66 |
&& data.devices[i].address[1] == 0x00 |
|
67 |
&& data.devices[i].address[2] == 0x00 |
|
68 |
&& data.devices[i].address[3] == 0x00 |
|
69 |
&& data.devices[i].address[4] == 0x00 |
|
70 |
&& data.devices[i].address[5] == 0x00) { |
|
71 |
cout << "None."; |
|
72 |
} else { |
|
73 |
cout << hex << setfill('0') |
|
74 |
<< setw(2) << (unsigned int) data.devices[i].address[0] << ":" |
|
75 |
<< setw(2) << (unsigned int) data.devices[i].address[1] << ":" |
|
76 |
<< setw(2) << (unsigned int) data.devices[i].address[2] << ":" |
|
77 |
<< setw(2) << (unsigned int) data.devices[i].address[3] << ":" |
|
78 |
<< setw(2) << (unsigned int) data.devices[i].address[4] << ":" |
|
79 |
<< setw(2) << (unsigned int) data.devices[i].address[5] << " (" |
|
80 |
<< (data.devices[i].attached ? "attached" : "waiting...") |
|
81 |
<< ")" << endl << dec |
|
82 |
<< " Tx count: " << data.devices[i].tx_count << endl |
|
83 |
<< " Rx count: " << data.devices[i].rx_count; |
|
84 |
} |
|
85 |
cout << endl; |
|
86 |
} |
|
87 |
} |
|
88 |
||
89 |
/*****************************************************************************/ |