lib/domain.c
author Florian Pose <fp@igh-essen.com>
Fri, 08 Feb 2013 20:00:16 +0100
branchstable-1.5
changeset 2512 a01947bc9ab6
parent 2504 5ef9d5b14879
permissions -rw-r--r--
Directly export PDFs from DOT graphs.
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
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$
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
     4
 *
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
     5
 *  Copyright (C) 2006-2012  Florian Pose, Ingenieurgemeinschaft IgH
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
     6
 *
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
     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
 *
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
     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/>.
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: 1326
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: 1326
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: 1326
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: 1326
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
/**
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
   \file
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
   EtherCAT domain methods.
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
*/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
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
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    38
#include <stdio.h>
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    39
#include <string.h>
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    40
#include <errno.h> /* ENOENT */
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    41
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    42
#include "ioctl.h"
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include "domain.h"
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    44
#include "master.h"
1255
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
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
1959
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    48
void ec_domain_clear(ec_domain_t *domain)
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    49
{
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    50
    // nothing to do
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    51
}
656f114153c2 Free all userspace library objects on releasing master.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    52
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
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
int ecrt_domain_reg_pdo_entry_list(ec_domain_t *domain,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
        const ec_pdo_entry_reg_t *regs)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
{
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
    const ec_pdo_entry_reg_t *reg;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
    ec_slave_config_t *sc;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
    int ret;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
    61
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
    for (reg = regs; reg->index; reg++) {
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
        if (!(sc = ecrt_master_slave_config(domain->master, reg->alias,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
                        reg->position, reg->vendor_id, reg->product_code)))
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    65
            return -ENOENT;
1255
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
        if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index,
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
                        reg->subindex, domain, reg->bit_position)) < 0)
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
    69
            return ret;
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        *reg->offset = ret;
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
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
    return 0;
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
2504
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    79
size_t ecrt_domain_size(const ec_domain_t *domain)
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    80
{
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    81
    int ret;
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    82
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    83
    ret = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_SIZE, domain->index);
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    84
    if (EC_IOCTL_IS_ERROR(ret)) {
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    85
        fprintf(stderr, "Failed to get domain size: %s\n",
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    86
                strerror(EC_IOCTL_ERRNO(ret)));
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    87
    }
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    88
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    89
    return ret;
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    90
}
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    91
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    92
/*****************************************************************************/
5ef9d5b14879 Exported ecrt_domain_size() for userspace.
Florian Pose <fp@igh-essen.com>
parents: 2433
diff changeset
    93
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
uint8_t *ecrt_domain_data(ec_domain_t *domain)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
{
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    96
    if (!domain->process_data) {
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    97
        int offset = 0;
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    98
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
    99
        offset = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_OFFSET,
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   100
                domain->index);
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   101
        if (EC_IOCTL_IS_ERROR(offset)) {
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   102
            fprintf(stderr, "Failed to get domain offset: %s\n",
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   103
                    strerror(EC_IOCTL_ERRNO(offset)));
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
   104
            return NULL;
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   105
        }
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
   106
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   107
        domain->process_data = domain->master->process_data + offset;
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   108
    }
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   109
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   110
    return domain->process_data;
1255
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
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
/*****************************************************************************/
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
void ecrt_domain_process(ec_domain_t *domain)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
{
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   117
    int ret;
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   118
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   119
    ret = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_PROCESS, domain->index);
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   120
    if (EC_IOCTL_IS_ERROR(ret)) {
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   121
        fprintf(stderr, "Failed to process domain: %s\n",
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   122
                strerror(EC_IOCTL_ERRNO(ret)));
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   123
    }
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
}
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
void ecrt_domain_queue(ec_domain_t *domain)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
{
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   130
    int ret;
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   131
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   132
    ret = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_QUEUE, domain->index);
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   133
    if (EC_IOCTL_IS_ERROR(ret)) {
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   134
        fprintf(stderr, "Failed to queue domain: %s\n",
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   135
                strerror(EC_IOCTL_ERRNO(ret)));
1258
900f1124e8f8 Memory-mapped process data.
Florian Pose <fp@igh-essen.com>
parents: 1257
diff changeset
   136
    }
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
/*****************************************************************************/
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
void ecrt_domain_state(const ec_domain_t *domain, ec_domain_state_t *state)
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
{
1259
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1258
diff changeset
   143
    ec_ioctl_domain_state_t data;
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   144
    int ret;
1259
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1258
diff changeset
   145
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1258
diff changeset
   146
    data.domain_index = domain->index;
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1258
diff changeset
   147
    data.state = state;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 1959
diff changeset
   148
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   149
    ret = ioctl(domain->master->fd, EC_IOCTL_DOMAIN_STATE, &data);
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   150
    if (EC_IOCTL_IS_ERROR(ret)) {
1259
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1258
diff changeset
   151
        fprintf(stderr, "Failed to get domain state: %s\n",
2433
3bdd7a747fae Re-worked and seamlessly integrated RTDM interface.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
   152
                strerror(EC_IOCTL_ERRNO(ret)));
1259
5f9d1abbee71 Added state functions; writing of process data works.
Florian Pose <fp@igh-essen.com>
parents: 1258
diff changeset
   153
    }
1255
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
}
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
38b7e05b20c1 Added some slave configuration methods.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
/*****************************************************************************/