lib/sdo_request.c
author Florian Pose <fp@igh-essen.com>
Wed, 19 Sep 2012 22:49:38 +0200
branchstable-1.5
changeset 2430 1430a47a67dd
parent 2428 8a270ea612ee
child 2431 eee9ed9901f7
permissions -rw-r--r--
Minor change.
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006-2009  Florian Pose, Ingenieurgemeinschaft IgH
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
     6
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
     7
 *  This file is part of the IgH EtherCAT master userspace library.
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
     8
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
     9
 *  The IgH EtherCAT master userspace library is free software; you can
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    10
 *  redistribute it and/or modify it under the terms of the GNU Lesser General
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    11
 *  Public License as published by the Free Software Foundation; version 2.1
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    12
 *  of the License.
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    14
 *  The IgH EtherCAT master userspace library is distributed in the hope that
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    15
 *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    16
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    17
 *  GNU Lesser General Public License for more details.
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    19
 *  You should have received a copy of the GNU Lesser General Public License
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    20
 *  along with the IgH EtherCAT master userspace library. If not, see
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    21
 *  <http://www.gnu.org/licenses/>.
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
    22
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    23
 *  ---
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
    24
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    25
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    26
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    27
 *  industrial property and similar rights of Beckhoff Automation GmbH.
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
/** \file
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 * Canopen over EtherCAT SDO request functions.
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
 */
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
/*****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <stdio.h>
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include <errno.h>
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include <string.h>
2428
8a270ea612ee Again fixed some compiler warnings.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    40
#include <sys/ioctl.h>
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "sdo_request.h"
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "master/ioctl.h"
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include "slave_config.h"
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
#include "master.h"
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
1959
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    47
/*****************************************************************************/
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    48
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    49
void ec_sdo_request_clear(ec_sdo_request_t *req)
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    50
{
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    51
    if (req->data) {
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    52
        free(req->data);
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    53
    }
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    54
}
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    55
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
/*****************************************************************************
1959
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    57
 * Application interface.
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
 ****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
void ecrt_sdo_request_timeout(ec_sdo_request_t *req, uint32_t timeout)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
{
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
    ec_ioctl_sdo_request_t data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
    data.config_index = req->config->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
    data.request_index = req->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
    data.timeout = timeout;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
    if (ioctl(req->config->master->fd, EC_IOCTL_SDO_REQUEST_TIMEOUT,
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
                &data) == -1)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
        fprintf(stderr, "Failed to set SDO request timeout: %s\n",
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
                strerror(errno));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
}
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
/*****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
uint8_t *ecrt_sdo_request_data(ec_sdo_request_t *req)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
{
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
    return req->data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
}
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
/*****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
size_t ecrt_sdo_request_data_size(const ec_sdo_request_t *req)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
{
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
    return req->data_size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
}
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
/*****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
ec_request_state_t ecrt_sdo_request_state(ec_sdo_request_t *req)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
{
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
    ec_ioctl_sdo_request_t data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
    data.config_index = req->config->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
    data.request_index = req->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
    if (ioctl(req->config->master->fd, EC_IOCTL_SDO_REQUEST_STATE,
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
                &data) == -1)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
        fprintf(stderr, "Failed to get SDO request state: %s\n",
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
                strerror(errno));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
    if (data.size) { // new data waiting to be copied
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
        if (req->mem_size < data.size) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
            if (req->data)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
                free(req->data);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
            req->data = malloc(data.size);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
            if (!req->data) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
                req->mem_size = 0;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
                fprintf(stderr, "Failed to allocate %u bytes of SDO data"
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
                        " memory!\n", data.size);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
                return EC_REQUEST_ERROR;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
            }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
            req->mem_size = data.size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
        }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
        data.data = req->data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
        if (ioctl(req->config->master->fd, EC_IOCTL_SDO_REQUEST_DATA,
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
                    &data) == -1) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
            fprintf(stderr, "Failed to get SDO data: %s\n", strerror(errno));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
            return EC_REQUEST_ERROR;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
        }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
        req->data_size = data.size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
    }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
    return data.state;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
}
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
/*****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
void ecrt_sdo_request_read(ec_sdo_request_t *req)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
{
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
    ec_ioctl_sdo_request_t data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
    data.config_index = req->config->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
    data.request_index = req->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
    if (ioctl(req->config->master->fd, EC_IOCTL_SDO_REQUEST_READ,
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
                &data) == -1)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
        fprintf(stderr, "Failed to command an SDO read operation : %s\n",
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
                strerror(errno));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
}
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
/*****************************************************************************/
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
void ecrt_sdo_request_write(ec_sdo_request_t *req)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
{
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
    ec_ioctl_sdo_request_t data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
    data.config_index = req->config->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
    data.request_index = req->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
    data.data = req->data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
    data.size = req->data_size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
    if (ioctl(req->config->master->fd, EC_IOCTL_SDO_REQUEST_WRITE,
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
                &data) == -1)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
        fprintf(stderr, "Failed to command an SDO write operation : %s\n",
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
                strerror(errno));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
}
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/*****************************************************************************/