tool/CommandRegRead.cpp
author Florian Pose <fp@igh-essen.com>
Tue, 20 Nov 2012 13:23:21 +0100
branchstable-1.5
changeset 2444 4b43c90142c8
parent 2443 2c3ccdde3919
child 2529 c7e1f2616a9d
permissions -rw-r--r--
Fixed typos in doc.
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
     3
 *  $Id$
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
     4
 *
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
     5
 *  Copyright (C) 2006-2012  Florian Pose, Ingenieurgemeinschaft IgH
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
     6
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
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: 1200
diff changeset
     8
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
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: 1200
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: 1200
diff changeset
    11
 *  published by the Free Software Foundation.
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
    12
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
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: 1200
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: 1200
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: 1200
diff changeset
    16
 *  Public License for more details.
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
    17
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
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: 1200
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: 1200
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: 1200
diff changeset
    21
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1200
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: 1200
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: 1200
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 ****************************************************************************/
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#include <iostream>
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <iomanip>
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
using namespace std;
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
1388
3c886ec376f5 Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents: 1387
diff changeset
    34
#include "CommandRegRead.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"
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
/*****************************************************************************/
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
1388
3c886ec376f5 Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents: 1387
diff changeset
    39
CommandRegRead::CommandRegRead():
1835
20748e9d2238 Sourced out data type handling into an own class.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
    40
    Command("reg_read", "Output a slave's register contents.")
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
{
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
}
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
/*****************************************************************************/
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
1968
4f682084c643 Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents: 1870
diff changeset
    46
string CommandRegRead::helpString(const string &binaryBaseName) const
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
{
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
    stringstream str;
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
1968
4f682084c643 Implemented drive_no for command-line tool; binary base name is now a
Florian Pose <fp@igh-essen.com>
parents: 1870
diff changeset
    50
    str << binaryBaseName << " " << getName()
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    51
        << " [OPTIONS] <ADDRESS> [SIZE]" << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    52
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    53
        << getBriefDescription() << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    54
        << endl
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
        << "This command requires a single slave to be selected." << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    56
        << endl
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
        << "Arguments:" << endl
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    58
        << "  ADDRESS is the register address. Must" << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    59
        << "          be an unsigned 16 bit number." << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    60
        << "  SIZE    is the number of bytes to read and must also be" << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    61
        << "          an unsigned 16 bit number. ADDRESS plus SIZE" << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    62
        << "          may not exceed 64k. The size is ignored (and" << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    63
        << "          can be omitted), if a selected data type" << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    64
        << "          implies a size." << endl
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    65
        << endl
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1835
diff changeset
    66
        << typeInfo()
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
        << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    68
        << "Command-specific options:" << endl
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
        << "  --alias    -a <alias>" << endl
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
        << "  --position -p <pos>    Slave selection. See the help of" << endl
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        << "                         the 'slaves' command." << endl
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    72
        << "  --type     -t <type>   Data type (see above)." << endl
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    73
        << endl
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    74
        << numericInfo();
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    75
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
    76
    return str.str();
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
}
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
/****************************************************************************/
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
1826
ec6223c3b7ec Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents: 1804
diff changeset
    81
void CommandRegRead::execute(const StringVector &args)
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
{
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
    SlaveList slaves;
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    84
    ec_ioctl_slave_reg_t io;
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    85
    stringstream strOffset, err;
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    86
    const DataType *dataType = NULL;
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    87
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    88
    if (args.size() < 1 || args.size() > 2) {
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    89
        err << "'" << getName() << "' takes one or two arguments!";
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
        throwInvalidUsageException(err);
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
    }
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
    strOffset << args[0];
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
    strOffset
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
        >> resetiosflags(ios::basefield) // guess base from prefix
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    96
        >> io.address;
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
    if (strOffset.fail()) {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    98
        err << "Invalid address '" << args[0] << "'!";
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
        throwInvalidUsageException(err);
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
    }
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   102
    if (args.size() > 1) {
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   103
        stringstream strLength;
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   104
        strLength << args[1];
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   105
        strLength
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   106
            >> resetiosflags(ios::basefield) // guess base from prefix
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   107
            >> io.size;
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   108
        if (strLength.fail()) {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   109
            err << "Invalid size '" << args[1] << "'!";
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   110
            throwInvalidUsageException(err);
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   111
        }
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   112
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   113
        if (!io.size) {
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   114
            err << "Length may not be zero!";
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   115
            throwInvalidUsageException(err);
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   116
        }
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   117
    } else { // no size argument given
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   118
        io.size = 0;
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   119
    }
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   120
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   121
    if (!getDataType().empty()) {
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   122
        if (!(dataType = findDataType(getDataType()))) {
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   123
            err << "Invalid data type '" << getDataType() << "'!";
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   124
            throwInvalidUsageException(err);
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   125
        }
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   126
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   127
        if (dataType->byteSize) {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   128
            // override size argument
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   129
            io.size = dataType->byteSize;
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   130
        }
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
    }
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   133
    if (!io.size) {
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   134
        err << "The size argument is mandatory, if no datatype is " << endl
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   135
            << "specified, or the datatype does not imply a size!";
1387
57020c731092 Data types for phy_read.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   136
        throwInvalidUsageException(err);
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
    }
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   139
    if ((uint32_t) io.address + io.size > 0xffff) {
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   140
        err << "Address and size exceeding 64k!";
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
        throwInvalidUsageException(err);
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
    }
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1968
diff changeset
   143
1870
0cee1fb7f0fd Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents: 1869
diff changeset
   144
    MasterDevice m(getSingleMasterIndex());
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
    m.open(MasterDevice::Read);
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
    slaves = selectedSlaves(m);
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
    if (slaves.size() != 1) {
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
        throwSingleSlaveRequired(slaves.size());
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
    }
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   151
    io.slave_position = slaves.front().position;
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   153
    io.data = new uint8_t[io.size];
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
   155
    try {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   156
        m.readReg(&io);
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
   157
    } catch (MasterDeviceException &e) {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   158
        delete [] io.data;
1804
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
   159
        throw e;
742607c464c4 Removed tabulators.
Florian Pose <fp@igh-essen.com>
parents: 1431
diff changeset
   160
    }
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
1835
20748e9d2238 Sourced out data type handling into an own class.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   162
    try {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   163
        outputData(cout, dataType, io.data, io.size);
1835
20748e9d2238 Sourced out data type handling into an own class.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   164
    } catch (SizeException &e) {
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   165
        delete [] io.data;
1835
20748e9d2238 Sourced out data type handling into an own class.
Florian Pose <fp@igh-essen.com>
parents: 1826
diff changeset
   166
        throwCommandException(e.what());
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
    }
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
2443
2c3ccdde3919 Added interface to read/write register contents; re-worked register requests.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   169
    delete [] io.data;
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
}
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
/*****************************************************************************/