lib/slave_config.c
author Florian Pose <fp@igh-essen.com>
Mon, 04 May 2009 12:11:00 +0000
changeset 1436 08eaf72409bb
parent 1413 44c2b7c0ae1a
child 1438 1d30b96bb04f
permissions -rw-r--r--
Use application start time as a common reference for cyclic generation
start times.
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
1266
dd1f501c4070 Added LGPL licence headers to userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1264
diff changeset
     2
 *  
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     3
 *  $Id$
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     4
 *  
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     5
 *  Copyright (C) 2006-2009  Florian Pose, Ingenieurgemeinschaft IgH
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     6
 *  
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     7
 *  This file is part of the IgH EtherCAT master userspace library.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     8
 *  
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
     9
 *  The IgH EtherCAT master userspace library is free software; you can
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    10
 *  redistribute it and/or modify it under the terms of the GNU Lesser General
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    11
 *  Public License as published by the Free Software Foundation; version 2.1
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    12
 *  of the License.
1287
cc7b679c74e9 Improved LGPL headers.
Florian Pose <fp@igh-essen.com>
parents: 1266
diff changeset
    13
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    14
 *  The IgH EtherCAT master userspace library is distributed in the hope that
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    15
 *  it will be useful, but WITHOUT ANY WARRANTY; without even the implied
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    16
 *  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    17
 *  GNU Lesser General Public License for more details.
1287
cc7b679c74e9 Improved LGPL headers.
Florian Pose <fp@igh-essen.com>
parents: 1266
diff changeset
    18
 *
1326
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    19
 *  You should have received a copy of the GNU Lesser General Public License
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    20
 *  along with the IgH EtherCAT master userspace library. If not, see
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    21
 *  <http://www.gnu.org/licenses/>.
ef907b0b5125 merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents: 1313
diff changeset
    22
 *  
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    23
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1352
diff changeset
    24
 *  
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.
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
 *****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <stdlib.h>
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <sys/ioctl.h>
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include <stdio.h>
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include <errno.h>
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <string.h>
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include "slave_config.h"
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#include "domain.h"
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    39
#include "sdo_request.h"
1264
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
    40
#include "voe_handler.h"
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#include "master.h"
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include "master/ioctl.h"
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
int ecrt_slave_config_sync_manager(ec_slave_config_t *sc, uint8_t sync_index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
        ec_direction_t dir)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
    ec_ioctl_config_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
    unsigned int i;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
    if (sync_index >= EC_MAX_SYNC_MANAGERS)
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
    53
        return -ENOENT;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
    memset(&data, 0x00, sizeof(ec_ioctl_config_t));
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
    data.syncs[sync_index].dir = dir;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
    if (ioctl(sc->master->fd, EC_IOCTL_SC_SYNC, &data) == -1) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
        fprintf(stderr, "Failed to config sync manager: %s\n",
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
                strerror(errno));
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
    62
        return -1; // FIXME
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
    
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
    return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
int ecrt_slave_config_pdo_assign_add(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        uint8_t sync_index, uint16_t pdo_index)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
    ec_ioctl_config_pdo_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
    data.sync_index = sync_index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
    data.index = pdo_index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
    if (ioctl(sc->master->fd, EC_IOCTL_SC_ADD_PDO, &data) == -1) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    80
        fprintf(stderr, "Failed to add PDO: %s\n",
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
                strerror(errno));
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
    82
        return -1;  // FIXME
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
    
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
    return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
void ecrt_slave_config_pdo_assign_clear(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
        uint8_t sync_index)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
    ec_ioctl_config_pdo_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
    data.sync_index = sync_index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
    if (ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_PDOS, &data) == -1) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    99
        fprintf(stderr, "Failed to clear PDOs: %s\n",
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
                strerror(errno));
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
int ecrt_slave_config_pdo_mapping_add(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
        uint16_t pdo_index, uint16_t entry_index, uint8_t entry_subindex,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
        uint8_t entry_bit_length)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
    ec_ioctl_add_pdo_entry_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
    data.pdo_index = pdo_index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
    data.entry_index = entry_index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
    data.entry_subindex = entry_subindex;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
    data.entry_bit_length = entry_bit_length;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
    if (ioctl(sc->master->fd, EC_IOCTL_SC_ADD_ENTRY, &data) == -1) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   119
        fprintf(stderr, "Failed to add PDO entry: %s\n",
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
                strerror(errno));
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   121
        return -1;  // FIXME
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
    
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
    return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
void ecrt_slave_config_pdo_mapping_clear(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
        uint16_t pdo_index)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
    ec_ioctl_config_pdo_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
    data.index = pdo_index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
    if (ioctl(sc->master->fd, EC_IOCTL_SC_CLEAR_ENTRIES, &data) == -1) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   138
        fprintf(stderr, "Failed to clear PDO entries: %s\n",
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
                strerror(errno));
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
int ecrt_slave_config_pdos(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
        unsigned int n_syncs, const ec_sync_info_t syncs[])
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
{
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   148
    int ret;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
    unsigned int i, j, k;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
    const ec_sync_info_t *sync_info;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
    const ec_pdo_info_t *pdo_info;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
    const ec_pdo_entry_info_t *entry_info;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
    if (!syncs)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
        return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
    for (i = 0; i < n_syncs; i++) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
        sync_info = &syncs[i];
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
        if (sync_info->index == (uint8_t) EC_END)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
            break;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
        if (sync_info->index >= EC_MAX_SYNC_MANAGERS) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
            fprintf(stderr, "Invalid sync manager index %u!\n",
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
                    sync_info->index);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   166
            return -ENOENT;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
        }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   169
        ret = ecrt_slave_config_sync_manager(
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   170
                sc, sync_info->index, sync_info->dir);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   171
        if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   172
            return ret;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
        if (sync_info->n_pdos && sync_info->pdos) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
            ecrt_slave_config_pdo_assign_clear(sc, sync_info->index);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
            for (j = 0; j < sync_info->n_pdos; j++) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
                pdo_info = &sync_info->pdos[j];
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   180
                ret = ecrt_slave_config_pdo_assign_add(
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   181
                        sc, sync_info->index, pdo_info->index);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   182
                if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   183
                    return ret;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
                if (pdo_info->n_entries && pdo_info->entries) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
                    ecrt_slave_config_pdo_mapping_clear(sc, pdo_info->index);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
                    for (k = 0; k < pdo_info->n_entries; k++) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
                        entry_info = &pdo_info->entries[k];
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   191
                        ret = ecrt_slave_config_pdo_mapping_add(sc,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   192
                                pdo_info->index, entry_info->index,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   193
                                entry_info->subindex,
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   194
                                entry_info->bit_length);
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   195
                        if (ret)
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   196
                            return ret;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
                    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
                }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
            }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
        }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
    return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
int ecrt_slave_config_reg_pdo_entry(
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
        ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
        uint16_t index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
        uint8_t subindex,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
        ec_domain_t *domain,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
        unsigned int *bit_position
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
        )
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
    ec_ioctl_reg_pdo_entry_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
    int ret;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
    data.entry_index = index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
    data.entry_subindex = subindex;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
    data.domain_index = domain->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
    ret = ioctl(sc->master->fd, EC_IOCTL_SC_REG_PDO_ENTRY, &data);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
    if (ret == -1) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   226
        fprintf(stderr, "Failed to register PDO entry: %s\n",
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
                strerror(errno));
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   228
        return -2; // FIXME
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
    if (bit_position) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
        *bit_position = data.bit_position;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
    } else {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
        if (data.bit_position) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   235
            fprintf(stderr, "PDO entry 0x%04X:%02X does not byte-align "
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
                    "in config %u:%u.\n", index, subindex,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
                    sc->alias, sc->position);
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   238
            return -3; // FIXME
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
        }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
    return ret;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
1413
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   247
void ecrt_slave_config_dc_assign_activate(ec_slave_config_t *sc,
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   248
        uint16_t assign_activate)
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   249
{
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   250
    ec_ioctl_sc_dc_t data;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   251
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   252
    data.config_index = sc->index;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   253
    data.assign_activate = assign_activate;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   254
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   255
    if (ioctl(sc->master->fd, EC_IOCTL_SC_DC_ASSIGN, &data) == -1) {
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   256
        fprintf(stderr, "Failed to set assign_activate word.\n");
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   257
    }
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   258
}
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   259
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   260
/*****************************************************************************/
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   261
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   262
void ecrt_slave_config_dc_sync_cycle_times(ec_slave_config_t *sc,
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   263
        uint32_t sync0_cycle_time, uint32_t sync1_cycle_time)
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   264
{
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   265
    ec_ioctl_sc_dc_t data;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   266
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   267
    data.config_index = sc->index;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   268
	data.cycle[0] = sync0_cycle_time;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   269
	data.cycle[1] = sync1_cycle_time;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   270
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   271
    if (ioctl(sc->master->fd, EC_IOCTL_SC_DC_CYCLE, &data) == -1) {
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   272
        fprintf(stderr, "Failed to set assign_activate word.\n");
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   273
    }
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   274
}
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   275
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   276
/*****************************************************************************/
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   277
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   278
void ecrt_slave_config_dc_sync_shift_times(ec_slave_config_t *sc,
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   279
        uint32_t sync0_shift_time, uint32_t sync1_shift_time)
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   280
{
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   281
    ec_ioctl_sc_dc_t data;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   282
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   283
    data.config_index = sc->index;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   284
	data.shift[0] = sync0_shift_time;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   285
	data.shift[1] = sync1_shift_time;
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   286
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   287
    if (ioctl(sc->master->fd, EC_IOCTL_SC_DC_SHIFT, &data) == -1) {
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   288
        fprintf(stderr, "Failed to set assign_activate word.\n");
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   289
    }
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   290
}
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   291
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   292
/*****************************************************************************/
44c2b7c0ae1a Userspace library implementation of DC functions.
Florian Pose <fp@igh-essen.com>
parents: 1371
diff changeset
   293
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
int ecrt_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
        uint8_t subindex, const uint8_t *sdo_data, size_t size)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
    ec_ioctl_sc_sdo_t data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
    data.config_index = sc->index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
    data.index = index;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
    data.subindex = subindex;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
    data.data = sdo_data;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
    data.size = size;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
1371
00e2975dc17b Fixed SDO configuration via library.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
   305
    if (ioctl(sc->master->fd, EC_IOCTL_SC_SDO, &data) == -1) {
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
   306
        fprintf(stderr, "Failed to configure SDO.\n");
1313
ed15eef57d5c Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents: 1287
diff changeset
   307
        return -1; // FIXME
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
    }
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
    return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
int ecrt_slave_config_sdo8(ec_slave_config_t *sc, uint16_t index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
        uint8_t subindex, uint8_t value)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
    uint8_t data[1];
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
    EC_WRITE_U8(data, value);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
    return ecrt_slave_config_sdo(sc, index, subindex, data, 1);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
int ecrt_slave_config_sdo16(ec_slave_config_t *sc, uint16_t index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
        uint8_t subindex, uint16_t value)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
    uint8_t data[2];
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
    EC_WRITE_U16(data, value);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
    return ecrt_slave_config_sdo(sc, index, subindex, data, 2);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
int ecrt_slave_config_sdo32(ec_slave_config_t *sc, uint16_t index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
        uint8_t subindex, uint32_t value)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
    uint8_t data[4];
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
    EC_WRITE_U32(data, value);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
    return ecrt_slave_config_sdo(sc, index, subindex, data, 4);
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
ec_sdo_request_t *ecrt_slave_config_create_sdo_request(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
        uint16_t index, uint8_t subindex, size_t size)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
{
1352
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   351
    ec_ioctl_sdo_request_t data;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   352
    ec_sdo_request_t *req;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   353
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   354
    req = malloc(sizeof(ec_sdo_request_t));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   355
    if (!req) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   356
        fprintf(stderr, "Failed to allocate memory.\n");
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   357
        return 0;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   358
    }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   359
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   360
    if (size) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   361
        req->data = malloc(size);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   362
        if (!req->data) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   363
            fprintf(stderr, "Failed to allocate %u bytes of SDO data"
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   364
                    " memory.\n", size);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   365
            free(req);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   366
            return 0;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   367
        }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   368
    } else {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   369
        req->data = NULL;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   370
    }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   371
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   372
    data.config_index = sc->index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   373
    data.sdo_index = index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   374
    data.sdo_subindex = subindex;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   375
    data.size = size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   376
    
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   377
    if (ioctl(sc->master->fd, EC_IOCTL_SC_SDO_REQUEST, &data) == -1) {
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   378
        fprintf(stderr, "Failed to create SDO request: %s\n",
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   379
                strerror(errno));
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   380
        if (req->data)
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   381
            free(req->data);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   382
        free(req);
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   383
        return NULL; 
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   384
    }
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   385
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   386
    req->config = sc;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   387
    req->index = data.request_index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   388
    req->sdo_index = data.sdo_index;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   389
    req->sdo_subindex = data.sdo_subindex;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   390
    req->data_size = size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   391
    req->mem_size = size;
275d2fdeab48 Implemented SDO requests in userspace library.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
   392
    return req;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
ec_voe_handler_t *ecrt_slave_config_create_voe_handler(ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
        size_t size)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
{
1264
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   400
    ec_ioctl_voe_t data;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   401
    ec_voe_handler_t *voe;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   402
    unsigned int index;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   403
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   404
    voe = malloc(sizeof(ec_voe_handler_t));
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   405
    if (!voe) {
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   406
        fprintf(stderr, "Failed to allocate memory.\n");
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   407
        return 0;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   408
    }
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   409
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   410
    if (size) {
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   411
        voe->data = malloc(size);
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   412
        if (!voe->data) {
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   413
            fprintf(stderr, "Failed to allocate %u bytes of VoE data"
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   414
                    " memory.\n", size);
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   415
            free(voe);
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   416
            return 0;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   417
        }
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   418
    } else {
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   419
        voe->data = NULL;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   420
    }
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   421
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   422
    data.config_index = sc->index;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   423
    data.size = size;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   424
    
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   425
    if (ioctl(sc->master->fd, EC_IOCTL_SC_VOE, &data) == -1) {
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   426
        fprintf(stderr, "Failed to create VoE handler: %s\n",
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   427
                strerror(errno));
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   428
        if (voe->data)
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   429
            free(voe->data);
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   430
        free(voe);
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   431
        return NULL; 
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   432
    }
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   433
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   434
    voe->config = sc;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   435
    voe->index = data.voe_index;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   436
    voe->data_size = size;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   437
    voe->mem_size = size;
e7882f246d7a Implemented VoE handler in userspace.
Florian Pose <fp@igh-essen.com>
parents: 1259
diff changeset
   438
    return voe;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
void ecrt_slave_config_state(const ec_slave_config_t *sc,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
        ec_slave_config_state_t *state)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
{
1259
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   446
    ec_ioctl_sc_state_t data;
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   447
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   448
    data.config_index = sc->index;
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   449
    data.state = state;
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   450
    
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   451
    if (ioctl(sc->master->fd, EC_IOCTL_SC_STATE, &data) == -1) {
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   452
        fprintf(stderr, "Failed to get slave configuration state: %s\n",
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   453
                strerror(errno));
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   454
    }
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   455
}
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   456
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1255
diff changeset
   457
/*****************************************************************************/