74 if (args.size()) { |
77 if (args.size()) { |
75 err << "'" << getName() << "' takes no arguments!"; |
78 err << "'" << getName() << "' takes no arguments!"; |
76 throwInvalidUsageException(err); |
79 throwInvalidUsageException(err); |
77 } |
80 } |
78 |
81 |
79 m.open(MasterDevice::Read); |
82 MasterIndexList::const_iterator mi; |
80 m.getMaster(&data); |
83 for (mi = getMasterIndices().begin(); |
|
84 mi != getMasterIndices().end(); mi++) { |
|
85 MasterDevice m(*mi); |
|
86 m.open(MasterDevice::Read); |
|
87 m.getMaster(&data); |
81 |
88 |
82 cout |
89 cout |
83 << "Master" << m.getIndex() << endl |
90 << "Master" << m.getIndex() << endl |
84 << " Phase: "; |
91 << " Phase: "; |
85 |
92 |
86 switch (data.phase) { |
93 switch (data.phase) { |
87 case 0: cout << "Waiting for device..."; break; |
94 case 0: cout << "Waiting for device..."; break; |
88 case 1: cout << "Idle"; break; |
95 case 1: cout << "Idle"; break; |
89 case 2: cout << "Operation"; break; |
96 case 2: cout << "Operation"; break; |
90 default: cout << "???"; |
97 default: cout << "???"; |
|
98 } |
|
99 |
|
100 cout << endl |
|
101 << " Active: " << (data.active ? "yes" : "no") << endl |
|
102 << " Slaves: " << data.slave_count << endl |
|
103 << " Ethernet devices:" << endl; |
|
104 |
|
105 for (i = 0; i < 2; i++) { |
|
106 cout << " " << (i == 0 ? "Main" : "Backup") << ": "; |
|
107 if (data.devices[i].address[0] == 0x00 |
|
108 && data.devices[i].address[1] == 0x00 |
|
109 && data.devices[i].address[2] == 0x00 |
|
110 && data.devices[i].address[3] == 0x00 |
|
111 && data.devices[i].address[4] == 0x00 |
|
112 && data.devices[i].address[5] == 0x00) { |
|
113 cout << "None."; |
|
114 } else { |
|
115 cout << hex << setfill('0') |
|
116 << setw(2) << (unsigned int) data.devices[i].address[0] |
|
117 << ":" |
|
118 << setw(2) << (unsigned int) data.devices[i].address[1] |
|
119 << ":" |
|
120 << setw(2) << (unsigned int) data.devices[i].address[2] |
|
121 << ":" |
|
122 << setw(2) << (unsigned int) data.devices[i].address[3] |
|
123 << ":" |
|
124 << setw(2) << (unsigned int) data.devices[i].address[4] |
|
125 << ":" |
|
126 << setw(2) << (unsigned int) data.devices[i].address[5] |
|
127 << " (" |
|
128 << (data.devices[i].attached ? "attached" : "waiting...") |
|
129 << ")" << endl << dec |
|
130 << " Link: " |
|
131 << (data.devices[i].link_state ? "UP" : "DOWN") << endl |
|
132 << " Tx count: " << data.devices[i].tx_count << endl |
|
133 << " Rx count: " << data.devices[i].rx_count; |
|
134 } |
|
135 cout << endl; |
|
136 } |
|
137 |
|
138 cout << " Distributed clocks:" << endl |
|
139 << " Reference clock: "; |
|
140 if (data.ref_clock != 0xffff) { |
|
141 cout << "Slave " << dec << data.ref_clock; |
|
142 } else { |
|
143 cout << "None"; |
|
144 } |
|
145 cout << endl |
|
146 << " Application time: " << data.app_time << endl |
|
147 << " "; |
|
148 |
|
149 epoch = data.app_time / 1000000000 + 946684800ULL; |
|
150 time_str_size = strftime(time_str, MAX_TIME_STR_SIZE, |
|
151 "%Y-%m-%d %H:%M:%S", gmtime(&epoch)); |
|
152 cout << string(time_str, time_str_size) << "." |
|
153 << setfill('0') << setw(9) << data.app_time % 1000000000 << endl; |
91 } |
154 } |
92 |
|
93 cout << endl |
|
94 << " Active: " << (data.active ? "yes" : "no") << endl |
|
95 << " Slaves: " << data.slave_count << endl |
|
96 << " Ethernet devices:" << endl; |
|
97 |
|
98 for (i = 0; i < 2; i++) { |
|
99 cout << " " << (i == 0 ? "Main" : "Backup") << ": "; |
|
100 if (data.devices[i].address[0] == 0x00 |
|
101 && data.devices[i].address[1] == 0x00 |
|
102 && data.devices[i].address[2] == 0x00 |
|
103 && data.devices[i].address[3] == 0x00 |
|
104 && data.devices[i].address[4] == 0x00 |
|
105 && data.devices[i].address[5] == 0x00) { |
|
106 cout << "None."; |
|
107 } else { |
|
108 cout << hex << setfill('0') |
|
109 << setw(2) << (unsigned int) data.devices[i].address[0] << ":" |
|
110 << setw(2) << (unsigned int) data.devices[i].address[1] << ":" |
|
111 << setw(2) << (unsigned int) data.devices[i].address[2] << ":" |
|
112 << setw(2) << (unsigned int) data.devices[i].address[3] << ":" |
|
113 << setw(2) << (unsigned int) data.devices[i].address[4] << ":" |
|
114 << setw(2) << (unsigned int) data.devices[i].address[5] << " (" |
|
115 << (data.devices[i].attached ? "attached" : "waiting...") |
|
116 << ")" << endl << dec |
|
117 << " Link: " << (data.devices[i].link_state ? "UP" : "DOWN") << endl |
|
118 << " Tx count: " << data.devices[i].tx_count << endl |
|
119 << " Rx count: " << data.devices[i].rx_count; |
|
120 } |
|
121 cout << endl; |
|
122 } |
|
123 |
|
124 cout << " Distributed clocks:" << endl |
|
125 << " Reference clock: "; |
|
126 if (data.ref_clock != 0xffff) { |
|
127 cout << "Slave " << dec << data.ref_clock; |
|
128 } else { |
|
129 cout << "None"; |
|
130 } |
|
131 cout << endl |
|
132 << " Application time: " << data.app_time << endl |
|
133 << " "; |
|
134 |
|
135 epoch = data.app_time / 1000000000 + 946684800ULL; |
|
136 time_str_size = strftime(time_str, MAX_TIME_STR_SIZE, |
|
137 "%Y-%m-%d %H:%M:%S", gmtime(&epoch)); |
|
138 cout << string(time_str, time_str_size) << "." |
|
139 << setfill('0') << setw(9) << data.app_time % 1000000000 << endl; |
|
140 } |
155 } |
141 |
156 |
142 /*****************************************************************************/ |
157 /*****************************************************************************/ |