master/slave.c
author Florian Pose <fp@igh-essen.com>
Fri, 21 Apr 2006 13:05:01 +0000
changeset 198 f7dff1ed01ba
parent 197 b9a6e2c22745
child 199 04ecf40fc2e9
permissions -rw-r--r--
Separate INSTALL file.
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
     1
/******************************************************************************
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
     3
 *  s l a v e . c
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
     5
 *  EtherCAT slave methods.
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
     7
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     9
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    10
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    11
 *  This file is part of the IgH EtherCAT Master.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    12
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    13
 *  The IgH EtherCAT Master is free software; you can redistribute it
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    14
 *  and/or modify it under the terms of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    15
 *  as published by the Free Software Foundation; version 2 of the License.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    16
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    17
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    18
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    19
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    21
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    22
 *  You should have received a copy of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    23
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    24
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    25
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    26
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    28
#include <linux/module.h>
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    29
#include <linux/delay.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    31
#include "globals.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    32
#include "slave.h"
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    33
#include "command.h"
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    34
#include "master.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    36
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    38
int ec_slave_fetch_categories(ec_slave_t *);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    39
int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
    40
int ec_slave_fetch_general(ec_slave_t *, const uint8_t *);
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
    41
int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
    42
int ec_slave_fetch_pdo(ec_slave_t *, const uint8_t *, size_t, ec_pdo_type_t);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
    43
int ec_slave_locate_string(ec_slave_t *, unsigned int, char **);
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    44
ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    45
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    46
/*****************************************************************************/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    47
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    48
EC_SYSFS_READ_ATTR(ring_position);
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
    49
EC_SYSFS_READ_ATTR(coupler_address);
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    50
EC_SYSFS_READ_ATTR(vendor_name);
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    51
EC_SYSFS_READ_ATTR(product_name);
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    52
EC_SYSFS_READ_ATTR(product_desc);
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    53
EC_SYSFS_READ_ATTR(type);
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    54
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    55
static struct attribute *def_attrs[] = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    56
    &attr_ring_position,
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
    57
    &attr_coupler_address,
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    58
    &attr_vendor_name,
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    59
    &attr_product_name,
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    60
    &attr_product_desc,
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    61
    &attr_type,
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    62
    NULL,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    63
};
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    64
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    65
static struct sysfs_ops sysfs_ops = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    66
    .show = &ec_show_slave_attribute,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    67
    .store = NULL
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    68
};
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    69
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    70
static struct kobj_type ktype_ec_slave = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    71
    .release = ec_slave_clear,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    72
    .sysfs_ops = &sysfs_ops,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    73
    .default_attrs = def_attrs
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    74
};
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    75
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    76
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    77
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    78
const ec_code_msg_t al_status_messages[];
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    79
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    80
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    81
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    83
   Slave constructor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    84
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    85
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    86
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    87
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    88
int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    89
                  ec_master_t *master, /**< EtherCAT master */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    90
                  uint16_t ring_position, /**< ring position */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    91
                  uint16_t station_address /**< station address to configure */
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    92
                  )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    93
{
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    94
    unsigned int i;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    95
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    96
    slave->ring_position = ring_position;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    97
    slave->station_address = station_address;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    98
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
    99
    // init kobject and add it to the hierarchy
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   100
    memset(&slave->kobj, 0x00, sizeof(struct kobject));
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   101
    kobject_init(&slave->kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   102
    slave->kobj.ktype = &ktype_ec_slave;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   103
    slave->kobj.parent = &master->kobj;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   104
    if (kobject_set_name(&slave->kobj, "slave%03i", slave->ring_position)) {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   105
        EC_ERR("Failed to set kobject name.\n");
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   106
        kobject_put(&slave->kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   107
        return -1;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   108
    }
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   109
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   110
    slave->master = master;
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
   111
    slave->coupler_index = 0;
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
   112
    slave->coupler_subindex = 0xFFFF;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   113
    slave->base_type = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   114
    slave->base_revision = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   115
    slave->base_build = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   116
    slave->base_fmmu_count = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   117
    slave->base_sync_count = 0;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   118
    slave->sii_alias = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   119
    slave->sii_vendor_id = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   120
    slave->sii_product_code = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   121
    slave->sii_revision_number = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   122
    slave->sii_serial_number = 0;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   123
    slave->sii_rx_mailbox_offset = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   124
    slave->sii_rx_mailbox_size = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   125
    slave->sii_tx_mailbox_offset = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   126
    slave->sii_tx_mailbox_size = 0;
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: 132
diff changeset
   127
    slave->sii_mailbox_protocols = 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   128
    slave->type = NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   129
    slave->registered = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   130
    slave->fmmu_count = 0;
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   131
    slave->eeprom_name = NULL;
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   132
    slave->eeprom_group = NULL;
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   133
    slave->eeprom_desc = NULL;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   134
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   135
    ec_command_init(&slave->mbox_command);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   136
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   137
    INIT_LIST_HEAD(&slave->eeprom_strings);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   138
    INIT_LIST_HEAD(&slave->eeprom_syncs);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   139
    INIT_LIST_HEAD(&slave->eeprom_pdos);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   140
    INIT_LIST_HEAD(&slave->sdo_dictionary);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   141
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   142
    for (i = 0; i < 4; i++) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   143
        slave->dl_link[i] = 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   144
        slave->dl_loop[i] = 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   145
        slave->dl_signal[i] = 0;
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   146
        slave->sii_physical_layer[i] = 0xFF;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   147
    }
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   148
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   149
    return 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   150
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   151
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   152
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   153
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   154
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   155
   Slave destructor.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   156
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   157
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   158
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   159
void ec_slave_clear(struct kobject *kobj /**< kobject of the slave */)
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   160
{
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   161
    ec_slave_t *slave;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   162
    ec_eeprom_string_t *string, *next_str;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   163
    ec_eeprom_sync_t *sync, *next_sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   164
    ec_eeprom_pdo_t *pdo, *next_pdo;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   165
    ec_eeprom_pdo_entry_t *entry, *next_ent;
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   166
    ec_sdo_t *sdo, *next_sdo;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   167
    ec_sdo_entry_t *en, *next_en;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   168
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   169
    slave = container_of(kobj, ec_slave_t, kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   170
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   171
    // free all string objects
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   172
    list_for_each_entry_safe(string, next_str, &slave->eeprom_strings, list) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   173
        list_del(&string->list);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   174
        kfree(string);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   175
    }
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   176
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   177
    // free all sync managers
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   178
    list_for_each_entry_safe(sync, next_sync, &slave->eeprom_syncs, list) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   179
        list_del(&sync->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   180
        kfree(sync);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   181
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   182
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   183
    // free all PDOs
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   184
    list_for_each_entry_safe(pdo, next_pdo, &slave->eeprom_pdos, list) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   185
        list_del(&pdo->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   186
        if (pdo->name) kfree(pdo->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   187
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   188
        // free all PDO entries
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   189
        list_for_each_entry_safe(entry, next_ent, &pdo->entries, list) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   190
            list_del(&entry->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   191
            if (entry->name) kfree(entry->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   192
            kfree(entry);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   193
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   194
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   195
        kfree(pdo);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   196
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   197
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   198
    if (slave->eeprom_name) kfree(slave->eeprom_name);
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   199
    if (slave->eeprom_group) kfree(slave->eeprom_group);
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   200
    if (slave->eeprom_desc) kfree(slave->eeprom_desc);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   201
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   202
    // free all SDOs
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   203
    list_for_each_entry_safe(sdo, next_sdo, &slave->sdo_dictionary, list) {
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   204
        list_del(&sdo->list);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   205
        if (sdo->name) kfree(sdo->name);
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 160
diff changeset
   206
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   207
        // free all SDO entries
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   208
        list_for_each_entry_safe(en, next_en, &sdo->entries, list) {
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   209
            list_del(&en->list);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   210
            kfree(en);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   211
        }
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   212
        kfree(sdo);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   213
    }
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   214
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   215
    ec_command_clear(&slave->mbox_command);
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   216
}
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   217
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   218
/*****************************************************************************/
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   219
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   220
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   221
   Reads all necessary information from a slave.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   222
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   223
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   224
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   225
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   226
int ec_slave_fetch(ec_slave_t *slave /**< EtherCAT slave */)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   227
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   228
    ec_command_t *command;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   229
    unsigned int i;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   230
    uint16_t dl_status;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   231
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   232
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   233
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   234
    // read base data
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   235
    if (ec_command_nprd(command, slave->station_address, 0x0000, 6)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   236
    if (unlikely(ec_master_simple_io(slave->master, command))) {
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   237
        EC_ERR("Reading base data from slave %i failed!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   238
               slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   239
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   240
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   241
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   242
    slave->base_type =       EC_READ_U8 (command->data);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   243
    slave->base_revision =   EC_READ_U8 (command->data + 1);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   244
    slave->base_build =      EC_READ_U16(command->data + 2);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   245
    slave->base_fmmu_count = EC_READ_U8 (command->data + 4);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   246
    slave->base_sync_count = EC_READ_U8 (command->data + 5);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   247
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   248
    if (slave->base_fmmu_count > EC_MAX_FMMUS)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   249
        slave->base_fmmu_count = EC_MAX_FMMUS;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   250
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   251
    // read data link status
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   252
    if (ec_command_nprd(command, slave->station_address, 0x0110, 2)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   253
    if (unlikely(ec_master_simple_io(slave->master, command))) {
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   254
        EC_ERR("Reading DL status from slave %i failed!\n",
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   255
               slave->ring_position);
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   256
        return -1;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   257
    }
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   258
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   259
    dl_status = EC_READ_U16(command->data);
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   260
    for (i = 0; i < 4; i++) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   261
        slave->dl_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   262
        slave->dl_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0;
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   263
        slave->dl_signal[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   264
    }
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   265
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   266
    // read EEPROM data
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   267
    if (ec_slave_sii_read16(slave, 0x0004, &slave->sii_alias))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   268
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   269
    if (ec_slave_sii_read32(slave, 0x0008, &slave->sii_vendor_id))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   270
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   271
    if (ec_slave_sii_read32(slave, 0x000A, &slave->sii_product_code))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   272
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   273
    if (ec_slave_sii_read32(slave, 0x000C, &slave->sii_revision_number))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   274
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   275
    if (ec_slave_sii_read32(slave, 0x000E, &slave->sii_serial_number))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   276
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   277
    if (ec_slave_sii_read16(slave, 0x0018, &slave->sii_rx_mailbox_offset))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   278
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   279
    if (ec_slave_sii_read16(slave, 0x0019, &slave->sii_rx_mailbox_size))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   280
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   281
    if (ec_slave_sii_read16(slave, 0x001A, &slave->sii_tx_mailbox_offset))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   282
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   283
    if (ec_slave_sii_read16(slave, 0x001B, &slave->sii_tx_mailbox_size))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   284
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   285
    if (ec_slave_sii_read16(slave, 0x001C, &slave->sii_mailbox_protocols))
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   286
        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: 132
diff changeset
   287
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   288
    if (unlikely(ec_slave_fetch_categories(slave))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   289
        EC_ERR("Failed to fetch category data!\n");
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   290
        return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   291
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   292
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   293
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   294
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   295
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   296
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   297
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   298
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   299
   Reads 16 bit from the slave information interface (SII).
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   300
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   301
   \ingroup Slave
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   302
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   303
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   304
int ec_slave_sii_read16(ec_slave_t *slave,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   305
                        /**< EtherCAT slave */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   306
                        uint16_t offset,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   307
                        /**< address of the SII register to read */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   308
                        uint16_t *target
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   309
                        /**< target memory */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   310
                        )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   311
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   312
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   313
    cycles_t start, end, timeout;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   314
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   315
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   316
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   317
    // initiate read operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   318
    if (ec_command_npwr(command, slave->station_address, 0x502, 6)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   319
    EC_WRITE_U8 (command->data,     0x00); // read-only access
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   320
    EC_WRITE_U8 (command->data + 1, 0x01); // request read operation
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   321
    EC_WRITE_U32(command->data + 2, offset);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   322
    if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   323
        EC_ERR("SII-read failed on slave %i!\n", slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   324
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   325
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   326
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   327
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   328
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   329
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   330
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   331
    {
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   332
        udelay(10);
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   333
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   334
        if (ec_command_nprd(command, slave->station_address, 0x502, 10))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   335
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   336
        if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   337
            EC_ERR("Getting SII-read status failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   338
                   slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   339
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   340
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   341
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   342
        end = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   343
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   344
        // check for "busy bit"
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   345
        if (likely((EC_READ_U8(command->data + 1) & 0x81) == 0)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   346
            *target = EC_READ_U16(command->data + 6);
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   347
            return 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   348
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   349
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   350
        if (unlikely((end - start) >= timeout)) {
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   351
            EC_ERR("SII-read. Slave %i timed out!\n", slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   352
            return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   353
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   354
    }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   355
}
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   356
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   357
/*****************************************************************************/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   358
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   359
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   360
   Reads 32 bit from the slave information interface (SII).
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   361
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   362
   \ingroup Slave
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   363
*/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   364
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   365
int ec_slave_sii_read32(ec_slave_t *slave,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   366
                        /**< EtherCAT slave */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   367
                        uint16_t offset,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   368
                        /**< address of the SII register to read */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   369
                        uint32_t *target
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   370
                        /**< target memory */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   371
                        )
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   372
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   373
    ec_command_t *command;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   374
    cycles_t start, end, timeout;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   375
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   376
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   377
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   378
    // initiate read operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   379
    if (ec_command_npwr(command, slave->station_address, 0x502, 6)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   380
    EC_WRITE_U8 (command->data,     0x00); // read-only access
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   381
    EC_WRITE_U8 (command->data + 1, 0x01); // request read operation
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   382
    EC_WRITE_U32(command->data + 2, offset);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   383
    if (unlikely(ec_master_simple_io(slave->master, command))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   384
        EC_ERR("SII-read failed on slave %i!\n", slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   385
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   386
    }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   387
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   388
    start = get_cycles();
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   389
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   390
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   391
    while (1)
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   392
    {
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   393
        udelay(10);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   394
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   395
        if (ec_command_nprd(command, slave->station_address, 0x502, 10))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   396
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   397
        if (unlikely(ec_master_simple_io(slave->master, command))) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   398
            EC_ERR("Getting SII-read status failed on slave %i!\n",
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   399
                   slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   400
            return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   401
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   402
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   403
        end = get_cycles();
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   404
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   405
        // check "busy bit"
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   406
        if (likely((EC_READ_U8(command->data + 1) & 0x81) == 0)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   407
            *target = EC_READ_U32(command->data + 6);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   408
            return 0;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   409
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   410
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   411
        if (unlikely((end - start) >= timeout)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   412
            EC_ERR("SII-read. Slave %i timed out!\n", slave->ring_position);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   413
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   414
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   415
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   416
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   417
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   418
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   419
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   420
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   421
   Writes 16 bit of data to the slave information interface (SII).
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   422
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   423
   \ingroup Slave
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   424
*/
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   425
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   426
int ec_slave_sii_write16(ec_slave_t *slave,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   427
                         /**< EtherCAT slave */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   428
                         uint16_t offset,
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   429
                         /**< address of the SII register to write */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   430
                         uint16_t value
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   431
                         /**< new value */
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   432
                         )
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   433
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   434
    ec_command_t *command;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   435
    cycles_t start, end, timeout;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   436
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   437
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   438
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   439
    EC_INFO("SII-write (slave %i, offset 0x%04X, value 0x%04X)\n",
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   440
            slave->ring_position, offset, value);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   441
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   442
    // initiate write operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   443
    if (ec_command_npwr(command, slave->station_address, 0x502, 8)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   444
    EC_WRITE_U8 (command->data,     0x01); // enable write access
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   445
    EC_WRITE_U8 (command->data + 1, 0x02); // request write operation
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   446
    EC_WRITE_U32(command->data + 2, offset);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   447
    EC_WRITE_U16(command->data + 6, value);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   448
    if (unlikely(ec_master_simple_io(slave->master, command))) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   449
        EC_ERR("SII-write failed on slave %i!\n", slave->ring_position);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   450
        return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   451
    }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   452
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   453
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   454
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   455
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   456
    while (1)
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   457
    {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   458
        udelay(10);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   459
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   460
        if (ec_command_nprd(command, slave->station_address, 0x502, 2))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   461
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   462
        if (unlikely(ec_master_simple_io(slave->master, command))) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   463
            EC_ERR("Getting SII-write status failed on slave %i!\n",
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   464
                   slave->ring_position);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   465
            return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   466
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   467
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   468
        end = get_cycles();
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   469
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   470
        // check "busy bit"
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   471
        if (likely((EC_READ_U8(command->data + 1) & 0x82) == 0)) {
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   472
            if (EC_READ_U8(command->data + 1) & 0x40) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   473
                EC_ERR("SII-write failed!\n");
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   474
                return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   475
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   476
            else {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   477
                EC_INFO("SII-write succeeded!\n");
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   478
                return 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   479
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   480
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   481
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   482
        if (unlikely((end - start) >= timeout)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   483
            EC_ERR("SII-write: Slave %i timed out!\n", slave->ring_position);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   484
            return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   485
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   486
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   487
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   488
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   489
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   490
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   491
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   492
   Fetches data from slave's EEPROM.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   493
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   494
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   495
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   496
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   497
int ec_slave_fetch_categories(ec_slave_t *slave /**< EtherCAT slave */)
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   498
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   499
    uint16_t word_offset, cat_type, word_count;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   500
    uint32_t value;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   501
    uint8_t *cat_data;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   502
    unsigned int i;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   503
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   504
    word_offset = 0x0040;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   505
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   506
    if (!(cat_data = (uint8_t *) kmalloc(0x10000, GFP_KERNEL))) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   507
        EC_ERR("Failed to allocate 64k bytes for category data.\n");
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   508
        return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   509
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   510
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   511
    while (1) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   512
        // read category type
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   513
        if (ec_slave_sii_read32(slave, word_offset, &value)) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   514
            EC_ERR("Unable to read category header.\n");
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   515
            goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   516
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   517
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   518
        // last category?
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   519
        if ((value & 0xFFFF) == 0xFFFF) break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   520
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   521
        cat_type = value & 0x7FFF;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   522
        word_count = (value >> 16) & 0xFFFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   523
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   524
        // fetch category data
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   525
        for (i = 0; i < word_count; i++) {
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   526
            if (ec_slave_sii_read32(slave, word_offset + 2 + i, &value)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   527
                EC_ERR("Unable to read category data word %i.\n", i);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   528
                goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   529
            }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   530
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   531
            cat_data[i * 2]     = (value >> 0) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   532
            cat_data[i * 2 + 1] = (value >> 8) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   533
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   534
            // read second word "on the fly"
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   535
            if (i + 1 < word_count) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   536
                i++;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   537
                cat_data[i * 2]     = (value >> 16) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   538
                cat_data[i * 2 + 1] = (value >> 24) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   539
            }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   540
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   541
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   542
        switch (cat_type)
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   543
        {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   544
            case 0x000A:
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   545
                if (ec_slave_fetch_strings(slave, cat_data))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   546
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   547
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   548
            case 0x001E:
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   549
                if (ec_slave_fetch_general(slave, cat_data))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   550
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   551
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   552
            case 0x0028:
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   553
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   554
            case 0x0029:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   555
                if (ec_slave_fetch_sync(slave, cat_data, word_count))
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   556
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   557
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   558
            case 0x0032:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   559
                if (ec_slave_fetch_pdo(slave, cat_data, word_count, EC_TX_PDO))
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   560
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   561
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   562
            case 0x0033:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   563
                if (ec_slave_fetch_pdo(slave, cat_data, word_count, EC_RX_PDO))
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   564
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   565
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   566
            default:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   567
                EC_WARN("Unknown category type 0x%04X in slave %i.\n",
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   568
                        cat_type, slave->ring_position);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   569
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   570
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   571
        word_offset += 2 + word_count;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   572
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   573
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   574
    kfree(cat_data);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   575
    return 0;
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   576
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   577
 out_free:
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   578
    kfree(cat_data);
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   579
    return -1;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   580
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   581
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   582
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   583
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   584
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   585
   Fetches data from a STRING category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   586
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   587
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   588
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   589
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   590
int ec_slave_fetch_strings(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   591
                           const uint8_t *data /**< category data */
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   592
                           )
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   593
{
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   594
    unsigned int string_count, i;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   595
    size_t size;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   596
    off_t offset;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   597
    ec_eeprom_string_t *string;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   598
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   599
    string_count = data[0];
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   600
    offset = 1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   601
    for (i = 0; i < string_count; i++) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   602
        size = data[offset];
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   603
        // allocate memory for string structure and data at a single blow
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   604
        if (!(string = (ec_eeprom_string_t *)
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   605
              kmalloc(sizeof(ec_eeprom_string_t) + size + 1, GFP_KERNEL))) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   606
            EC_ERR("Failed to allocate string memory.\n");
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   607
            return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   608
        }
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   609
        string->size = size;
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 160
diff changeset
   610
        // string memory appended to string structure
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   611
        string->data = (char *) string + sizeof(ec_eeprom_string_t);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   612
        memcpy(string->data, data + offset + 1, size);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   613
        string->data[size] = 0x00;
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   614
        list_add_tail(&string->list, &slave->eeprom_strings);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   615
        offset += 1 + size;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   616
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   617
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   618
    return 0;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   619
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   620
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   621
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   622
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   623
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   624
   Fetches data from a GENERAL category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   625
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   626
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   627
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   628
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   629
int ec_slave_fetch_general(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   630
                           const uint8_t *data /**< category data */
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   631
                           )
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   632
{
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   633
    unsigned int i;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   634
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   635
    if (ec_slave_locate_string(slave, data[0], &slave->eeprom_group))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   636
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   637
    if (ec_slave_locate_string(slave, data[1], &slave->eeprom_name))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   638
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   639
    if (ec_slave_locate_string(slave, data[3], &slave->eeprom_desc))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   640
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   641
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   642
    for (i = 0; i < 4; i++)
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   643
        slave->sii_physical_layer[i] =
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   644
            (data[4] & (0x03 << (i * 2))) >> (i * 2);
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
   645
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   646
    return 0;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   647
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   648
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   649
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   650
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   651
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   652
   Fetches data from a SYNC MANAGER category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   653
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   654
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   655
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   656
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   657
int ec_slave_fetch_sync(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   658
                        const uint8_t *data, /**< category data */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   659
                        size_t word_count /**< number of words */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   660
                        )
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   661
{
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   662
    unsigned int sync_count, i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   663
    ec_eeprom_sync_t *sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   664
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   665
    sync_count = word_count / 4; // sync manager struct is 4 words long
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   666
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   667
    for (i = 0; i < sync_count; i++, data += 8) {
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   668
        if (!(sync = (ec_eeprom_sync_t *)
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   669
              kmalloc(sizeof(ec_eeprom_sync_t), GFP_KERNEL))) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   670
            EC_ERR("Failed to allocate Sync-Manager memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   671
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   672
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   673
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   674
        sync->index = i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   675
        sync->physical_start_address = *((uint16_t *) (data + 0));
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   676
        sync->length                 = *((uint16_t *) (data + 2));
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   677
        sync->control_register       = data[4];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   678
        sync->enable                 = data[6];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   679
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   680
        list_add_tail(&sync->list, &slave->eeprom_syncs);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   681
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   682
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   683
    return 0;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   684
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   685
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   686
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   687
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   688
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   689
   Fetches data from a [RT]XPDO category.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   690
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   691
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   692
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   693
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   694
int ec_slave_fetch_pdo(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   695
                       const uint8_t *data, /**< category data */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   696
                       size_t word_count, /**< number of words */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   697
                       ec_pdo_type_t pdo_type /**< PDO type */
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   698
                       )
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   699
{
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   700
    ec_eeprom_pdo_t *pdo;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   701
    ec_eeprom_pdo_entry_t *entry;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   702
    unsigned int entry_count, i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   703
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   704
    while (word_count >= 4) {
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   705
        if (!(pdo = (ec_eeprom_pdo_t *)
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   706
              kmalloc(sizeof(ec_eeprom_pdo_t), GFP_KERNEL))) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   707
            EC_ERR("Failed to allocate PDO memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   708
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   709
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   710
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   711
        INIT_LIST_HEAD(&pdo->entries);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   712
        pdo->type = pdo_type;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   713
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   714
        pdo->index = *((uint16_t *) data);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   715
        entry_count = data[2];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   716
        pdo->sync_manager = data[3];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   717
        pdo->name = NULL;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   718
        ec_slave_locate_string(slave, data[5], &pdo->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   719
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   720
        list_add_tail(&pdo->list, &slave->eeprom_pdos);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   721
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   722
        word_count -= 4;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   723
        data += 8;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   724
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   725
        for (i = 0; i < entry_count; i++) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   726
            if (!(entry = (ec_eeprom_pdo_entry_t *)
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   727
                  kmalloc(sizeof(ec_eeprom_pdo_entry_t), GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   728
                EC_ERR("Failed to allocate PDO entry memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   729
                return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   730
            }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   731
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   732
            entry->index = *((uint16_t *) data);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   733
            entry->subindex = data[2];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   734
            entry->name = NULL;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   735
            ec_slave_locate_string(slave, data[3], &entry->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   736
            entry->bit_length = data[5];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   737
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   738
            list_add_tail(&entry->list, &pdo->entries);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   739
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   740
            word_count -= 4;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   741
            data += 8;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   742
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   743
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   744
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   745
    return 0;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   746
}
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   747
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   748
/*****************************************************************************/
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   749
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   750
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   751
   Searches the string list for an index and allocates a new string.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   752
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   753
   \ingroup Slave
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   754
   \todo documentation
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   755
*/
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   756
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   757
int ec_slave_locate_string(ec_slave_t *slave, /**< EtherCAT slave */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   758
                           unsigned int index, /**< string index */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   759
                           char **ptr /**< Address of the string pointer */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   760
                           )
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   761
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   762
    ec_eeprom_string_t *string;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   763
    char *err_string;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   764
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   765
    // Erst alten Speicher freigeben
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   766
    if (*ptr) {
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   767
        kfree(*ptr);
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   768
        *ptr = NULL;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   769
    }
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   770
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   771
    // Index 0 bedeutet "nicht belegt"
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   772
    if (!index) return 0;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   773
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   774
    // EEPROM-String mit Index finden und kopieren
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   775
    list_for_each_entry(string, &slave->eeprom_strings, list) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   776
        if (--index) continue;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   777
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   778
        if (!(*ptr = (char *) kmalloc(string->size + 1, GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   779
            EC_ERR("Unable to allocate string memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   780
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   781
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   782
        memcpy(*ptr, string->data, string->size + 1);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   783
        return 0;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   784
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   785
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   786
    EC_WARN("String %i not found in slave %i.\n", index, slave->ring_position);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   787
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   788
    err_string = "(string not found)";
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   789
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   790
    if (!(*ptr = (char *) kmalloc(strlen(err_string) + 1, GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   791
        EC_ERR("Unable to allocate string memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   792
        return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   793
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   794
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   795
    memcpy(*ptr, err_string, strlen(err_string) + 1);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   796
    return 0;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   797
}
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   798
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   799
/*****************************************************************************/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   800
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   801
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   802
   Acknowledges an error after a state transition.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   803
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   804
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   805
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   806
void ec_slave_state_ack(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   807
                        uint8_t state /**< previous state */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   808
                        )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   809
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   810
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   811
    cycles_t start, end, timeout;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   812
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   813
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   814
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   815
    if (ec_command_npwr(command, slave->station_address, 0x0120, 2)) return;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   816
    EC_WRITE_U16(command->data, state | EC_ACK);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   817
    if (unlikely(ec_master_simple_io(slave->master, command))) {
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   818
        EC_WARN("Acknowledge sending failed on slave %i!\n",
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   819
                slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   820
        return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   821
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   822
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   823
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   824
    timeout = (cycles_t) 10 * cpu_khz; // 10ms
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   825
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   826
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   827
    {
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   828
        udelay(100); // wait a little bit...
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   829
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   830
        if (ec_command_nprd(command, slave->station_address, 0x0130, 2))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   831
            return;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   832
        if (unlikely(ec_master_simple_io(slave->master, command))) {
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   833
            EC_WARN("Acknowledge checking failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   834
                    slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   835
            return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   836
        }
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   837
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   838
        end = get_cycles();
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   839
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   840
        if (likely(EC_READ_U8(command->data) == state)) {
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   841
            EC_INFO("Acknowleged state 0x%02X on slave %i.\n", state,
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   842
                    slave->ring_position);
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   843
            return;
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   844
        }
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   845
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   846
        if (unlikely((end - start) >= timeout)) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   847
            EC_WARN("Failed to acknowledge state 0x%02X on slave %i"
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   848
                    " - Timeout!\n", state, slave->ring_position);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   849
            return;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   850
        }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   851
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   852
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   853
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   854
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   855
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   856
/**
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   857
   Reads the AL status code of a slave and displays it.
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   858
   If the AL status code is not supported, or if no error occurred (both
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   859
   resulting in code = 0), nothing is displayed.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   860
   \ingroup Slave
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   861
*/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   862
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   863
void ec_slave_read_al_status_code(ec_slave_t *slave /**< EtherCAT slave */)
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   864
{
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   865
    ec_command_t *command;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   866
    uint16_t code;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   867
    const ec_code_msg_t *al_msg;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   868
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   869
    command = &slave->master->simple_command;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   870
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   871
    if (ec_command_nprd(command, slave->station_address, 0x0134, 2)) return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   872
    if (unlikely(ec_master_simple_io(slave->master, command))) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   873
        EC_WARN("Failed to read AL status code on slave %i!\n",
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   874
                slave->ring_position);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   875
        return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   876
    }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   877
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   878
    if (!(code = EC_READ_U16(command->data))) return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   879
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   880
    for (al_msg = al_status_messages; al_msg->code; al_msg++) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   881
        if (al_msg->code == code) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   882
            EC_ERR("AL status message 0x%04X: \"%s\".\n",
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   883
                   al_msg->code, al_msg->message);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   884
            return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   885
        }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   886
    }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   887
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   888
    EC_ERR("Unknown AL status code 0x%04X.\n", code);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   889
}
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   890
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   891
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   892
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   893
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   894
   Does a state transition.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   895
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   896
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   897
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   898
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   899
int ec_slave_state_change(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   900
                          uint8_t state /**< new state */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   901
                          )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   902
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   903
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   904
    cycles_t start, end, timeout;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   905
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   906
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   907
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   908
    if (ec_command_npwr(command, slave->station_address, 0x0120, 2)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   909
    EC_WRITE_U16(command->data, state);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   910
    if (unlikely(ec_master_simple_io(slave->master, command))) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   911
        EC_ERR("Failed to set state 0x%02X on slave %i!\n",
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   912
               state, slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   913
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   914
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   915
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   916
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   917
    timeout = (cycles_t) 10 * cpu_khz; // 10ms
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   918
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   919
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   920
    {
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   921
        udelay(100); // wait a little bit
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   922
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   923
        if (ec_command_nprd(command, slave->station_address, 0x0130, 2))
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   924
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   925
        if (unlikely(ec_master_simple_io(slave->master, command))) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   926
            EC_ERR("Failed to check state 0x%02X on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   927
                   state, slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   928
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   929
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   930
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   931
        end = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   932
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   933
        if (unlikely(EC_READ_U8(command->data) & 0x10)) { // state change error
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   934
            EC_ERR("Failed to set state 0x%02X - Slave %i refused state change"
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   935
                   " (code 0x%02X)!\n", state, slave->ring_position,
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   936
                   EC_READ_U8(command->data));
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   937
            state = EC_READ_U8(command->data) & 0x0F;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   938
            ec_slave_read_al_status_code(slave);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   939
            ec_slave_state_ack(slave, state);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   940
            return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   941
        }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   942
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   943
        if (likely(EC_READ_U8(command->data) == (state & 0x0F)))
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   944
            return 0; // state change successful
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   945
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   946
        if (unlikely((end - start) >= timeout)) {
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   947
            EC_ERR("Failed to check state 0x%02X of slave %i - Timeout!\n",
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   948
                   state, slave->ring_position);
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   949
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   950
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   951
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   952
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   953
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   954
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   955
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   956
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   957
   Prepares an FMMU configuration.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   958
   Configuration data for the FMMU is saved in the slave structure and is
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   959
   written to the slave in ecrt_master_activate().
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   960
   The FMMU configuration is done in a way, that the complete data range
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   961
   of the corresponding sync manager is covered. Seperate FMMUs arce configured
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   962
   for each domain.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   963
   If the FMMU configuration is already prepared, the function returns with
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   964
   success.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   965
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
   966
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   967
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   968
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   969
int ec_slave_prepare_fmmu(ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   970
                          const ec_domain_t *domain, /**< domain */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   971
                          const ec_sync_t *sync  /**< sync manager */
160
7ddf8367196a Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
   972
                          )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   973
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   974
    unsigned int i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   975
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   976
    // FMMU configuration already prepared?
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   977
    for (i = 0; i < slave->fmmu_count; i++)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   978
        if (slave->fmmus[i].domain == domain && slave->fmmus[i].sync == sync)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   979
            return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   980
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
   981
    // reserve new FMMU...
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   982
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   983
    if (slave->fmmu_count >= slave->base_fmmu_count) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   984
        EC_ERR("Slave %i FMMU limit reached!\n", slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   985
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   986
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   987
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   988
    slave->fmmus[slave->fmmu_count].domain = domain;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   989
    slave->fmmus[slave->fmmu_count].sync = sync;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   990
    slave->fmmus[slave->fmmu_count].logical_start_address = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   991
    slave->fmmu_count++;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   992
    slave->registered = 1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   993
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   994
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   995
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   996
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   997
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   998
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   999
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1000
   Outputs all information about a certain slave.
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1001
   Verbosity:
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1002
   - 0: Only slave types and addresses
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1003
   - 1: with EEPROM information
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1004
   - >1: with SDO dictionaries
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1005
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1006
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1007
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1008
void ec_slave_print(const ec_slave_t *slave, /**< EtherCAT slave */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1009
                    unsigned int verbosity /**< verbosity level */
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1010
                    )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1011
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
  1012
    ec_eeprom_sync_t *sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
  1013
    ec_eeprom_pdo_t *pdo;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1014
    ec_eeprom_pdo_entry_t *pdo_entry;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1015
    ec_sdo_t *sdo;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1016
    ec_sdo_entry_t *sdo_entry;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
  1017
    int first, i;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
  1018
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1019
    if (slave->type) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1020
        EC_INFO("%i) %s %s: %s\n", slave->ring_position,
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1021
                slave->type->vendor_name, slave->type->product_name,
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1022
                slave->type->description);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1023
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1024
    else {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1025
        EC_INFO("%i) UNKNOWN SLAVE: vendor 0x%08X, product 0x%08X\n",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1026
                slave->ring_position, slave->sii_vendor_id,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1027
                slave->sii_product_code);
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1028
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1029
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1030
    if (!verbosity) return;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1031
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1032
    EC_INFO("  Station address: 0x%04X\n", slave->station_address);
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1033
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1034
    EC_INFO("  Data link status:\n");
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1035
    for (i = 0; i < 4; i++) {
190
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1036
        EC_INFO("    Port %i (", i);
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1037
        switch (slave->sii_physical_layer[i]) {
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1038
            case 0x00:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1039
                printk("EBUS");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1040
                break;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1041
            case 0x01:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1042
                printk("100BASE-TX");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1043
                break;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1044
            case 0x02:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1045
                printk("100BASE-FX");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1046
                break;
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1047
            default:
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1048
                printk("unknown");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1049
        }
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1050
        printk(")\n");
4e32bcc6b361 Now fetching port physical layer from EEPROM
Florian Pose <fp@igh-essen.com>
parents: 188
diff changeset
  1051
        EC_INFO("      link %s, loop %s, %s\n",
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1052
                slave->dl_link[i] ? "up" : "down",
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1053
                slave->dl_loop[i] ? "closed" : "open",
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1054
                slave->dl_signal[i] ? "signal detected" : "no signal");
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1055
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1056
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1057
    EC_INFO("  Base information:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1058
    EC_INFO("    Type %u, revision %i, build %i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1059
            slave->base_type, slave->base_revision, slave->base_build);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1060
    EC_INFO("    Supported FMMUs: %i, sync managers: %i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1061
            slave->base_fmmu_count, slave->base_sync_count);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1062
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1063
    if (slave->sii_mailbox_protocols) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1064
        EC_INFO("  Mailbox communication:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1065
        EC_INFO("    RX mailbox: 0x%04X/%i, TX mailbox: 0x%04X/%i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1066
                slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1067
                slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1068
        EC_INFO("    Supported protocols: ");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1069
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1070
        first = 1;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1071
        if (slave->sii_mailbox_protocols & EC_MBOX_AOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1072
            printk("AoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1073
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1074
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1075
        if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1076
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1077
            printk("EoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1078
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1079
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1080
        if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1081
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1082
            printk("CoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1083
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1084
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1085
        if (slave->sii_mailbox_protocols & EC_MBOX_FOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1086
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1087
            printk("FoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1088
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1089
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1090
        if (slave->sii_mailbox_protocols & EC_MBOX_SOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1091
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1092
            printk("SoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1093
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1094
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1095
        if (slave->sii_mailbox_protocols & EC_MBOX_VOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1096
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1097
            printk("VoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1098
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1099
        printk("\n");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1100
    }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1101
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1102
    EC_INFO("  EEPROM data:\n");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1103
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1104
    if (slave->sii_alias)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1105
        EC_INFO("    Configured station alias: 0x%04X (%i)\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1106
                slave->sii_alias, slave->sii_alias);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1107
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1108
    EC_INFO("    Vendor-ID: 0x%08X, Product code: 0x%08X\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1109
            slave->sii_vendor_id, slave->sii_product_code);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1110
    EC_INFO("    Revision number: 0x%08X, Serial number: 0x%08X\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1111
            slave->sii_revision_number, slave->sii_serial_number);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1112
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1113
    if (slave->eeprom_name)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1114
        EC_INFO("    Name: %s\n", slave->eeprom_name);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1115
    if (slave->eeprom_group)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1116
        EC_INFO("    Group: %s\n", slave->eeprom_group);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1117
    if (slave->eeprom_desc)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1118
        EC_INFO("    Description: %s\n", slave->eeprom_desc);
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1119
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1120
    if (!list_empty(&slave->eeprom_syncs)) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1121
        EC_INFO("    Sync-Managers:\n");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1122
        list_for_each_entry(sync, &slave->eeprom_syncs, list) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1123
            EC_INFO("      %i: 0x%04X, length %i, control 0x%02X, %s\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1124
                    sync->index, sync->physical_start_address,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1125
                    sync->length, sync->control_register,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1126
                    sync->enable ? "enable" : "disable");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1127
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1128
    }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1129
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1130
    list_for_each_entry(pdo, &slave->eeprom_pdos, list) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1131
        EC_INFO("    %s \"%s\" (0x%04X), -> Sync-Manager %i\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1132
                pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1133
                pdo->name ? pdo->name : "???",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1134
                pdo->index, pdo->sync_manager);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1135
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1136
        list_for_each_entry(pdo_entry, &pdo->entries, list) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1137
            EC_INFO("      \"%s\" 0x%04X:%X, %i Bit\n",
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1138
                    pdo_entry->name ? pdo_entry->name : "???",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1139
                    pdo_entry->index, pdo_entry->subindex,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1140
                    pdo_entry->bit_length);
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1141
        }
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1142
    }
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1143
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1144
    if (verbosity < 2) return;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1145
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1146
    if (!list_empty(&slave->sdo_dictionary)) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1147
        EC_INFO("    SDO-Dictionary:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1148
        list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1149
            EC_INFO("      0x%04X \"%s\"\n", sdo->index,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1150
                    sdo->name ? sdo->name : "");
175
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
  1151
            EC_INFO("        Object code: 0x%02X\n", sdo->object_code);
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1152
            list_for_each_entry(sdo_entry, &sdo->entries, list) {
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1153
                EC_INFO("        0x%04X:%i \"%s\", type 0x%04X, %i bits\n",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1154
                        sdo->index, sdo_entry->subindex,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1155
                        sdo_entry->name ? sdo_entry->name : "",
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1156
                        sdo_entry->data_type, sdo_entry->bit_length);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1157
            }
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1158
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1159
    }
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1160
}
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1161
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1162
/*****************************************************************************/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1163
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1164
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1165
   Outputs the values of the CRC faoult counters and resets them.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1166
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1167
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1168
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1169
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1170
int ec_slave_check_crc(ec_slave_t *slave /**< EtherCAT slave */)
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1171
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1172
    ec_command_t *command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1173
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1174
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1175
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1176
    if (ec_command_nprd(command, slave->station_address, 0x0300, 4)) return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1177
    if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
  1178
        EC_WARN("Reading CRC fault counters failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1179
                slave->ring_position);
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1180
        return -1;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1181
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1182
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1183
    if (!EC_READ_U32(command->data)) return 0; // no CRC faults
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1184
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1185
    if (EC_READ_U8(command->data))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1186
        EC_WARN("%3i RX-error%s on slave %i, channel A.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1187
                EC_READ_U8(command->data),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1188
                EC_READ_U8(command->data) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1189
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1190
    if (EC_READ_U8(command->data + 1))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1191
        EC_WARN("%3i invalid frame%s on slave %i, channel A.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1192
                EC_READ_U8(command->data + 1),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1193
                EC_READ_U8(command->data + 1) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1194
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1195
    if (EC_READ_U8(command->data + 2))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1196
        EC_WARN("%3i RX-error%s on slave %i, channel B.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1197
                EC_READ_U8(command->data + 2),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1198
                EC_READ_U8(command->data + 2) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1199
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1200
    if (EC_READ_U8(command->data + 3))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1201
        EC_WARN("%3i invalid frame%s on slave %i, channel B.\n",
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1202
                EC_READ_U8(command->data + 3),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1203
                EC_READ_U8(command->data + 3) == 1 ? "" : "s",
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1204
                slave->ring_position);
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1205
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1206
    // reset CRC counters
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1207
    if (ec_command_npwr(command, slave->station_address, 0x0300, 4)) return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1208
    EC_WRITE_U32(command->data, 0x00000000);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1209
    if (unlikely(ec_master_simple_io(slave->master, command))) {
89
e91ef35c36db Wiederholtes Senden, wenn keine Antwort.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
  1210
        EC_WARN("Resetting CRC fault counters failed on slave %i!\n",
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1211
                slave->ring_position);
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1212
        return -1;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1213
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1214
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1215
    return 0;
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1216
}
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1217
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1218
/*****************************************************************************/
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1219
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: 132
diff changeset
  1220
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1221
   Writes the "configured station alias" to the slave's EEPROM.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1222
   \return 0 in case of success, else < 0
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1223
   \ingroup Slave
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1224
*/
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1225
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1226
int ecrt_slave_write_alias(ec_slave_t *slave, /**< EtherCAT slave */
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1227
                           uint16_t alias /**< new alias */
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1228
                           )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1229
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1230
    return ec_slave_sii_write16(slave, 0x0004, alias);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1231
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1232
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1233
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1234
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1235
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1236
   Formats attribute data for SysFS read access.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1237
   \return number of bytes to read
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
  1238
   \ingroup Slave
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1239
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1240
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1241
ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< slave's kobject */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1242
                                struct attribute *attr, /**< attribute */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 190
diff changeset
  1243
                                char *buffer /**< memory to store data */
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1244
                                )
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1245
{
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1246
    ec_slave_t *slave = container_of(kobj, ec_slave_t, kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1247
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1248
    if (attr == &attr_ring_position) {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1249
        return sprintf(buffer, "%i\n", slave->ring_position);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1250
    }
188
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
  1251
    else if (attr == &attr_coupler_address) {
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
  1252
        return sprintf(buffer, "%i:%i\n", slave->coupler_index,
c0e49f4a1c07 Better calc. of coupler address; coupler address in SysFS; better output of ec_list
Florian Pose <fp@igh-essen.com>
parents: 185
diff changeset
  1253
                       slave->coupler_subindex);
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1254
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1255
    else if (attr == &attr_vendor_name) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1256
        if (slave->type)
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1257
            return sprintf(buffer, "%s\n", slave->type->vendor_name);
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1258
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1259
    else if (attr == &attr_product_name) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1260
        if (slave->type)
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1261
            return sprintf(buffer, "%s\n", slave->type->product_name);
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1262
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1263
    else if (attr == &attr_product_desc) {
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1264
        if (slave->type)
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1265
            return sprintf(buffer, "%s\n", slave->type->description);
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1266
    }
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1267
    else if (attr == &attr_type) {
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1268
        if (slave->type) {
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1269
            if (slave->type->special == EC_TYPE_BUS_COUPLER)
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1270
                return sprintf(buffer, "coupler\n");
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1271
            else
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1272
                return sprintf(buffer, "normal\n");
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1273
        }
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1274
    }
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1275
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1276
    return 0;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1277
}
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1278
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1279
/*****************************************************************************/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1280
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1281
const ec_code_msg_t al_status_messages[] = {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1282
    {0x0001, "Unspecified error"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1283
    {0x0011, "Invalud requested state change"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1284
    {0x0012, "Unknown requested state"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1285
    {0x0013, "Bootstrap not supported"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1286
    {0x0014, "No valid firmware"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1287
    {0x0015, "Invalid mailbox configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1288
    {0x0016, "Invalid mailbox configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1289
    {0x0017, "Invalid sync manager configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1290
    {0x0018, "No valid inputs available"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1291
    {0x0019, "No valid outputs"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1292
    {0x001A, "Synchronisation error"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1293
    {0x001B, "Sync manager watchdog"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1294
    {0x0020, "Slave needs cold start"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1295
    {0x0021, "Slave needs INIT"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1296
    {0x0022, "Slave needs PREOP"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1297
    {0x0023, "Slave needs SAVEOP"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1298
    {}
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1299
};
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1300
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1301
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1302
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1303
EXPORT_SYMBOL(ecrt_slave_write_alias);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1304
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1305
/*****************************************************************************/