author | Florian Pose <fp@igh.de> |
Thu, 12 Oct 2017 15:01:43 +0200 | |
branch | stable-1.5 |
changeset 2689 | 61c7f0681247 |
parent 2453 | d461b1f07296 |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
3 |
* $Id$ |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
4 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
6 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
8 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
11 |
* published by the Free Software Foundation. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
12 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
16 |
* Public License for more details. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
17 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
21 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1142 | 27 |
* |
28 |
****************************************************************************/ |
|
29 |
||
30 |
#include <iostream> |
|
31 |
#include <iomanip> |
|
32 |
using namespace std; |
|
33 |
||
34 |
#include "CommandMaster.h" |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
35 |
#include "MasterDevice.h" |
1142 | 36 |
|
1415
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
37 |
#define MAX_TIME_STR_SIZE 50 |
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
38 |
|
1142 | 39 |
/*****************************************************************************/ |
40 |
||
41 |
CommandMaster::CommandMaster(): |
|
1143
09ee878d7214
Fixed duplicate alias command.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
42 |
Command("master", "Show master and Ethernet device information.") |
1142 | 43 |
{ |
44 |
} |
|
45 |
||
46 |
/****************************************************************************/ |
|
47 |
||
1968
4f682084c643
Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents:
1962
diff
changeset
|
48 |
string CommandMaster::helpString(const string &binaryBaseName) const |
1142 | 49 |
{ |
50 |
stringstream str; |
|
51 |
||
1968
4f682084c643
Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents:
1962
diff
changeset
|
52 |
str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl |
1804 | 53 |
<< endl |
54 |
<< getBriefDescription() << endl |
|
55 |
<< endl |
|
56 |
<< "Command-specific options:" << endl |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
57 |
<< " --master -m <indices> Master indices. A comma-separated" << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
58 |
<< " list with ranges is supported." << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
59 |
<< " Example: 1,4,5,7-9. Default: - (all)." |
1804 | 60 |
<< endl << endl |
61 |
<< numericInfo(); |
|
1142 | 62 |
|
1804 | 63 |
return str.str(); |
1142 | 64 |
} |
65 |
||
66 |
/****************************************************************************/ |
|
67 |
||
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
68 |
void CommandMaster::execute(const StringVector &args) |
1142 | 69 |
{ |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1858
diff
changeset
|
70 |
MasterIndexList masterIndices; |
1142 | 71 |
ec_ioctl_master_t data; |
72 |
stringstream err; |
|
2453
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
73 |
unsigned int dev_idx, j; |
1415
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
74 |
time_t epoch; |
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
75 |
char time_str[MAX_TIME_STR_SIZE + 1]; |
9d1cdbf41247
Output reference clock and application time in 'ethercat Master'.
Florian Pose <fp@igh-essen.com>
parents:
1401
diff
changeset
|
76 |
size_t time_str_size; |
2421 | 77 |
|
1373
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
78 |
if (args.size()) { |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
79 |
err << "'" << getName() << "' takes no arguments!"; |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
80 |
throwInvalidUsageException(err); |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
81 |
} |
e651000f1ff1
Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
82 |
|
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1858
diff
changeset
|
83 |
masterIndices = getMasterIndices(); |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
84 |
MasterIndexList::const_iterator mi; |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1858
diff
changeset
|
85 |
for (mi = masterIndices.begin(); |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1858
diff
changeset
|
86 |
mi != masterIndices.end(); mi++) { |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
87 |
MasterDevice m(*mi); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
88 |
m.open(MasterDevice::Read); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
89 |
m.getMaster(&data); |
1142 | 90 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
91 |
cout |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
92 |
<< "Master" << m.getIndex() << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
93 |
<< " Phase: "; |
1142 | 94 |
|
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
95 |
switch (data.phase) { |
2156
71425e6120d8
Master accepting two devices.
Florian Pose <fp@igh-essen.com>
parents:
1968
diff
changeset
|
96 |
case 0: cout << "Waiting for device(s)..."; break; |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
97 |
case 1: cout << "Idle"; break; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
98 |
case 2: cout << "Operation"; break; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
99 |
default: cout << "???"; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
100 |
} |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
101 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
102 |
cout << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
103 |
<< " Active: " << (data.active ? "yes" : "no") << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
104 |
<< " Slaves: " << data.slave_count << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
105 |
<< " Ethernet devices:" << endl; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
106 |
|
2453
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
107 |
for (dev_idx = EC_DEVICE_MAIN; dev_idx < data.num_devices; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
108 |
dev_idx++) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
109 |
cout << " " << (dev_idx == EC_DEVICE_MAIN ? "Main" : "Backup") |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
110 |
<< ": "; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
111 |
cout << hex << setfill('0') |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
112 |
<< setw(2) << (unsigned int) data.devices[dev_idx].address[0] |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
113 |
<< ":" |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
114 |
<< setw(2) << (unsigned int) data.devices[dev_idx].address[1] |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
115 |
<< ":" |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
116 |
<< setw(2) << (unsigned int) data.devices[dev_idx].address[2] |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
117 |
<< ":" |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
118 |
<< setw(2) << (unsigned int) data.devices[dev_idx].address[3] |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
119 |
<< ":" |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
120 |
<< setw(2) << (unsigned int) data.devices[dev_idx].address[4] |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
121 |
<< ":" |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
122 |
<< setw(2) << (unsigned int) data.devices[dev_idx].address[5] |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
123 |
<< " (" |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
124 |
<< (data.devices[dev_idx].attached ? |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
125 |
"attached" : "waiting...") |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
126 |
<< ")" << endl << dec |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
127 |
<< " Link: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
128 |
<< (data.devices[dev_idx].link_state ? "UP" : "DOWN") << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
129 |
<< " Tx frames: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
130 |
<< data.devices[dev_idx].tx_count << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
131 |
<< " Tx bytes: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
132 |
<< data.devices[dev_idx].tx_bytes << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
133 |
<< " Rx frames: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
134 |
<< data.devices[dev_idx].rx_count << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
135 |
<< " Rx bytes: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
136 |
<< data.devices[dev_idx].rx_bytes << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
137 |
<< " Tx errors: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
138 |
<< data.devices[dev_idx].tx_errors << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
139 |
<< " Tx frame rate [1/s]: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
140 |
<< setfill(' ') << setprecision(0) << fixed; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
141 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
142 |
cout << setw(ColWidth) |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
143 |
<< data.devices[dev_idx].tx_frame_rates[j] / 1000.0; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
144 |
if (j < EC_RATE_COUNT - 1) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
145 |
cout << " "; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
146 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
147 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
148 |
cout << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
149 |
<< " Tx rate [KByte/s]: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
150 |
<< setprecision(1) << fixed; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
151 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
152 |
cout << setw(ColWidth) |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
153 |
<< data.devices[dev_idx].tx_byte_rates[j] / 1024.0; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
154 |
if (j < EC_RATE_COUNT - 1) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
155 |
cout << " "; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
156 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
157 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
158 |
cout << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
159 |
<< " Rx frame rate [1/s]: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
160 |
<< setfill(' ') << setprecision(0) << fixed; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
161 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
162 |
cout << setw(ColWidth) |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
163 |
<< data.devices[dev_idx].rx_frame_rates[j] / 1000.0; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
164 |
if (j < EC_RATE_COUNT - 1) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
165 |
cout << " "; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
166 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
167 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
168 |
cout << endl |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
169 |
<< " Rx rate [KByte/s]: " |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
170 |
<< setprecision(1) << fixed; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
171 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
172 |
cout << setw(ColWidth) |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
173 |
<< data.devices[dev_idx].rx_byte_rates[j] / 1024.0; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
174 |
if (j < EC_RATE_COUNT - 1) { |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
175 |
cout << " "; |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
176 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
177 |
} |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2452
diff
changeset
|
178 |
cout << setprecision(0) << endl; |
2158
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
179 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
180 |
unsigned int lost = data.tx_count - data.rx_count; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
181 |
if (lost == 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
182 |
// allow one frame travelling |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
183 |
lost = 0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
184 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
185 |
cout << " Common:" << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
186 |
<< " Tx frames: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
187 |
<< data.tx_count << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
188 |
<< " Tx bytes: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
189 |
<< data.tx_bytes << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
190 |
<< " Rx frames: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
191 |
<< data.rx_count << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
192 |
<< " Rx bytes: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
193 |
<< data.rx_bytes << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
194 |
<< " Lost frames: " << lost << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
195 |
<< " Tx frame rate [1/s]: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
196 |
<< setfill(' ') << setprecision(0) << fixed; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
197 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
198 |
cout << setw(ColWidth) |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
199 |
<< data.tx_frame_rates[j] / 1000.0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
200 |
if (j < EC_RATE_COUNT - 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
201 |
cout << " "; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
202 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
203 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
204 |
cout << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
205 |
<< " Tx rate [KByte/s]: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
206 |
<< setprecision(1) << fixed; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
207 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
208 |
cout << setw(ColWidth) |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
209 |
<< data.tx_byte_rates[j] / 1024.0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
210 |
if (j < EC_RATE_COUNT - 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
211 |
cout << " "; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
212 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
213 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
214 |
cout << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
215 |
<< " Rx frame rate [1/s]: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
216 |
<< setfill(' ') << setprecision(0) << fixed; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
217 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
218 |
cout << setw(ColWidth) |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
219 |
<< data.rx_frame_rates[j] / 1000.0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
220 |
if (j < EC_RATE_COUNT - 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
221 |
cout << " "; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
222 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
223 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
224 |
cout << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
225 |
<< " Rx rate [KByte/s]: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
226 |
<< setprecision(1) << fixed; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
227 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
228 |
cout << setw(ColWidth) |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
229 |
<< data.rx_byte_rates[j] / 1024.0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
230 |
if (j < EC_RATE_COUNT - 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
231 |
cout << " "; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
232 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
233 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
234 |
cout << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
235 |
<< " Loss rate [1/s]: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
236 |
<< setprecision(0) << fixed; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
237 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
238 |
cout << setw(ColWidth) |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
239 |
<< data.loss_rates[j] / 1000.0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
240 |
if (j < EC_RATE_COUNT - 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
241 |
cout << " "; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
242 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
243 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
244 |
cout << endl |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
245 |
<< " Frame loss [%]: " |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
246 |
<< setprecision(1) << fixed; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
247 |
for (j = 0; j < EC_RATE_COUNT; j++) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
248 |
double perc = 0.0; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
249 |
if (data.tx_frame_rates[j]) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
250 |
perc = 100.0 * data.loss_rates[j] / data.tx_frame_rates[j]; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
251 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
252 |
cout << setw(ColWidth) << perc; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
253 |
if (j < EC_RATE_COUNT - 1) { |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
254 |
cout << " "; |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
255 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
256 |
} |
69f2b2702336
Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents:
2156
diff
changeset
|
257 |
cout << setprecision(0) << endl; |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
258 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
259 |
cout << " Distributed clocks:" << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
260 |
<< " Reference clock: "; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
261 |
if (data.ref_clock != 0xffff) { |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
262 |
cout << "Slave " << dec << data.ref_clock; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
263 |
} else { |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
264 |
cout << "None"; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
265 |
} |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
266 |
cout << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
267 |
<< " Application time: " << data.app_time << endl |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
268 |
<< " "; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
269 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
270 |
epoch = data.app_time / 1000000000 + 946684800ULL; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
271 |
time_str_size = strftime(time_str, MAX_TIME_STR_SIZE, |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
272 |
"%Y-%m-%d %H:%M:%S", gmtime(&epoch)); |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
273 |
cout << string(time_str, time_str_size) << "." |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
274 |
<< setfill('0') << setw(9) << data.app_time % 1000000000 << endl; |
1142 | 275 |
} |
276 |
} |
|
277 |
||
278 |
/*****************************************************************************/ |