tool/CommandSoeWrite.cpp
author Florian Pose <fp@igh-essen.com>
Fri, 19 Mar 2010 12:41:32 +0100
changeset 1880 f46bec1b5f21
parent 1877 7b77000f9764
child 1953 968a531e5a89
permissions -rw-r--r--
Removed tabs.
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006-2009  Florian Pose, Ingenieurgemeinschaft IgH
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
 *  published by the Free Software Foundation.
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  Public License for more details.
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *  ---
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 ****************************************************************************/
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#include <iostream>
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
using namespace std;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include "CommandSoeWrite.h"
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include "MasterDevice.h"
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
/*****************************************************************************/
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
CommandSoeWrite::CommandSoeWrite():
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    39
    SoeCommand("soe_write", "Write an SoE IDN to a slave.")
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
{
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
}
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
/*****************************************************************************/
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
string CommandSoeWrite::helpString() const
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
{
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
    stringstream str;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    49
    str << getName() << " [OPTIONS] <IDN> <VALUE>" << endl
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
        << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
        << getBriefDescription() << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
        << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
        << "This command requires a single slave to be selected." << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
        << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
        << "Arguments:" << endl
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    56
        << "  IDN      is the IDN and must be either an unsigned" << endl
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    57
        << "           16 bit number acc. to IEC 61800-7-204:" << endl
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    58
        << "             Bit 15: (0) Standard data, (1) Product data" << endl
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    59
        << "             Bit 14 - 12: Parameter set (0 - 7)" << endl
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    60
        << "             Bit 11 - 0: Data block number" << endl
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    61
        << "           or a string like 'P-0-150'." << endl
1872
23d4e121faaf Improved SoE command help.
Florian Pose <fp@igh-essen.com>
parents: 1870
diff changeset
    62
        << "  VALUE    is the value to write (see below)." << endl
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    63
		<< endl
1872
23d4e121faaf Improved SoE command help.
Florian Pose <fp@igh-essen.com>
parents: 1870
diff changeset
    64
        << "The VALUE argument is interpreted as the given data type" << endl
23d4e121faaf Improved SoE command help.
Florian Pose <fp@igh-essen.com>
parents: 1870
diff changeset
    65
		<< "(--type is mandatory) and written to the selected slave." << endl
23d4e121faaf Improved SoE command help.
Florian Pose <fp@igh-essen.com>
parents: 1870
diff changeset
    66
        << endl
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    67
		<< typeInfo()
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
        << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
        << "Command-specific options:" << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
        << "  --alias    -a <alias>" << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        << "  --position -p <pos>    Slave selection. See the help of" << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
        << "                         the 'slaves' command." << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
        << "  --type     -t <type>   Data type (see above)." << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
        << endl
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
        << numericInfo();
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
    return str.str();
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
}
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
/****************************************************************************/
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
void CommandSoeWrite::execute(const StringVector &args)
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
{
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    stringstream strIdn, err;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
    const DataType *dataType = NULL;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
    ec_ioctl_slave_soe_write_t ioctl;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
    SlaveList slaves;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
    size_t memSize;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
    if (args.size() != 2) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
        err << "'" << getName() << "' takes 2 arguments!";
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
        throwInvalidUsageException(err);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
1868
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    95
    try {
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    96
        ioctl.idn = parseIdn(args[0]);
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    97
    } catch (runtime_error &e) {
489ea0becd74 Implemented SoE IDN parser for strings like 'P-0-0150'; moved data type
Florian Pose <fp@igh-essen.com>
parents: 1867
diff changeset
    98
        err << "Invalid IDN '" << args[0] << "': " << e.what();
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
        throwInvalidUsageException(err);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
1870
0cee1fb7f0fd Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents: 1869
diff changeset
   102
    MasterDevice m(getSingleMasterIndex());
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
    m.open(MasterDevice::ReadWrite);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
    slaves = selectedSlaves(m);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
    if (slaves.size() != 1) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
        throwSingleSlaveRequired(slaves.size());
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
    ioctl.slave_position = slaves.front().position;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
    if (!getDataType().empty()) { // data type specified
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
        if (!(dataType = findDataType(getDataType()))) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
            err << "Invalid data type '" << getDataType() << "'!";
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
            throwInvalidUsageException(err);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
        }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
    } else { // no data type specified
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
        err << "Please specify a data type.";
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
        throwInvalidUsageException(err); // FIXME read from stream
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
    if (dataType->byteSize) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
        memSize = dataType->byteSize;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
    } else {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
        // guess string type size
1867
fec951a0a654 Fixed string argument for soe_write.
Florian Pose <fp@igh-essen.com>
parents: 1837
diff changeset
   124
        memSize = args[1].size() + 1;
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
        if (!memSize) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
            err << "Empty argument not allowed.";
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
            throwInvalidUsageException(err);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
        }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
1867
fec951a0a654 Fixed string argument for soe_write.
Florian Pose <fp@igh-essen.com>
parents: 1837
diff changeset
   131
    ioctl.data = new uint8_t[memSize];
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
    try {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
        ioctl.data_size = interpretAsType(
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
                dataType, args[1], ioctl.data, memSize);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
    } catch (SizeException &e) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
        delete [] ioctl.data;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
        throwCommandException(e.what());
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
    } catch (ios::failure &e) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
        delete [] ioctl.data;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
        err << "Invalid value argument '" << args[1]
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
            << "' for type '" << dataType->name << "'!";
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
        throwInvalidUsageException(err);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
    try {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
        m.writeSoe(&ioctl);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
    } catch (MasterDeviceSoeException &e) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
        delete [] ioctl.data;
1877
7b77000f9764 Included list of common SoE error messages.
Florian Pose <fp@igh-essen.com>
parents: 1872
diff changeset
   150
        err << "SoE write command failed with code " << errorMsg(e.errorCode);
1837
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
        throwCommandException(err);
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
    } catch (MasterDeviceException &e) {
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
        delete [] ioctl.data;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
        throw e;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
    }
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
    delete [] ioctl.data;
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
}
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
32136215c1fa Implemented SoE write state machine and soe_write command.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
/*****************************************************************************/