master/sdo_entry.c
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sat, 29 Sep 2018 23:58:09 +0200
branchstable-1.5
changeset 2714 ec417efca1fd
parent 1382 cb2188d111f3
permissions -rw-r--r--
This fix a segfault in xenomai_posix example when calling pthread_setschedparam(cyclic_thread, ...) from main thread. As a side effect EL2004 becomes EL2088 - that's what IU have for testing.
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
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: 991
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
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: 991
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
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: 991
diff changeset
    10
 *  modify it under the terms of the GNU General Public License version 2, as
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: 991
diff changeset
    11
 *  published by the Free Software Foundation.
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
 *
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: 991
diff changeset
    13
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
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: 991
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
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: 991
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 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: 991
diff changeset
    16
 *  Public License for more details.
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *
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: 991
diff changeset
    18
 *  You should have received a copy of the GNU General Public License along
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: 991
diff changeset
    19
 *  with the IgH EtherCAT Master; if not, write to the Free Software
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *
1363
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    22
 *  ---
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    23
 *
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    24
 *  The license mentioned above concerns the source code only. Using the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    25
 *  EtherCAT technology and brand is only permitted in compliance with the
11c0b2caa253 Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents: 1327
diff changeset
    26
 *  industrial property and similar rights of Beckhoff Automation GmbH.
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
 *
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
 *****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
/**
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
   \file
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    32
   CANopen over EtherCAT SDO entry functions.
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
*/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    37
#include <linux/slab.h>
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    39
#include "sdo_entry.h"
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    40
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    41
/*****************************************************************************/
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    42
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    43
/** Constructor.
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    44
 */
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    45
void ec_sdo_entry_init(
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    46
        ec_sdo_entry_t *entry, /**< SDO entry. */
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    47
        ec_sdo_t *sdo, /**< Parent SDO. */
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    48
        uint8_t subindex /**< Subindex. */
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    49
        )
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
{
430
74754f45d5fa Implemented SDO reading via Sysfs.
Florian Pose <fp@igh-essen.com>
parents: 419
diff changeset
    51
    entry->sdo = sdo;
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
    entry->subindex = subindex;
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
    entry->data_type = 0x0000;
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
    entry->bit_length = 0;
1382
cb2188d111f3 Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    55
    entry->read_access[EC_SDO_ENTRY_ACCESS_PREOP] = 0;
cb2188d111f3 Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    56
    entry->read_access[EC_SDO_ENTRY_ACCESS_SAFEOP] = 0;
cb2188d111f3 Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    57
    entry->read_access[EC_SDO_ENTRY_ACCESS_OP] = 0;
cb2188d111f3 Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    58
    entry->write_access[EC_SDO_ENTRY_ACCESS_PREOP] = 0;
cb2188d111f3 Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    59
    entry->write_access[EC_SDO_ENTRY_ACCESS_SAFEOP] = 0;
cb2188d111f3 Read SDO entry access rights.
Florian Pose <fp@igh-essen.com>
parents: 1363
diff changeset
    60
    entry->write_access[EC_SDO_ENTRY_ACCESS_OP] = 0;
409
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
    entry->description = NULL;
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
}
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
/*****************************************************************************/
bc4c852e1b93 Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    66
/** Destructor.
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    67
 */
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    68
void ec_sdo_entry_clear(
1327
4d179b06dd3c merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents: 1326
diff changeset
    69
        ec_sdo_entry_t *entry /**< SDO entry. */
847
92266462d411 Saparated ec_sdo_t, ec_sdo_entry_t and ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents: 831
diff changeset
    70
        )
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 441
diff changeset
    71
{
991
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    72
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    73
    if (entry->description)
2548ca639b1f Removed kobject from sdo entry.
Florian Pose <fp@igh-essen.com>
parents: 986
diff changeset
    74
        kfree(entry->description);
448
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 441
diff changeset
    75
}
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 441
diff changeset
    76
e4b76dc7910c FIX: Introduced destroy() functions for kobject-derived classes and thus fixed memory leak.
Florian Pose <fp@igh-essen.com>
parents: 441
diff changeset
    77
/*****************************************************************************/