tool/CommandPdos.cpp
author Florian Pose <fp@igh-essen.com>
Tue, 12 Feb 2013 15:30:34 +0100
branchstable-1.5
changeset 2521 3d68bb0047a1
parent 2436 960cc1bb6b4a
permissions -rw-r--r--
Removed unused prototype.
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: 1327
diff changeset
     3
 *  $Id$
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
     4
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
     5
 *  Copyright (C) 2006-2009  Florian Pose, Ingenieurgemeinschaft IgH
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
     6
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
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: 1327
diff changeset
     8
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
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: 1327
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: 1327
diff changeset
    11
 *  published by the Free Software Foundation.
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    12
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
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: 1327
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: 1327
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: 1327
diff changeset
    16
 *  Public License for more details.
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    17
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
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: 1327
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: 1327
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: 1327
diff changeset
    21
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
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: 1327
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: 1327
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>
2436
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    32
#include <cstring>
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
using namespace std;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include "CommandPdos.h"
1826
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
    36
#include "MasterDevice.h"
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
/*****************************************************************************/
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
CommandPdos::CommandPdos():
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1187
diff changeset
    41
    Command("pdos", "List Sync managers, PDO assignment and mapping.")
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
{
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
1968
4f682084c643 Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents: 1869
diff changeset
    47
string CommandPdos::helpString(const string &binaryBaseName) const
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
{
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
    stringstream str;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
1968
4f682084c643 Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents: 1869
diff changeset
    51
    str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
        << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    53
        << getBriefDescription() << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    54
        << endl
2436
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    55
        << "For the default skin (see --skin option) the information" << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    56
        << "is displayed in three layers, which are" << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    57
        << "indented accordingly:" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    58
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    59
        << "1) Sync managers - Contains the sync manager information" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    60
        << "   from the SII: Index, physical start address, default" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    61
        << "   size, control register and enable word. Example:" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    62
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    63
        << "   SM3: PhysAddr 0x1100, DefaultSize 0, ControlRegister 0x20, "
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    64
        << "Enable 1" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    65
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    66
        << "2) Assigned PDOs - PDO direction, hexadecimal index and" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    67
        << "   the PDO name, if avaliable. Note that a 'Tx' and 'Rx'" << endl
1144
7dbfdd61812c Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents: 1142
diff changeset
    68
        << "   are seen from the slave's point of view. Example:" << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    69
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    70
        << "   TxPDO 0x1a00 \"Channel1\"" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    71
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    72
        << "3) Mapped PDO entries - PDO entry index and subindex (both" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    73
        << "   hexadecimal), the length in bit and the description, if" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    74
        << "   available. Example:" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    75
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    76
        << "   PDO entry 0x3101:01, 8 bit, \"Status\"" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    77
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    78
        << "Note, that the displayed PDO assignment and PDO mapping" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    79
        << "information can either originate from the SII or from the" << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    80
        << "CoE communication area." << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    81
        << endl
2436
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    82
        << "The \"etherlab\" skin outputs a template configuration" << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    83
        << "for EtherLab's generic EtherCAT slave block." << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    84
        << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    85
        << "Command-specific options:" << endl
1157
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    86
        << "  --alias    -a <alias>" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    87
        << "  --position -p <pos>    Slave selection. See the help of" << endl
04d1c950cf9d Added --help for alias and position parameters.
Florian Pose <fp@igh-essen.com>
parents: 1151
diff changeset
    88
        << "                         the 'slaves' command." << endl
2436
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    89
        << "  --skin     -s <skin>   Choose output skin. Possible values are"
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    90
        << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    91
        << "                         \"default\" and \"etherlab\"." << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    92
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    93
        << numericInfo();
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
    95
    return str.str();
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
1826
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   100
void CommandPdos::execute(const StringVector &args)
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
{
1869
14f634f5b613 Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents: 1827
diff changeset
   102
	MasterIndexList masterIndices;
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1144
diff changeset
   103
    SlaveList slaves;
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1144
diff changeset
   104
    SlaveList::const_iterator si;
1826
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   105
    bool showHeader, multiMaster;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1968
diff changeset
   106
1373
e651000f1ff1 Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   107
    if (args.size()) {
e651000f1ff1 Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   108
        stringstream err;
e651000f1ff1 Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   109
        err << "'" << getName() << "' takes no arguments!";
e651000f1ff1 Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   110
        throwInvalidUsageException(err);
e651000f1ff1 Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   111
    }
e651000f1ff1 Complain about given arguments if none are required.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   112
2436
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   113
    if (getSkin().empty() || getSkin() == "default") {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   114
        masterIndices = getMasterIndices();
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   115
        multiMaster = masterIndices.size() > 1;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   116
        MasterIndexList::const_iterator mi;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   117
        for (mi = masterIndices.begin();
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   118
                mi != masterIndices.end(); mi++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   119
            MasterDevice m(*mi);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   120
            m.open(MasterDevice::Read);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   121
            slaves = selectedSlaves(m);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   122
            showHeader = multiMaster || slaves.size() > 1;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   123
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   124
            for (si = slaves.begin(); si != slaves.end(); si++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   125
                listSlavePdos(m, *si, showHeader);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   126
            }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   127
        }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   128
    }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   129
    else if (getSkin() == "etherlab") {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   130
        masterIndices = getMasterIndices();
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   131
        MasterIndexList::const_iterator mi;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   132
        for (mi = masterIndices.begin();
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   133
                mi != masterIndices.end(); mi++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   134
            MasterDevice m(*mi);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   135
            m.open(MasterDevice::Read);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   136
            slaves = selectedSlaves(m);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   137
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   138
            for (si = slaves.begin(); si != slaves.end(); si++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   139
                etherlabConfig(m, *si);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   140
            }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   141
        }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   142
    }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   143
    else {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   144
        stringstream err;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   145
        err << "Invalid skin '" << getSkin() << "'!";
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   146
        throwInvalidUsageException(err);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
    }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
/****************************************************************************/
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
void CommandPdos::listSlavePdos(
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
   153
        MasterDevice &m,
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1144
diff changeset
   154
        const ec_ioctl_slave_t &slave,
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
   155
        bool showHeader
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1373
diff changeset
   156
        )
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
{
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
    ec_ioctl_slave_sync_t sync;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
    ec_ioctl_slave_sync_pdo_t pdo;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
    ec_ioctl_slave_sync_pdo_entry_t entry;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
    unsigned int i, j, k;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1968
diff changeset
   162
1827
489be2180f71 Improved multi-master capabilities of ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   163
    if (showHeader && slave.sync_count)
1826
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   164
        cout << "=== Master " << m.getIndex()
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
   165
            << ", Slave " << slave.position << " ===" << endl;
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
    for (i = 0; i < slave.sync_count; i++) {
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1144
diff changeset
   168
        m.getSync(&sync, slave.position, i);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
        cout << "SM" << i << ":"
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
            << " PhysAddr 0x"
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
            << hex << setfill('0')
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
            << setw(4) << sync.physical_start_address
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
            << ", DefaultSize "
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
            << dec << setfill(' ') << setw(4) << sync.default_size
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
            << ", ControlRegister 0x"
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
            << hex << setfill('0') << setw(2)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
            << (unsigned int) sync.control_register
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
            << ", Enable " << dec << (unsigned int) sync.enable
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
            << endl;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
        for (j = 0; j < sync.pdo_count; j++) {
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1144
diff changeset
   183
            m.getPdo(&pdo, slave.position, i, j);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
            cout << "  " << (sync.control_register & 0x04 ? "R" : "T")
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1187
diff changeset
   186
                << "xPDO 0x"
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
                << hex << setfill('0')
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
                << setw(4) << pdo.index
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
                << " \"" << pdo.name << "\"" << endl;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
            if (getVerbosity() == Quiet)
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
                continue;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
            for (k = 0; k < pdo.entry_count; k++) {
1151
1fc1535dec29 Alias/Position selection.
Florian Pose <fp@igh-essen.com>
parents: 1144
diff changeset
   195
                m.getPdoEntry(&entry, slave.position, i, j, k);
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1187
diff changeset
   197
                cout << "    PDO entry 0x"
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
                    << hex << setfill('0')
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
                    << setw(4) << entry.index
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
                    << ":" << setw(2) << (unsigned int) entry.subindex
1187
aa616c3286ce Show Pdo bit lengths right-aligned.
Florian Pose <fp@igh-essen.com>
parents: 1167
diff changeset
   201
                    << ", " << dec << setfill(' ')
aa616c3286ce Show Pdo bit lengths right-aligned.
Florian Pose <fp@igh-essen.com>
parents: 1167
diff changeset
   202
                    << setw(2) << (unsigned int) entry.bit_length
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
                    << " bit, \"" << entry.name << "\"" << endl;
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
            }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
        }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
    }
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
}
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
2436
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   209
/****************************************************************************/
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   210
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   211
void CommandPdos::etherlabConfig(
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   212
        MasterDevice &m,
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   213
        const ec_ioctl_slave_t &slave
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   214
        )
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   215
{
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   216
    ec_ioctl_slave_sync_t sync;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   217
    ec_ioctl_slave_sync_pdo_t pdo;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   218
    ec_ioctl_slave_sync_pdo_entry_t entry;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   219
    unsigned int i, j, k;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   220
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   221
    cout << "%" << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   222
        << "% Master " << m.getIndex() << ", Slave " << slave.position;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   223
    if (strlen(slave.order)) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   224
        cout << ", \"" << slave.order << "\"";
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   225
    }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   226
    cout << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   227
        << "%" << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   228
        << "function rv = slave" << slave.position << "()" << endl << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   229
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   230
    cout << "% Slave configuration" << endl << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   231
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   232
    cout << "rv.SlaveConfig.vendor = " << slave.vendor_id << ";" << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   233
        << "rv.SlaveConfig.product = hex2dec('"
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   234
        << hex << setfill('0') << setw(8) << slave.product_code << "');"
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   235
        << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   236
        << "rv.SlaveConfig.description = '" << slave.order << "';" << endl
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   237
        << "rv.SlaveConfig.sm = { ..." << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   238
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   239
    /* slave configuration */
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   240
    for (i = 0; i < slave.sync_count; i++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   241
        m.getSync(&sync, slave.position, i);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   242
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   243
        cout << "    {" << dec << i << ", "
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   244
            << (sync.control_register & 0x04 ? 0 : 1) << ", {" << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   245
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   246
        for (j = 0; j < sync.pdo_count; j++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   247
            m.getPdo(&pdo, slave.position, i, j);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   248
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   249
            cout << "        {hex2dec('" <<
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   250
                hex << setfill('0') << setw(4) << pdo.index << "'), ["
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   251
                << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   252
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   253
            for (k = 0; k < pdo.entry_count; k++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   254
                m.getPdoEntry(&entry, slave.position, i, j, k);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   255
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   256
                cout << "            hex2dec('"
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   257
                    << hex << setfill('0') << setw(4) << entry.index
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   258
                    << "'), hex2dec('"
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   259
                    << setw(2) << (unsigned int) entry.subindex
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   260
                    << "'), " << dec << setfill(' ') << setw(3)
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   261
                    << (unsigned int) entry.bit_length
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   262
                    << "; ..." << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   263
            }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   264
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   265
            cout << "            ]}, ..." << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   266
        }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   267
        cout << "        }}, ..." << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   268
    }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   269
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   270
    cout << "    };" << endl << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   271
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   272
    cout << "% Port configuration" << endl << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   273
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   274
    unsigned int input = 1, output = 1;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   275
    for (i = 0; i < slave.sync_count; i++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   276
        m.getSync(&sync, slave.position, i);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   277
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   278
        for (j = 0; j < sync.pdo_count; j++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   279
            m.getPdo(&pdo, slave.position, i, j);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   280
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   281
            for (k = 0; k < pdo.entry_count; k++) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   282
                m.getPdoEntry(&entry, slave.position, i, j, k);
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   283
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   284
                if (!entry.index) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   285
                    continue;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   286
                }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   287
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   288
                string dir;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   289
                unsigned int port;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   290
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   291
                if (sync.control_register & 0x04) {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   292
                    dir = "input";
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   293
                    port = input++;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   294
                }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   295
                else {
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   296
                    dir = "output";
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   297
                    port = output++;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   298
                }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   299
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   300
                stringstream var;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   301
                var << "rv.PortConfig." << dir << "(" << dec << port
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   302
                    << ")";
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   303
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   304
                cout << var.str() << ".pdo = ["
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   305
                    << i << ", " << j << ", " << k << ", 0];" << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   306
                cout << var.str() << ".pdo_data_type = "
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   307
                    << 1000 + (unsigned int) entry.bit_length
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   308
                    << ";" << endl << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   309
            }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   310
        }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   311
    }
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   312
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   313
    cout << "end" << endl;
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   314
}
960cc1bb6b4a EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   315
1142
59be91dfcbe1 Redesigned command interface.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
/*****************************************************************************/