1 /***************************************************************************** |
|
2 * |
|
3 * $Id$ |
|
4 * |
|
5 ****************************************************************************/ |
|
6 |
|
7 #include <iostream> |
|
8 #include <iomanip> |
|
9 using namespace std; |
|
10 |
|
11 #include "globals.h" |
|
12 |
|
13 /****************************************************************************/ |
|
14 |
|
15 const char *help_master = |
|
16 "[OPTIONS]\n" |
|
17 "\n" |
|
18 "Show master and Ethernet device information.\n" |
|
19 "\n" |
|
20 "Command-specific options:\n" |
|
21 " --master -m <index> Index of the master to use. Default: 0.\n" |
|
22 "\n" |
|
23 "Numerical values can be specified either with decimal (no prefix),\n" |
|
24 "octal (prefix '0') or hexadecimal (prefix '0x') base.\n"; |
|
25 |
|
26 /****************************************************************************/ |
|
27 |
|
28 void command_master(void) |
|
29 { |
|
30 ec_ioctl_master_t data; |
|
31 stringstream err; |
|
32 unsigned int i; |
|
33 |
|
34 masterDev.open(MasterDevice::Read); |
|
35 masterDev.getMaster(&data); |
|
36 |
|
37 cout |
|
38 << "Master" << masterIndex << endl |
|
39 << " Phase: "; |
|
40 |
|
41 switch (data.phase) { |
|
42 case 0: cout << "Waiting for device..."; break; |
|
43 case 1: cout << "Idle"; break; |
|
44 case 2: cout << "Operation"; break; |
|
45 default: cout << "???"; |
|
46 } |
|
47 |
|
48 cout << endl |
|
49 << " Slaves: " << data.slave_count << endl; |
|
50 |
|
51 for (i = 0; i < 2; i++) { |
|
52 cout << " Device" << i << ": "; |
|
53 if (data.devices[i].address[0] == 0x00 |
|
54 && data.devices[i].address[1] == 0x00 |
|
55 && data.devices[i].address[2] == 0x00 |
|
56 && data.devices[i].address[3] == 0x00 |
|
57 && data.devices[i].address[4] == 0x00 |
|
58 && data.devices[i].address[5] == 0x00) { |
|
59 cout << "None."; |
|
60 } else { |
|
61 cout << hex << setfill('0') |
|
62 << setw(2) << (unsigned int) data.devices[i].address[0] << ":" |
|
63 << setw(2) << (unsigned int) data.devices[i].address[1] << ":" |
|
64 << setw(2) << (unsigned int) data.devices[i].address[2] << ":" |
|
65 << setw(2) << (unsigned int) data.devices[i].address[3] << ":" |
|
66 << setw(2) << (unsigned int) data.devices[i].address[4] << ":" |
|
67 << setw(2) << (unsigned int) data.devices[i].address[5] << " (" |
|
68 << (data.devices[i].attached ? "attached" : "waiting...") |
|
69 << ")" << endl << dec |
|
70 << " Tx count: " << data.devices[i].tx_count << endl |
|
71 << " Rx count: " << data.devices[i].rx_count; |
|
72 } |
|
73 cout << endl; |
|
74 } |
|
75 } |
|
76 |
|
77 /*****************************************************************************/ |
|