tool/CommandMaster.cpp
author Florian Pose <fp@igh-essen.com>
Thu, 06 Sep 2012 14:47:42 +0200
branchredundancy
changeset 2418 8cbb68315d29
parent 2158 69f2b2702336
child 2421 bc2d4bf9cbe5
permissions -rw-r--r--
Fixed all mangled hg keywords.
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 ****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#include <iostream>
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <iomanip>
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
using namespace std;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
/*****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
{
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
{
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
    stringstream str;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    53
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    54
        << getBriefDescription() << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    55
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    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
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    60
        << endl << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    61
        << numericInfo();
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1530
diff changeset
    63
    return str.str();
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
{
1869
14f634f5b613 Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents: 1858
diff changeset
    70
	MasterIndexList masterIndices;
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
    ec_ioctl_master_t data;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
    stringstream err;
1851
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
    73
    unsigned int i, 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;
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    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
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   107
        for (i = 0; i < 2; i++) {
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   108
            cout << "    " << (i == 0 ? "Main" : "Backup") << ": ";
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   109
            if (data.devices[i].address[0] == 0x00
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   110
                    && data.devices[i].address[1] == 0x00
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   111
                    && data.devices[i].address[2] == 0x00
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   112
                    && data.devices[i].address[3] == 0x00
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   113
                    && data.devices[i].address[4] == 0x00
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   114
                    && data.devices[i].address[5] == 0x00) {
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   115
                cout << "None.";
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   116
            } else {
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   117
                cout << hex << setfill('0')
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   118
                    << setw(2) << (unsigned int) data.devices[i].address[0]
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   119
                    << ":"
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   120
                    << setw(2) << (unsigned int) data.devices[i].address[1]
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   121
                    << ":"
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   122
                    << setw(2) << (unsigned int) data.devices[i].address[2]
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   123
                    << ":"
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   124
                    << setw(2) << (unsigned int) data.devices[i].address[3]
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   125
                    << ":"
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   126
                    << setw(2) << (unsigned int) data.devices[i].address[4]
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   127
                    << ":"
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   128
                    << setw(2) << (unsigned int) data.devices[i].address[5]
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   129
                    << " ("
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   130
                    << (data.devices[i].attached ? "attached" : "waiting...")
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   131
                    << ")" << endl << dec
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   132
                    << "      Link: "
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   133
                    << (data.devices[i].link_state ? "UP" : "DOWN") << endl
1858
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   134
                    << "      Tx frames:   "
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   135
                    << data.devices[i].tx_count << endl
2158
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   136
                    << "      Tx bytes:    "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   137
                    << data.devices[i].tx_bytes << endl
1858
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   138
                    << "      Rx frames:   "
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   139
                    << data.devices[i].rx_count << endl
2158
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   140
                    << "      Rx bytes:    "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   141
                    << data.devices[i].rx_bytes << endl
1858
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   142
                    << "      Tx errors:   "
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   143
                    << data.devices[i].tx_errors << endl
1857
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   144
                    << "      Tx frame rate [1/s]: "
1853
e0b9c4611f0a Improved frame statistics output.
Florian Pose <fp@igh-essen.com>
parents: 1851
diff changeset
   145
                    << setfill(' ') << setprecision(0) << fixed;
1851
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   146
                for (j = 0; j < EC_RATE_COUNT; j++) {
1962
df9b00bda8dc Set master stats colum with to 6.
Florian Pose <fp@igh-essen.com>
parents: 1956
diff changeset
   147
                    cout << setw(ColWidth)
df9b00bda8dc Set master stats colum with to 6.
Florian Pose <fp@igh-essen.com>
parents: 1956
diff changeset
   148
                        << data.devices[i].tx_frame_rates[j] / 1000.0;
1851
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   149
                    if (j < EC_RATE_COUNT - 1) {
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   150
                        cout << " ";
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   151
                    }
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   152
                }
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   153
                cout << endl
1857
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   154
                    << "      Tx rate [KByte/s]:   "
1858
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   155
                    << setprecision(1) << fixed;
4d4aa4c0fc1e Improved frame statistics output again.
Florian Pose <fp@igh-essen.com>
parents: 1857
diff changeset
   156
                for (j = 0; j < EC_RATE_COUNT; j++) {
1962
df9b00bda8dc Set master stats colum with to 6.
Florian Pose <fp@igh-essen.com>
parents: 1956
diff changeset
   157
                    cout << setw(ColWidth)
1956
f461dc0d145a Fixed frame statistics overflow (to be verified).
Florian Pose <fp@igh-essen.com>
parents: 1869
diff changeset
   158
                        << data.devices[i].tx_byte_rates[j] / 1024.0;
1857
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   159
                    if (j < EC_RATE_COUNT - 1) {
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   160
                        cout << " ";
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   161
                    }
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   162
                }
ed8b490b5bc3 Output tx errors and tx rate in byte/s.
Florian Pose <fp@igh-essen.com>
parents: 1853
diff changeset
   163
                cout << endl
2158
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   164
                    << "      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
   165
                    << setfill(' ') << setprecision(0) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   166
                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
   167
                    cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   168
                        << data.devices[i].rx_frame_rates[j] / 1000.0;
1851
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   169
                    if (j < EC_RATE_COUNT - 1) {
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   170
                        cout << " ";
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   171
                    }
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   172
                }
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   173
                cout << endl
2158
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   174
                    << "      Rx rate [KByte/s]:   "
1853
e0b9c4611f0a Improved frame statistics output.
Florian Pose <fp@igh-essen.com>
parents: 1851
diff changeset
   175
                    << setprecision(1) << fixed;
1851
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   176
                for (j = 0; j < EC_RATE_COUNT; j++) {
2158
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   177
                    cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   178
                        << data.devices[i].rx_byte_rates[j] / 1024.0;
1851
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   179
                    if (j < EC_RATE_COUNT - 1) {
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   180
                        cout << " ";
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   181
                    }
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   182
                }
a56bd34e20a1 Frame statistics in 'ethercat master' output.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   183
                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
   184
            }
2158
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   185
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   186
        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
   187
        if (lost == 1) {
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   188
            // allow one frame travelling
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   189
            lost = 0;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   190
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   191
        cout << "    Common:" << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   192
            << "      Tx frames:   "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   193
            << data.tx_count << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   194
            << "      Tx bytes:    "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   195
            << data.tx_bytes << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   196
            << "      Rx frames:   "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   197
            << data.rx_count << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   198
            << "      Rx bytes:    "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   199
            << data.rx_bytes << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   200
            << "      Lost frames: " << lost << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   201
            << "      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
   202
            << setfill(' ') << setprecision(0) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   203
        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
   204
            cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   205
                << 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
   206
            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
   207
                cout << " ";
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   208
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   209
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   210
        cout << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   211
            << "      Tx rate [KByte/s]:   "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   212
            << setprecision(1) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   213
        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
   214
            cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   215
                << 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
   216
            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
   217
                cout << " ";
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   218
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   219
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   220
        cout << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   221
            << "      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
   222
            << setfill(' ') << setprecision(0) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   223
        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
   224
            cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   225
                << 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
   226
            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
   227
                cout << " ";
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   228
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   229
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   230
        cout << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   231
            << "      Rx rate [KByte/s]:   "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   232
            << setprecision(1) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   233
        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
   234
            cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   235
                << 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
   236
            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
   237
                cout << " ";
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   238
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   239
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   240
        cout << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   241
            << "      Loss rate [1/s]:     "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   242
            << setprecision(0) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   243
        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
   244
            cout << setw(ColWidth)
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   245
                << 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
   246
            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
   247
                cout << " ";
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   248
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   249
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   250
        cout << endl
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   251
            << "      Frame loss [%]:      "
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   252
            << setprecision(1) << fixed;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   253
        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
   254
            double perc = 0.0;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   255
            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
   256
                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
   257
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   258
            cout << setw(ColWidth) << perc;
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   259
            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
   260
                cout << " ";
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   261
            }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   262
        }
69f2b2702336 Adjusted frame statistics for the use with two devices.
Florian Pose <fp@igh-essen.com>
parents: 2156
diff changeset
   263
        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
   264
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   265
        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
   266
            << "    Reference clock: ";
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   267
        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
   268
            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
   269
        } else {
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   270
            cout << "None";
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   271
        }
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   272
        cout << endl
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   273
            << "    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
   274
            << "                      ";
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   275
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   276
        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
   277
        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
   278
                "%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
   279
        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
   280
            << setfill('0') << setw(9) << data.app_time % 1000000000 << endl;
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
    }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
/*****************************************************************************/