master/canopen.c
author Florian Pose <fp@igh-essen.com>
Mon, 10 Apr 2006 15:00:03 +0000
changeset 179 fb4c9dd11ca0
parent 175 2e4b18203ade
child 195 674071846ee3
permissions -rw-r--r--
Sourced SysFS attribute show method prototypes out of headers.
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  c a n o p e n . c
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  CANopen over EtherCAT
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  $Id$
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *****************************************************************************/
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
#include <linux/delay.h>
80
8cd08d73b560 CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
    12
#include <linux/slab.h>
8cd08d73b560 CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
    13
#include <linux/module.h>
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
#include "master.h"
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    16
#include "mailbox.h"
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
/*****************************************************************************/
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    20
void ec_canopen_abort_msg(uint32_t);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    21
int ec_slave_fetch_sdo_descriptions(ec_slave_t *);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    22
int ec_slave_fetch_sdo_entries(ec_slave_t *, ec_sdo_t *, uint8_t);
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    23
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    24
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    25
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
    26
const ec_code_msg_t sdo_abort_messages[];
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
    27
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    28
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    29
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    30
/**
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    31
   Liest 32 Bit eines CANopen-SDOs im Expedited-Modus aus einem Slave.
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    32
   \return 0 wenn alles ok, < 0 bei Fehler
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    33
 */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    34
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    35
int ec_slave_sdo_read_exp(ec_slave_t *slave, /**< EtherCAT-Slave */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    36
                          uint16_t sdo_index, /**< SDO-Index */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    37
                          uint8_t sdo_subindex, /**< SDO-Subindex */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    38
                          uint8_t *target /**< Speicher für 4 Bytes */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    39
                          )
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    40
{
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    41
    size_t rec_size;
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
    42
    uint8_t *data;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
    43
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    44
    if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 6))) return -1;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    45
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    46
    EC_WRITE_U16(data, 0x2 << 12); // SDO request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    47
    EC_WRITE_U8 (data + 2, (0x1 << 1 // expedited transfer
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    48
                            | 0x2 << 5));  // initiate upload request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    49
    EC_WRITE_U16(data + 3, sdo_index);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    50
    EC_WRITE_U8 (data + 5, sdo_subindex);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    51
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    52
    if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    53
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    54
    if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    55
        EC_READ_U8 (data + 2) >> 5 == 0x4) { // Abort SDO transfer request
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
    56
        EC_ERR("SDO upload 0x%04X:%X aborted on slave %i.\n",
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    57
               sdo_index, sdo_subindex, slave->ring_position);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    58
        ec_canopen_abort_msg(EC_READ_U32(data + 6));
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    59
        return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    60
    }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    61
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    62
    if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    63
        EC_READ_U8 (data + 2) >> 5 != 0x2 || // Upload response
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    64
        EC_READ_U16(data + 3) != sdo_index || // Index
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    65
        EC_READ_U8 (data + 5) != sdo_subindex) { // Subindex
159
acb250c92896 Fixed invalid format string.
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
    66
        EC_ERR("SDO upload 0x%04X:%X failed:\n", sdo_index, sdo_subindex);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    67
        EC_ERR("Invalid SDO upload response at slave %i!\n",
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    68
               slave->ring_position);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
    69
        ec_print_data(data, rec_size);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    70
        return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    71
    }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    72
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    73
    memcpy(target, data + 6, 4);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    74
    return 0;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    75
}
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    76
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    77
/*****************************************************************************/
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    78
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
    79
/**
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    80
   Beschreibt ein CANopen-SDO eines Slaves im Expedited-Modus.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    81
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    82
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    83
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    84
int ec_slave_sdo_write_exp(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    85
                           uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    86
                           uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    87
                           const uint8_t *sdo_data, /**< Neuer Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    88
                           size_t size
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    89
                           )
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
    91
    uint8_t *data;
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
    92
    size_t rec_size;
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
    if (size == 0 || size > 4) {
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    95
        EC_ERR("Invalid data size!\n");
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    96
        return -1;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    97
    }
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
    98
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    99
    if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 0x0A))) return -1;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   100
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   101
    EC_WRITE_U16(data, 0x2 << 12); // SDO request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   102
    EC_WRITE_U8 (data + 2, (0x1 // size specified
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   103
                            | 0x1 << 1 // expedited transfer
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   104
                            | (4 - size) << 2 // data set size
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   105
                            | 0x1 << 5)); // initiate download request
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   106
    EC_WRITE_U16(data + 3, sdo_index);
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   107
    EC_WRITE_U8 (data + 5, sdo_subindex);
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   108
    memcpy(data + 6, sdo_data, size);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   109
    if (size < 4) memset(data + 6 + size, 0x00, 4 - size);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   110
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   111
    if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1;
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   112
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   113
    if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   114
        EC_READ_U8 (data + 2) >> 5 == 0x4) { // Abort SDO transfer request
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   115
        EC_ERR("SDO download 0x%04X:%X (%i bytes) aborted on slave %i.\n",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   116
               sdo_index, sdo_subindex, size, slave->ring_position);
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   117
        ec_canopen_abort_msg(EC_READ_U32(data + 6));
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   118
        return -1;
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   119
    }
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   120
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   121
    if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   122
        EC_READ_U8 (data + 2) >> 5 != 0x3 || // Download response
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   123
        EC_READ_U16(data + 3) != sdo_index || // Index
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   124
        EC_READ_U8 (data + 5) != sdo_subindex) { // Subindex
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   125
        EC_ERR("SDO download 0x%04X:%X (%i bytes) failed:\n",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   126
               sdo_index, sdo_subindex, size);
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   127
        EC_ERR("Invalid SDO download response at slave %i!\n",
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 66
diff changeset
   128
               slave->ring_position);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   129
        ec_print_data(data, rec_size);
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
        return -1;
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
    }
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
    return 0;
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
}
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
/*****************************************************************************/
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
80
8cd08d73b560 CANopen SDO read implementiert.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   138
/**
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   139
   Liest ein CANopen-SDO im "Normal-Modus" aus einem Slave.
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   140
   \return 0 wenn alles ok, < 0 bei Fehler
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   141
 */
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   142
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   143
int ecrt_slave_sdo_read(ec_slave_t *slave, /**< EtherCAT-Slave */
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   144
                        uint16_t sdo_index, /**< SDO-Index */
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   145
                        uint8_t sdo_subindex, /**< SDO-Subindex */
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   146
                        uint8_t *target, /**< Speicher für gel. Wert */
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   147
                        size_t *size /**< Größe des Speichers */
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   148
                        )
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   149
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   150
    uint8_t *data;
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   151
    size_t rec_size, data_size;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   152
    uint32_t complete_size;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   153
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   154
    if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 6))) return -1;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   155
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   156
    EC_WRITE_U16(data, 0x2 << 12); // SDO request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   157
    EC_WRITE_U8 (data + 2, 0x2 << 5); // initiate upload request
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   158
    EC_WRITE_U16(data + 3, sdo_index);
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   159
    EC_WRITE_U8 (data + 5, sdo_subindex);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   160
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   161
    if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1;
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   162
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   163
    if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   164
        EC_READ_U8 (data + 2) >> 5 == 0x4) { // Abort SDO transfer request
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   165
        EC_ERR("SDO upload 0x%04X:%X aborted on slave %i.\n",
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   166
               sdo_index, sdo_subindex, slave->ring_position);
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   167
        ec_canopen_abort_msg(EC_READ_U32(data + 6));
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   168
        return -1;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   169
    }
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   170
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   171
    if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   172
        EC_READ_U8 (data + 2) >> 5 != 0x2 || // Initiate upload response
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   173
        EC_READ_U16(data + 3) != sdo_index || // Index
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   174
        EC_READ_U8 (data + 5) != sdo_subindex) { // Subindex
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   175
        EC_ERR("SDO upload 0x%04X:%X failed:\n", sdo_index, sdo_subindex);
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   176
        EC_ERR("Invalid SDO upload response at slave %i!\n",
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   177
               slave->ring_position);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   178
        ec_print_data(data, rec_size);
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   179
        return -1;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   180
    }
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   181
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   182
    if (rec_size < 10) {
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   183
        EC_ERR("Received currupted SDO upload response!\n");
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   184
        ec_print_data(data, rec_size);
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   185
        return -1;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   186
    }
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   187
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   188
    if ((complete_size = EC_READ_U32(data + 6)) > *size) {
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   189
        EC_ERR("SDO data does not fit into buffer (%i / %i)!\n",
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   190
               complete_size, *size);
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   191
        return -1;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   192
    }
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   193
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   194
    data_size = rec_size - 10;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   195
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   196
    if (data_size != complete_size) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   197
        EC_ERR("SDO data incomplete - Fragmenting not implemented.\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   198
        return -1;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   199
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   200
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   201
    memcpy(target, data + 10, data_size);
137
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   202
    return 0;
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   203
}
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   204
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   205
/*****************************************************************************/
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   206
3fb18812871a SDO-Zugriff aufgeteilt in Expedited und Normal. Noch nicht fertig...
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   207
/**
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   208
   Lädt das gesamte SDO-Dictionary aus einem Slave.
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   209
   \return 0, wenn alles ok, sonst < 0
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   210
*/
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   211
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   212
int ec_slave_fetch_sdo_list(ec_slave_t *slave /**< EtherCAT-Slave */)
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   213
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   214
    uint8_t *data;
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   215
    size_t rec_size;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   216
    unsigned int i, sdo_count;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   217
    ec_sdo_t *sdo;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   218
    uint16_t sdo_index;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   219
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   220
    if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 8))) return -1;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   221
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   222
    EC_WRITE_U16(data, 0x8 << 12); // SDO information
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   223
    EC_WRITE_U8 (data + 2, 0x01); // Get OD List Request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   224
    EC_WRITE_U8 (data + 3, 0x00);
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   225
    EC_WRITE_U16(data + 4, 0x0000);
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   226
    EC_WRITE_U16(data + 6, 0x0001); // Deliver all SDOs!
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   227
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   228
    if (unlikely(ec_master_simple_io(slave->master, &slave->mbox_command))) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   229
        EC_ERR("Mailbox checking failed on slave %i!\n", slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   230
        return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   231
    }
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   232
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   233
    do {
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   234
        if (!(data = ec_slave_mbox_simple_receive(slave, 0x03, &rec_size)))
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   235
            return -1;
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   236
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   237
        if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   238
            (EC_READ_U8(data + 2) & 0x7F) == 0x07) { // Error response
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   239
            EC_ERR("SDO information error response at slave %i!\n",
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   240
                   slave->ring_position);
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   241
            ec_canopen_abort_msg(EC_READ_U32(data + 6));
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   242
            return -1;
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   243
        }
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   244
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   245
        if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   246
            (EC_READ_U8 (data + 2) & 0x7F) != 0x02) { // Get OD List response
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   247
            EC_ERR("Invalid SDO list response at slave %i!\n",
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   248
                   slave->ring_position);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   249
            ec_print_data(data, rec_size);
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   250
            return -1;
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   251
        }
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   252
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   253
        if (rec_size < 8) {
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   254
            EC_ERR("Invalid data size!\n");
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   255
            ec_print_data(data, rec_size);
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   256
            return -1;
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   257
        }
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   258
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   259
        sdo_count = (rec_size - 8) / 2;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   260
        for (i = 0; i < sdo_count; i++) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   261
            sdo_index = EC_READ_U16(data + 8 + i * 2);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   262
            if (!sdo_index) continue; // Manchmal ist der Index 0... ???
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   263
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   264
            if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_KERNEL))) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   265
                EC_ERR("Failed to allocate memory for SDO!\n");
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   266
                return -1;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   267
            }
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   268
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   269
            // Initialize SDO object
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   270
            sdo->index = sdo_index;
175
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   271
            //sdo->unkown = 0x0000;
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   272
            sdo->object_code = 0x00;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   273
            sdo->name = NULL;
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   274
            INIT_LIST_HEAD(&sdo->entries);
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   275
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   276
            list_add_tail(&sdo->list, &slave->sdo_dictionary);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   277
        }
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   278
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   279
    while (EC_READ_U8(data + 2) & 0x80);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   280
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   281
    // Alle Beschreibungen laden
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   282
    if (ec_slave_fetch_sdo_descriptions(slave)) return -1;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   283
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   284
    return 0;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   285
}
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   286
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   287
/*****************************************************************************/
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   288
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   289
/**
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   290
   Holt die Beschreibungen zu allen bereits bekannten SDOs.
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   291
   \return 0, wenn alles ok, sonst < 0
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   292
*/
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   293
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   294
int ec_slave_fetch_sdo_descriptions(ec_slave_t *slave /**< EtherCAT-Slave */)
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   295
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   296
    uint8_t *data;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   297
    size_t rec_size, name_size;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   298
    ec_sdo_t *sdo;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   299
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   300
    list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   301
        if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 8))) return -1;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   302
        EC_WRITE_U16(data, 0x8 << 12); // SDO information
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   303
        EC_WRITE_U8 (data + 2, 0x03); // Get object description request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   304
        EC_WRITE_U8 (data + 3, 0x00);
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   305
        EC_WRITE_U16(data + 4, 0x0000);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   306
        EC_WRITE_U16(data + 6, sdo->index); // SDO index
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   307
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   308
        if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   309
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   310
        if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   311
            (EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // Error response
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   312
            EC_ERR("SDO information error response at slave %i while"
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   313
                   " fetching SDO 0x%04X!\n", slave->ring_position,
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   314
                   sdo->index);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   315
            ec_canopen_abort_msg(EC_READ_U32(data + 6));
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   316
            return -1;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   317
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   318
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   319
        if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   320
            (EC_READ_U8 (data + 2) & 0x7F) != 0x04 || // Object desc. response
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   321
            EC_READ_U16(data + 6) != sdo->index) { // SDO index
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   322
            EC_ERR("Invalid object description response at slave %i while"
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   323
                   " fetching SDO 0x%04X!\n", slave->ring_position,
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   324
                   sdo->index);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   325
            ec_print_data(data, rec_size);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   326
            return -1;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   327
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   328
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   329
        if (rec_size < 12) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   330
            EC_ERR("Invalid data size!\n");
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   331
            ec_print_data(data, rec_size);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   332
            return -1;
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   333
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   334
175
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   335
        EC_DBG("object desc response:\n");
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   336
        ec_print_data(data, rec_size);
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   337
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   338
        //sdo->unknown = EC_READ_U16(data + 8);
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
   339
        sdo->object_code = EC_READ_U8(data + 11);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   340
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   341
        name_size = rec_size - 12;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   342
        if (name_size) {
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   343
            if (!(sdo->name = kmalloc(name_size + 1, GFP_KERNEL))) {
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   344
                EC_ERR("Failed to allocate SDO name!\n");
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   345
                return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   346
            }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   347
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   348
            memcpy(sdo->name, data + 12, name_size);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   349
            sdo->name[name_size] = 0;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   350
        }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   351
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   352
        if (EC_READ_U8(data + 2) & 0x80) {
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   353
            EC_ERR("Fragment follows (not implemented)!\n");
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   354
            return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   355
        }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   356
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   357
        // Alle Entries (Subindizes) laden
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   358
        if (ec_slave_fetch_sdo_entries(slave, sdo, EC_READ_U8(data + 10)))
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   359
            return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   360
    }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   361
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   362
    return 0;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   363
}
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   364
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   365
/*****************************************************************************/
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   366
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   367
/**
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   368
   Lädt alle Entries (Subindizes) zu einem SDO.
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   369
   \return 0, wenn alles ok, sonst < 0
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   370
*/
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   371
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   372
int ec_slave_fetch_sdo_entries(ec_slave_t *slave, /**< EtherCAT-Slave */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   373
                               ec_sdo_t *sdo, /**< SDO */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   374
                               uint8_t subindices /**< Anzahl Subindizes */
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   375
                               )
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   376
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   377
    uint8_t *data;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   378
    size_t rec_size, data_size;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   379
    uint8_t i;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   380
    ec_sdo_entry_t *entry;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   381
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   382
    for (i = 1; i <= subindices; i++) {
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   383
        if (!(data = ec_slave_mbox_prepare_send(slave, 0x03, 10)))
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   384
            return -1;
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   385
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   386
        EC_WRITE_U16(data, 0x8 << 12); // SDO information
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   387
        EC_WRITE_U8 (data + 2, 0x05); // Get entry description request
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   388
        EC_WRITE_U8 (data + 3, 0x00);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   389
        EC_WRITE_U16(data + 4, 0x0000);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   390
        EC_WRITE_U16(data + 6, sdo->index); // SDO index
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   391
        EC_WRITE_U8 (data + 8, i); // SDO subindex
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   392
        EC_WRITE_U8 (data + 9, 0x00); // value info (no values)
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   393
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   394
        if (!(data = ec_slave_mbox_simple_io(slave, &rec_size))) return -1;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   395
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   396
        if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   397
            (EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // Error response
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   398
            EC_ERR("SDO information error response at slave %i while"
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   399
                   " fetching SDO entry 0x%04X:%i!\n", slave->ring_position,
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   400
                   sdo->index, i);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   401
            ec_canopen_abort_msg(EC_READ_U32(data + 6));
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   402
            return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   403
        }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   404
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   405
        if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   406
            (EC_READ_U8(data + 2) & 0x7F) != 0x06 || // entry descr. response
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   407
            EC_READ_U16(data + 6) != sdo->index || // SDO index
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   408
            EC_READ_U8(data + 8) != i) { // SDO subindex
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   409
            EC_ERR("Invalid entry description response at slave %i while"
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   410
                   " fetching SDO entry 0x%04X:%i!\n", slave->ring_position,
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   411
                   sdo->index, i);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   412
            ec_print_data(data, rec_size);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   413
            return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   414
        }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   415
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   416
        if (rec_size < 16) {
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   417
            EC_ERR("Invalid data size!\n");
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   418
            ec_print_data(data, rec_size);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   419
            return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   420
        }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   421
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   422
        if (!EC_READ_U16(data + 12)) // bit length = 0
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   423
            continue;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   424
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   425
        data_size = rec_size - 16;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   426
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   427
        if (!(entry = (ec_sdo_entry_t *)
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   428
              kmalloc(sizeof(ec_sdo_entry_t) + data_size + 1, GFP_KERNEL))) {
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   429
            EC_ERR("Failed to allocate entry!\n");
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   430
            return -1;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   431
        }
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   432
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   433
        entry->subindex = i;
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   434
        entry->data_type = EC_READ_U16(data + 10);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   435
        entry->bit_length = EC_READ_U16(data + 12);
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   436
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   437
        // memory for name string appended to entry
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   438
        entry->name = (uint8_t *) entry + sizeof(ec_sdo_entry_t);
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   439
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   440
        memcpy(entry->name, data + 16, data_size);
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 159
diff changeset
   441
        entry->name[data_size] = 0;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   442
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   443
        list_add_tail(&entry->list, &sdo->entries);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 134
diff changeset
   444
    }
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   445
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   446
    return 0;
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   447
}
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   448
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   449
/*****************************************************************************/
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   450
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   451
/**
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   452
   Gibt eine SDO-Abort-Meldung aus.
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   453
*/
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   454
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   455
void ec_canopen_abort_msg(uint32_t abort_code)
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   456
{
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   457
    const ec_code_msg_t *abort_msg;
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   458
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   459
    for (abort_msg = sdo_abort_messages; abort_msg->code; abort_msg++) {
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   460
        if (abort_msg->code == abort_code) {
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   461
            EC_ERR("SDO abort message 0x%08X: \"%s\".\n",
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   462
                   abort_msg->code, abort_msg->message);
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   463
            return;
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   464
        }
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   465
    }
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
   466
133
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   467
    EC_ERR("Unknown SDO abort code 0x%08X.\n", abort_code);
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   468
}
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   469
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   470
/*****************************************************************************/
b36d187ecc0b Unterst?tzte Prot. auslesen, Mailbox in Slave ausgelagert, Bugfix in Anzeige des Watch-Frames und erste SDO-List-Abfrage.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   471
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   472
const ec_code_msg_t sdo_abort_messages[] = {
111
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   473
    {0x05030000, "Toggle bit not changed"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   474
    {0x05040000, "SDO protocol timeout"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   475
    {0x05040001, "Client/Server command specifier not valid or unknown"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   476
    {0x05040005, "Out of memory"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   477
    {0x06010000, "Unsupported access to an object"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   478
    {0x06010001, "Attempt to read a write-only object"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   479
    {0x06010002, "Attempt to write a read-only object"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   480
    {0x06020000, "This object does not exist in the object directory"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   481
    {0x06040041, "The object cannot be mapped into the PDO"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   482
    {0x06040042, "The number and length of the objects to be mapped would"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   483
     " exceed the PDO length"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   484
    {0x06040043, "General parameter incompatibility reason"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   485
    {0x06040047, "Gerneral internal incompatibility in device"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   486
    {0x06060000, "Access failure due to a hardware error"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   487
    {0x06070010, "Data type does not match, length of service parameter does"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   488
     " not match"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   489
    {0x06070012, "Data type does not match, length of service parameter too"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   490
     " high"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   491
    {0x06070013, "Data type does not match, length of service parameter too"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   492
     " low"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   493
    {0x06090011, "Subindex does not exist"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   494
    {0x06090030, "Value range of parameter exceeded"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   495
    {0x06090031, "Value of parameter written too high"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   496
    {0x06090032, "Value of parameter written too low"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   497
    {0x06090036, "Maximum value is less than minimum value"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   498
    {0x08000000, "General error"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   499
    {0x08000020, "Data cannot be transferred or stored to the application"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   500
    {0x08000021, "Data cannot be transferred or stored to the application"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   501
     " because of local control"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   502
    {0x08000022, "Data cannot be transferred or stored to the application"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   503
     " because of the present device state"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   504
    {0x08000023, "Object dictionary dynamic generation fails or no object"
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   505
     " dictionary is present"},
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   506
    {}
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   507
};
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   508
9963537ec776 Bugfix: SDO download. SDO abort codes ausgeben.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   509
/*****************************************************************************/
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   510
// Echtzeitschnittstelle
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   511
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   512
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   513
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   514
/**
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   515
   Liest ein 8-Bit CANopen-SDO im Expedited-Modus aus einem Slave.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   516
   Siehe ec_slave_sdo_read_exp()
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   517
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   518
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   519
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   520
int ecrt_slave_sdo_read_exp8(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   521
                             uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   522
                             uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   523
                             uint8_t *target /**< Speicher für gel. Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   524
                             )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   525
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   526
    uint8_t data[4];
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   527
    if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   528
    *target = EC_READ_U8(data);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   529
    return 0;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   530
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   531
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   532
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   533
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   534
/**
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   535
   Liest ein 16-Bit CANopen-SDO im Expedited-Modus aus einem Slave.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   536
   Siehe ec_slave_sdo_read_exp()
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   537
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   538
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   539
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   540
int ecrt_slave_sdo_read_exp16(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   541
                              uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   542
                              uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   543
                              uint16_t *target /**< Speicher für gel. Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   544
                              )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   545
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   546
    uint8_t data[4];
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   547
    if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   548
    *target = EC_READ_U16(data);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   549
    return 0;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   550
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   551
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   552
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   553
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   554
/**
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   555
   Liest ein 32-Bit CANopen-SDO im Expedited-Modus aus einem Slave.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   556
   Siehe ec_slave_sdo_read_exp()
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   557
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   558
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   559
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   560
int ecrt_slave_sdo_read_exp32(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   561
                              uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   562
                              uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   563
                              uint32_t *target /**< Speicher für gel. Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   564
                              )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   565
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   566
    uint8_t data[4];
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   567
    if (ec_slave_sdo_read_exp(slave, sdo_index, sdo_subindex, data)) return -1;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   568
    *target = EC_READ_U32(data);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   569
    return 0;
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   570
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   571
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   572
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   573
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   574
/**
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   575
   Beschreibt ein 8-Bit CANopen-SDO eines Slaves im Expedited-Modus.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   576
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   577
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   578
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   579
int ecrt_slave_sdo_write_exp8(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   580
                              uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   581
                              uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   582
                              uint8_t value /**< Neuer Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   583
                              )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   584
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   585
    return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, &value, 1);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   586
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   587
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   588
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   589
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   590
/**
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   591
   Beschreibt ein 16-Bit CANopen-SDO eines Slaves im Expedited-Modus.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   592
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   593
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   594
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   595
int ecrt_slave_sdo_write_exp16(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   596
                               uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   597
                               uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   598
                               uint16_t value /**< Neuer Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   599
                               )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   600
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   601
    uint8_t data[2];
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   602
    EC_WRITE_U16(data, value);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   603
    return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, data, 2);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   604
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   605
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   606
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   607
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   608
/**
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   609
   Beschreibt ein 32-Bit CANopen-SDO eines Slaves im Expedited-Modus.
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   610
   \return 0 wenn alles ok, < 0 bei Fehler
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   611
 */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   612
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   613
int ecrt_slave_sdo_write_exp32(ec_slave_t *slave, /**< EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   614
                               uint16_t sdo_index, /**< SDO-Index */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   615
                               uint8_t sdo_subindex, /**< SDO-Subindex */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   616
                               uint32_t value /**< Neuer Wert */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   617
                               )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   618
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   619
    uint8_t data[4];
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   620
    EC_WRITE_U32(data, value);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   621
    return ec_slave_sdo_write_exp(slave, sdo_index, sdo_subindex, data, 4);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   622
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   623
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   624
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   625
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   626
EXPORT_SYMBOL(ecrt_slave_sdo_read_exp8);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   627
EXPORT_SYMBOL(ecrt_slave_sdo_read_exp16);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   628
EXPORT_SYMBOL(ecrt_slave_sdo_read_exp32);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   629
EXPORT_SYMBOL(ecrt_slave_sdo_write_exp8);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   630
EXPORT_SYMBOL(ecrt_slave_sdo_write_exp16);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 137
diff changeset
   631
EXPORT_SYMBOL(ecrt_slave_sdo_write_exp32);
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   632
EXPORT_SYMBOL(ecrt_slave_sdo_read);
64
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
/*****************************************************************************/
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
/* Emacs-Konfiguration
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
;;; Local Variables: ***
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
;;; c-basic-offset:4 ***
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
;;; End: ***
ea6ccf12c612 CANopen over EtherCAT.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
*/