master/slave.c
author Florian Pose <fp@igh-essen.com>
Tue, 11 Apr 2006 14:38:34 +0000
changeset 189 aabbfdacc2cc
parent 188 c0e49f4a1c07
child 190 4e32bcc6b361
permissions -rw-r--r--
Updated todo.txt
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
 *
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
     5
 *  Methoden für einen EtherCAT-Slave.
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
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
     9
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    11
#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
    12
#include <linux/delay.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    14
#include "globals.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    15
#include "slave.h"
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    16
#include "command.h"
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    17
#include "master.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    19
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    21
int ec_slave_fetch_categories(ec_slave_t *);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    22
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
    23
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
    24
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
    25
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
    26
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
    27
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
    28
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    29
/*****************************************************************************/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    30
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    31
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
    32
EC_SYSFS_READ_ATTR(coupler_address);
184
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    33
EC_SYSFS_READ_ATTR(vendor_name);
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    34
EC_SYSFS_READ_ATTR(product_name);
2fc86cec12df Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents: 183
diff changeset
    35
EC_SYSFS_READ_ATTR(product_desc);
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    36
EC_SYSFS_READ_ATTR(type);
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    37
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    38
static struct attribute *def_attrs[] = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    39
    &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
    40
    &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
    41
    &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
    42
    &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
    43
    &attr_product_desc,
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
    44
    &attr_type,
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    45
    NULL,
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
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    48
static struct sysfs_ops sysfs_ops = {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    49
    .show = &ec_show_slave_attribute,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    50
    .store = NULL
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    51
};
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    52
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    53
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
    54
    .release = ec_slave_clear,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    55
    .sysfs_ops = &sysfs_ops,
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    56
    .default_attrs = def_attrs
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    57
};
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    58
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    59
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
    60
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    61
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
    62
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    63
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
    64
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
   EtherCAT-Slave-Konstruktor.
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    67
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    68
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    69
int ec_slave_init(ec_slave_t *slave, /**< EtherCAT-Slave */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    70
                  ec_master_t *master, /**< EtherCAT-Master */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    71
                  uint16_t ring_position, /**< Ringposition */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    72
                  uint16_t station_address /**< Programmierte Adresse */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    73
                  )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    74
{
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    75
    unsigned int i;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
    76
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    77
    slave->ring_position = ring_position;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    78
    slave->station_address = station_address;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    79
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    80
    // Init kobject and add it to the hierarchy
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    81
    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
    82
    kobject_init(&slave->kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    83
    slave->kobj.ktype = &ktype_ec_slave;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    84
    slave->kobj.parent = &master->kobj;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    85
    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
    86
        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
    87
        kobject_put(&slave->kobj);
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    88
        return -1;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    89
    }
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
    90
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    91
    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
    92
    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
    93
    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
    94
    slave->base_type = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    95
    slave->base_revision = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    96
    slave->base_build = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    97
    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
    98
    slave->base_sync_count = 0;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
    99
    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
   100
    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
   101
    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
   102
    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
   103
    slave->sii_serial_number = 0;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   104
    slave->sii_rx_mailbox_offset = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   105
    slave->sii_rx_mailbox_size = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   106
    slave->sii_tx_mailbox_offset = 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   107
    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
   108
    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
   109
    slave->type = NULL;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   110
    slave->registered = 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   111
    slave->fmmu_count = 0;
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   112
    slave->eeprom_name = NULL;
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   113
    slave->eeprom_group = NULL;
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   114
    slave->eeprom_desc = NULL;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   115
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   116
    ec_command_init(&slave->mbox_command);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   117
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   118
    INIT_LIST_HEAD(&slave->eeprom_strings);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   119
    INIT_LIST_HEAD(&slave->eeprom_syncs);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   120
    INIT_LIST_HEAD(&slave->eeprom_pdos);
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   121
    INIT_LIST_HEAD(&slave->sdo_dictionary);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   122
183
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
   123
    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
   124
        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
   125
        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
   126
        slave->dl_signal[i] = 0;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   127
    }
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   128
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   129
    return 0;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   130
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   131
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   132
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   133
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   134
/**
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   135
   EtherCAT-Slave-Destruktor.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   136
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   137
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   138
void ec_slave_clear(struct kobject *kobj /**< KObject des Slaves */)
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   139
{
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   140
    ec_slave_t *slave;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   141
    ec_eeprom_string_t *string, *next_str;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   142
    ec_eeprom_sync_t *sync, *next_sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   143
    ec_eeprom_pdo_t *pdo, *next_pdo;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   144
    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
   145
    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
   146
    ec_sdo_entry_t *en, *next_en;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   147
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
   148
    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
   149
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   150
    // Alle Strings freigeben
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   151
    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
   152
        list_del(&string->list);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   153
        kfree(string);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   154
    }
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   155
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   156
    // Alle Sync-Manager freigeben
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   157
    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
   158
        list_del(&sync->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   159
        kfree(sync);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   160
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   161
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   162
    // Alle PDOs freigeben
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   163
    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
   164
        list_del(&pdo->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   165
        if (pdo->name) kfree(pdo->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   166
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   167
        // Alle Entries innerhalb eines PDOs freigeben
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   168
        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
   169
            list_del(&entry->list);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   170
            if (entry->name) kfree(entry->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   171
            kfree(entry);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   172
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   173
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   174
        kfree(pdo);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   175
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   176
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   177
    if (slave->eeprom_name) kfree(slave->eeprom_name);
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   178
    if (slave->eeprom_group) kfree(slave->eeprom_group);
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   179
    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
   180
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   181
    // Alle SDOs freigeben
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   182
    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
   183
        list_del(&sdo->list);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   184
        if (sdo->name) kfree(sdo->name);
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 160
diff changeset
   185
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   186
        // Alle Entries freigeben
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   187
        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
   188
            list_del(&en->list);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   189
            kfree(en);
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   190
        }
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   191
        kfree(sdo);
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   192
    }
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   193
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   194
    ec_command_clear(&slave->mbox_command);
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   195
}
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   196
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   197
/*****************************************************************************/
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   198
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   199
/**
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   200
   Liest alle benötigten Informationen aus einem Slave.
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   201
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   202
   \return 0 wenn alles ok, < 0 bei Fehler.
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   203
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   204
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   205
int ec_slave_fetch(ec_slave_t *slave /**< EtherCAT-Slave */)
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   206
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   207
    ec_command_t *command;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   208
    unsigned int i;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   209
    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
   210
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   211
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   212
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   213
    // Read base data
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   214
    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
   215
    if (unlikely(ec_master_simple_io(slave->master, command))) {
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   216
        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
   217
               slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   218
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   219
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   220
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   221
    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
   222
    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
   223
    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
   224
    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
   225
    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
   226
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   227
    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
   228
        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
   229
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   230
    // Read DL status
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   231
    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
   232
    if (unlikely(ec_master_simple_io(slave->master, command))) {
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   233
        EC_ERR("Reading DL status from slave %i failed!\n",
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   234
               slave->ring_position);
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   235
        return -1;
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   236
    }
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   237
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   238
    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
   239
    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
   240
        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
   241
        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
   242
        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
   243
    }
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   244
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   245
    // Read EEPROM data
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   246
    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
   247
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   248
    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
   249
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   250
    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
   251
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   252
    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
   253
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   254
    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
   255
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   256
    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
   257
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   258
    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
   259
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   260
    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
   261
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   262
    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
   263
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   264
    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
   265
        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
   266
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   267
    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
   268
        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
   269
        return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   270
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   271
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   272
    return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   273
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   274
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   275
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   276
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   277
/**
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   278
   Liest 16 Bit aus dem Slave-Information-Interface
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   279
   eines EtherCAT-Slaves.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   280
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   281
   \return 0 bei Erfolg, sonst < 0
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   282
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   283
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   284
int ec_slave_sii_read16(ec_slave_t *slave,
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   285
                        /**< EtherCAT-Slave */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   286
                        uint16_t offset,
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   287
                        /**< Adresse des zu lesenden SII-Registers */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   288
                        uint16_t *target
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   289
                        /**< Speicher für Wert (16-Bit) */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   290
                        )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   291
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   292
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   293
    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
   294
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   295
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   296
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   297
    // Initiate read operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   298
    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
   299
    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
   300
    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
   301
    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
   302
    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
   303
        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
   304
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   305
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   306
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   307
    // Der Slave legt die Informationen des Slave-Information-Interface
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   308
    // in das Datenregister und löscht daraufhin ein Busy-Bit. Solange
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   309
    // den Status auslesen, bis das Bit weg ist.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   310
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   311
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   312
    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
   313
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   314
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   315
    {
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   316
        udelay(10);
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   317
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   318
        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
   319
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   320
        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
   321
            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
   322
                   slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   323
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   324
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   325
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   326
        end = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   327
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   328
        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
   329
            *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
   330
            return 0;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   331
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   332
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   333
        if (unlikely((end - start) >= timeout)) {
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   334
            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
   335
            return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   336
        }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   337
    }
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   338
}
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   339
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   340
/*****************************************************************************/
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   341
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   342
/**
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   343
   Liest 32 Bit aus dem Slave-Information-Interface
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   344
   eines EtherCAT-Slaves.
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   345
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   346
   \return 0 bei Erfolg, sonst < 0
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   347
*/
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
int ec_slave_sii_read32(ec_slave_t *slave,
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   350
                        /**< EtherCAT-Slave */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   351
                        uint16_t offset,
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   352
                        /**< Adresse des zu lesenden SII-Registers */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   353
                        uint32_t *target
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   354
                        /**< Speicher für Wert (32-Bit) */
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
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   357
    ec_command_t *command;
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   358
    cycles_t start, end, timeout;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   359
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   360
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   361
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   362
    // Initiate read operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   363
    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
   364
    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
   365
    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
   366
    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
   367
    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
   368
        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
   369
        return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   370
    }
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
    // Der Slave legt die Informationen des Slave-Information-Interface
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   373
    // in das Datenregister und löscht daraufhin ein Busy-Bit. Solange
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   374
    // den Status auslesen, bis das Bit weg ist.
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   375
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   376
    start = get_cycles();
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   377
    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
   378
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   379
    while (1)
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   380
    {
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   381
        udelay(10);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   382
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   383
        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
   384
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   385
        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
   386
            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
   387
                   slave->ring_position);
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   388
            return -1;
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   389
        }
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
        end = get_cycles();
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   392
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   393
        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
   394
            *target = EC_READ_U32(command->data + 6);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   395
            return 0;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   396
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   397
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   398
        if (unlikely((end - start) >= timeout)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   399
            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
   400
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   401
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   402
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   403
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   404
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   405
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   406
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   407
/**
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   408
   Schreibt 16 Bit Daten in das Slave-Information-Interface
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   409
   eines EtherCAT-Slaves.
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   410
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   411
   \return 0 bei Erfolg, sonst < 0
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   412
*/
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   413
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   414
int ec_slave_sii_write16(ec_slave_t *slave,
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   415
                         /**< EtherCAT-Slave */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   416
                         uint16_t offset,
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   417
                         /**< Adresse des zu lesenden SII-Registers */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   418
                         uint16_t value
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   419
                         /**< Zu schreibender Wert */
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   420
                         )
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   421
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   422
    ec_command_t *command;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   423
    cycles_t start, end, timeout;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   424
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   425
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   426
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   427
    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
   428
            slave->ring_position, offset, value);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   429
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   430
    // Initiate write operation
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   431
    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
   432
    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
   433
    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
   434
    EC_WRITE_U32(command->data + 2, offset);
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   435
    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
   436
    if (unlikely(ec_master_simple_io(slave->master, command))) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   437
        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
   438
        return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   439
    }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   440
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   441
    // Der Slave legt die Informationen des Slave-Information-Interface
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   442
    // in das Datenregister und löscht daraufhin ein Busy-Bit. Solange
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   443
    // den Status auslesen, bis das Bit weg ist.
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   444
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   445
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   446
    timeout = (cycles_t) 100 * cpu_khz; // 100ms
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   447
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   448
    while (1)
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   449
    {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   450
        udelay(10);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   451
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   452
        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
   453
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   454
        if (unlikely(ec_master_simple_io(slave->master, command))) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   455
            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
   456
                   slave->ring_position);
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   457
            return -1;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   458
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   459
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   460
        end = get_cycles();
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   461
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   462
        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
   463
            if (EC_READ_U8(command->data + 1) & 0x40) {
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   464
                EC_ERR("SII-write failed!\n");
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
            else {
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   468
                EC_INFO("SII-write succeeded!\n");
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   469
                return 0;
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   470
            }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   471
        }
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   472
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   473
        if (unlikely((end - start) >= timeout)) {
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   474
            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
   475
            return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   476
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   477
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   478
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   479
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   480
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   481
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   482
/**
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   483
   Holt Daten aus dem EEPROM.
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   484
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   485
   \return 0, wenn alles ok, sonst < 0
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
int ec_slave_fetch_categories(ec_slave_t *slave /**< EtherCAT-Slave */)
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   489
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   490
    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
   491
    uint32_t value;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   492
    uint8_t *cat_data;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   493
    unsigned int i;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   494
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   495
    word_offset = 0x0040;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   496
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   497
    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
   498
        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
   499
        return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   500
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   501
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   502
    while (1) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   503
        // read category type
136
a03a684cac89 Dynamische Mailbox-Kommunikation, auch mit unbekannten Slaves.
Florian Pose <fp@igh-essen.com>
parents: 135
diff changeset
   504
        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
   505
            EC_ERR("Unable to read category header.\n");
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   506
            goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   507
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   508
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   509
        // Last category?
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   510
        if ((value & 0xFFFF) == 0xFFFF) break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   511
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   512
        cat_type = value & 0x7FFF;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   513
        word_count = (value >> 16) & 0xFFFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   514
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   515
        // Fetch category data
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   516
        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
   517
            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
   518
                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
   519
                goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   520
            }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   521
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   522
            cat_data[i * 2]     = (value >> 0) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   523
            cat_data[i * 2 + 1] = (value >> 8) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   524
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   525
            // read second word "on the fly"
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   526
            if (i + 1 < word_count) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   527
                i++;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   528
                cat_data[i * 2]     = (value >> 16) & 0xFF;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   529
                cat_data[i * 2 + 1] = (value >> 24) & 0xFF;
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
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   532
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   533
        switch (cat_type)
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   534
        {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   535
            case 0x000A:
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   536
                if (ec_slave_fetch_strings(slave, cat_data))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   537
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   538
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   539
            case 0x001E:
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   540
                if (ec_slave_fetch_general(slave, cat_data))
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   541
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   542
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   543
            case 0x0028:
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   544
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   545
            case 0x0029:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   546
                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
   547
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   548
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   549
            case 0x0032:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   550
                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
   551
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   552
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   553
            case 0x0033:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   554
                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
   555
                    goto out_free;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   556
                break;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   557
            default:
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   558
                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
   559
                        cat_type, slave->ring_position);
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   560
        }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   561
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   562
        word_offset += 2 + word_count;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   563
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   564
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   565
    kfree(cat_data);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   566
    return 0;
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   567
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   568
 out_free:
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   569
    kfree(cat_data);
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   570
    return -1;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   571
}
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
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   575
/**
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   576
   Holt die Daten einer String-Kategorie.
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   577
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   578
   \return 0 wenn alles ok, sonst < 0
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   579
*/
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
int ec_slave_fetch_strings(ec_slave_t *slave, /**< EtherCAT-Slave */
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   582
                           const uint8_t *data /**< Kategoriedaten */
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
{
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   585
    unsigned int string_count, i;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   586
    size_t size;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   587
    off_t offset;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   588
    ec_eeprom_string_t *string;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   589
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   590
    string_count = data[0];
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   591
    offset = 1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   592
    for (i = 0; i < string_count; i++) {
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   593
        size = data[offset];
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   594
        // Speicher für String-Objekt und Daten in einem Rutsch allozieren
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   595
        if (!(string = (ec_eeprom_string_t *)
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   596
              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
   597
            EC_ERR("Failed to allocate string memory.\n");
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   598
            return -1;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   599
        }
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   600
        string->size = size;
161
ddb7266d1c56 Bugfix: Discovered memory leak.
Florian Pose <fp@igh-essen.com>
parents: 160
diff changeset
   601
        // string memory appended to string structure
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   602
        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
   603
        memcpy(string->data, data + offset + 1, size);
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   604
        string->data[size] = 0x00;
121
1cd6f7a47b72 Bugfix: Absturz behoben, EEPROM-Infos.
Florian Pose <fp@igh-essen.com>
parents: 119
diff changeset
   605
        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
   606
        offset += 1 + size;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   607
    }
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   608
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   609
    return 0;
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   610
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   611
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   612
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   613
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   614
/**
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   615
   Holt die Daten einer General-Kategorie.
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
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   618
int ec_slave_fetch_general(ec_slave_t *slave, /**< EtherCAT-Slave */
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   619
                           const uint8_t *data /**< Kategorie-Daten */
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   620
                           )
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   621
{
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   622
    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
   623
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   624
    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
   625
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   626
    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
   627
        return -1;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   628
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   629
    return 0;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   630
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   631
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   632
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   633
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   634
/**
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   635
   Holt die Daten einer Sync-Manager-Kategorie.
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   636
*/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   637
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   638
int ec_slave_fetch_sync(ec_slave_t *slave, /**< EtherCAT-Slave */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   639
                        const uint8_t *data, /**< Kategorie-Daten */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   640
                        size_t word_count /**< Anzahl Words */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   641
                        )
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   642
{
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   643
    unsigned int sync_count, i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   644
    ec_eeprom_sync_t *sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   645
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   646
    sync_count = word_count / 4; // Sync-Manager-Strunktur ist 4 Worte lang
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   647
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   648
    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
   649
        if (!(sync = (ec_eeprom_sync_t *)
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   650
              kmalloc(sizeof(ec_eeprom_sync_t), GFP_KERNEL))) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   651
            EC_ERR("Failed to allocate Sync-Manager memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   652
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   653
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   654
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   655
        sync->index = i;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   656
        sync->physical_start_address = *((uint16_t *) (data + 0));
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   657
        sync->length                 = *((uint16_t *) (data + 2));
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   658
        sync->control_register       = data[4];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   659
        sync->enable                 = data[6];
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
        list_add_tail(&sync->list, &slave->eeprom_syncs);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   662
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   663
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   664
    return 0;
118
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   665
}
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   666
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   667
/*****************************************************************************/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   668
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   669
/**
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   670
   Holt die Daten einer TXPDO-Kategorie.
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   671
*/
dc71ce4cc641 Kategorie-Daten aus EEPROM lesen.
Florian Pose <fp@igh-essen.com>
parents: 114
diff changeset
   672
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   673
int ec_slave_fetch_pdo(ec_slave_t *slave, /**< EtherCAT-Slave */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   674
                       const uint8_t *data, /**< Kategorie-Daten */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   675
                       size_t word_count, /**< Anzahl Worte */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   676
                       ec_pdo_type_t pdo_type /**< PDO-Typ */
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   677
                       )
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   678
{
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   679
    ec_eeprom_pdo_t *pdo;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   680
    ec_eeprom_pdo_entry_t *entry;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   681
    unsigned int entry_count, i;
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
    while (word_count >= 4) {
127
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   684
        if (!(pdo = (ec_eeprom_pdo_t *)
e67c80a76de4 Code aufger?umt und kleines Speicherleck entdeckt.
Florian Pose <fp@igh-essen.com>
parents: 126
diff changeset
   685
              kmalloc(sizeof(ec_eeprom_pdo_t), GFP_KERNEL))) {
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   686
            EC_ERR("Failed to allocate PDO memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   687
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   688
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   689
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   690
        INIT_LIST_HEAD(&pdo->entries);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   691
        pdo->type = pdo_type;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   692
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   693
        pdo->index = *((uint16_t *) data);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   694
        entry_count = data[2];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   695
        pdo->sync_manager = data[3];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   696
        pdo->name = NULL;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   697
        ec_slave_locate_string(slave, data[5], &pdo->name);
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
        list_add_tail(&pdo->list, &slave->eeprom_pdos);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   700
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   701
        word_count -= 4;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   702
        data += 8;
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
        for (i = 0; i < entry_count; i++) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   705
            if (!(entry = (ec_eeprom_pdo_entry_t *)
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   706
                  kmalloc(sizeof(ec_eeprom_pdo_entry_t), GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   707
                EC_ERR("Failed to allocate PDO entry 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
            entry->index = *((uint16_t *) data);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   712
            entry->subindex = data[2];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   713
            entry->name = NULL;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   714
            ec_slave_locate_string(slave, data[3], &entry->name);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   715
            entry->bit_length = data[5];
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   716
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   717
            list_add_tail(&entry->list, &pdo->entries);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   718
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   719
            word_count -= 4;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   720
            data += 8;
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
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   723
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   724
    return 0;
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   725
}
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   726
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   727
/*****************************************************************************/
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   728
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
   729
/**
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   730
   Durchsucht die temporären Strings und dupliziert den gefundenen String.
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   731
*/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   732
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   733
int ec_slave_locate_string(ec_slave_t *slave, unsigned int index, char **ptr)
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   734
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   735
    ec_eeprom_string_t *string;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   736
    char *err_string;
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
    // Erst alten Speicher freigeben
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   739
    if (*ptr) {
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   740
        kfree(*ptr);
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   741
        *ptr = NULL;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   742
    }
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   743
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   744
    // Index 0 bedeutet "nicht belegt"
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   745
    if (!index) return 0;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   746
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   747
    // EEPROM-String mit Index finden und kopieren
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   748
    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
   749
        if (--index) continue;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   750
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   751
        if (!(*ptr = (char *) kmalloc(string->size + 1, GFP_KERNEL))) {
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   752
            EC_ERR("Unable to allocate string memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   753
            return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   754
        }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   755
        memcpy(*ptr, string->data, string->size + 1);
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   756
        return 0;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   757
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   758
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   759
    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
   760
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   761
    err_string = "(string not found)";
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   762
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   763
    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
   764
        EC_ERR("Unable to allocate string memory.\n");
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   765
        return -1;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   766
    }
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   767
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   768
    memcpy(*ptr, err_string, strlen(err_string) + 1);
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   769
    return 0;
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   770
}
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   771
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   772
/*****************************************************************************/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   773
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
   774
/**
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   775
   Bestätigt einen Fehler beim Zustandswechsel.
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   776
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   777
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   778
void ec_slave_state_ack(ec_slave_t *slave,
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   779
                        /**< Slave, dessen Zustand geändert werden soll */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   780
                        uint8_t state
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   781
                        /**< Alter Zustand */
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   782
                        )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   783
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   784
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   785
    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
   786
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   787
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   788
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   789
    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
   790
    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
   791
    if (unlikely(ec_master_simple_io(slave->master, command))) {
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   792
        EC_WARN("Acknowledge sending failed on slave %i!\n",
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   793
                slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   794
        return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   795
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   796
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   797
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   798
    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
   799
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   800
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   801
    {
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   802
        udelay(100); // Dem Slave etwas Zeit lassen...
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   803
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   804
        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
   805
            return;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   806
        if (unlikely(ec_master_simple_io(slave->master, command))) {
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   807
            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
   808
                    slave->ring_position);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   809
            return;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   810
        }
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   811
163
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   812
        end = get_cycles();
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   813
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   814
        if (likely(EC_READ_U8(command->data) == state)) {
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   815
            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
   816
                    slave->ring_position);
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   817
            return;
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   818
        }
a1eea08070e1 Fixed state acknowledgement.
Florian Pose <fp@igh-essen.com>
parents: 161
diff changeset
   819
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   820
        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
   821
            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
   822
                    " - Timeout!\n", state, slave->ring_position);
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   823
            return;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   824
        }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   825
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   826
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   827
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   828
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   829
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   830
/**
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   831
   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
   832
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   833
   If the AL status code is not supported, or if no error occurred (both
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   834
   resulting in code=0), nothing is displayed.
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   835
*/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   836
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   837
void ec_slave_read_al_status_code(ec_slave_t *slave /**< EtherCAT-Slave */)
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   838
{
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   839
    ec_command_t *command;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   840
    uint16_t code;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   841
    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
   842
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   843
    command = &slave->master->simple_command;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   844
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   845
    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
   846
    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
   847
        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
   848
                slave->ring_position);
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   849
        return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   850
    }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   851
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   852
    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
   853
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   854
    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
   855
        if (al_msg->code == code) {
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   856
            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
   857
                   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
   858
            return;
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   859
        }
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   860
    }
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
    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
   863
}
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
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   866
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
   867
/**
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   868
   Ändert den Zustand eines Slaves.
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   869
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   870
   \return 0 bei Erfolg, sonst < 0
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   871
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   872
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   873
int ec_slave_state_change(ec_slave_t *slave,
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   874
                          /**< Slave, dessen Zustand geändert werden soll */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   875
                          uint8_t state
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   876
                          /**< Neuer Zustand */
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   877
                          )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   878
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   879
    ec_command_t *command;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   880
    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
   881
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   882
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   883
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   884
    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
   885
    EC_WRITE_U16(command->data, state);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   886
    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
   887
        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
   888
               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
   889
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   890
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   891
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   892
    start = get_cycles();
119
b2de89096010 Verschiedene Timeouts verl?ngert.
Florian Pose <fp@igh-essen.com>
parents: 118
diff changeset
   893
    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
   894
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   895
    while (1)
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   896
    {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   897
        udelay(100); // Dem Slave etwas Zeit lassen...
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   898
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   899
        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
   900
            return -1;
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   901
        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
   902
            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
   903
                   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
   904
            return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   905
        }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   906
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   907
        end = get_cycles();
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   908
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   909
        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
   910
            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
   911
                   " (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
   912
                   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
   913
            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
   914
            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
   915
            ec_slave_state_ack(slave, state);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   916
            return -1;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   917
        }
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   918
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
   919
        if (likely(EC_READ_U8(command->data) == (state & 0x0F))) {
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   920
            // State change successful
113
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   921
            return 0;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   922
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   923
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   924
        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
   925
            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
   926
                   state, slave->ring_position);
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   927
            return -1;
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   928
        }
a3dbd6bc8fce Do-Schleifen ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   929
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   930
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   931
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   932
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   933
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   934
/**
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   935
   Merkt eine FMMU-Konfiguration vor.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   936
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   937
   Die FMMU wird so konfiguriert, dass sie den gesamten Datenbereich des
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   938
   entsprechenden Sync-Managers abdeckt. Für jede Domäne werden separate
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   939
   FMMUs konfiguriert.
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   940
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   941
   Wenn die entsprechende FMMU bereits konfiguriert ist, wird dies als
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   942
   Erfolg zurückgegeben.
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   943
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   944
   \return 0 bei Erfolg, sonst < 0
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   945
*/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   946
160
7ddf8367196a Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
   947
int ec_slave_prepare_fmmu(ec_slave_t *slave, /**< EtherCAT-Slave */
7ddf8367196a Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
   948
                          const ec_domain_t *domain, /**< Domäne */
7ddf8367196a Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
   949
                          const ec_sync_t *sync  /**< Sync-Manager */
7ddf8367196a Renamed slave_set_fmmu() to slave_prepare_fmmu().
Florian Pose <fp@igh-essen.com>
parents: 157
diff changeset
   950
                          )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   951
{
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   952
    unsigned int i;
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
    // FMMU schon vorgemerkt?
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   955
    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
   956
        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
   957
            return 0;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   958
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   959
    // Neue FMMU reservieren...
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 89
diff changeset
   960
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   961
    if (slave->fmmu_count >= slave->base_fmmu_count) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
   962
        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
   963
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   964
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   965
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   966
    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
   967
    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
   968
    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
   969
    slave->fmmu_count++;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   970
    slave->registered = 1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   971
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   972
    return 0;
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
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   975
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   976
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   977
/**
122
132c3ffc8dea "kaputte" Umlaute korrigiert.
Florian Pose <fp@igh-essen.com>
parents: 121
diff changeset
   978
   Gibt alle Informationen über einen EtherCAT-Slave aus.
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   979
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   980
   Verbosity:
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   981
     0 - Nur Slavetypen und Adressen
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   982
     1 - mit EEPROM-Informationen
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   983
    >1 - mit SDO-Dictionaries
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   984
*/
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   985
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   986
void ec_slave_print(const ec_slave_t *slave, /**< EtherCAT-Slave */
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   987
                    unsigned int verbosity /**< Geschwätzigkeit */
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
   988
                    )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   989
{
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   990
    ec_eeprom_sync_t *sync;
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   991
    ec_eeprom_pdo_t *pdo;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   992
    ec_eeprom_pdo_entry_t *pdo_entry;
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
   993
    ec_sdo_t *sdo;
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
   994
    ec_sdo_entry_t *sdo_entry;
142
e933f1adb550 Link Status ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 140
diff changeset
   995
    int first, i;
126
bbc963b9fead Restliche EEPROM-Daten ausgelesen.
Florian Pose <fp@igh-essen.com>
parents: 124
diff changeset
   996
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
   997
    if (slave->type) {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
   998
        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
   999
                slave->type->vendor_name, slave->type->product_name,
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 77
diff changeset
  1000
                slave->type->description);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1001
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1002
    else {
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1003
        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
  1004
                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
  1005
                slave->sii_product_code);
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1006
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1007
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1008
    if (!verbosity) return;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1009
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1010
    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
  1011
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1012
    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
  1013
    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
  1014
        EC_INFO("    Port %i: link %s, loop %s, %s\n", i,
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1015
                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
  1016
                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
  1017
                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
  1018
    }
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1019
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1020
    EC_INFO("  Base information:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1021
    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
  1022
            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
  1023
    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
  1024
            slave->base_fmmu_count, slave->base_sync_count);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1025
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1026
    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
  1027
        EC_INFO("  Mailbox communication:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1028
        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
  1029
                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
  1030
                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
  1031
        EC_INFO("    Supported protocols: ");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1032
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1033
        first = 1;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1034
        if (slave->sii_mailbox_protocols & EC_MBOX_AOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1035
            printk("AoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1036
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1037
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1038
        if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1039
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1040
            printk("EoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1041
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1042
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1043
        if (slave->sii_mailbox_protocols & EC_MBOX_COE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1044
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1045
            printk("CoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1046
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1047
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1048
        if (slave->sii_mailbox_protocols & EC_MBOX_FOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1049
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1050
            printk("FoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1051
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1052
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1053
        if (slave->sii_mailbox_protocols & EC_MBOX_SOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1054
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1055
            printk("SoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1056
            first = 0;
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1057
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1058
        if (slave->sii_mailbox_protocols & EC_MBOX_VOE) {
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1059
            if (!first) printk(", ");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1060
            printk("VoE");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1061
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1062
        printk("\n");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1063
    }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1064
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1065
    EC_INFO("  EEPROM data:\n");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1066
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1067
    if (slave->sii_alias)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1068
        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
  1069
                slave->sii_alias, slave->sii_alias);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1070
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1071
    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
  1072
            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
  1073
    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
  1074
            slave->sii_revision_number, slave->sii_serial_number);
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1075
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1076
    if (slave->eeprom_name)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1077
        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
  1078
    if (slave->eeprom_group)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1079
        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
  1080
    if (slave->eeprom_desc)
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1081
        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
  1082
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1083
    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
  1084
        EC_INFO("    Sync-Managers:\n");
147
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1085
        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
  1086
            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
  1087
                    sync->index, sync->physical_start_address,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1088
                    sync->length, sync->control_register,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1089
                    sync->enable ? "enable" : "disable");
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1090
        }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1091
    }
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1092
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1093
    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
  1094
        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
  1095
                pdo->type == EC_RX_PDO ? "RXPDO" : "TXPDO",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1096
                pdo->name ? pdo->name : "???",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1097
                pdo->index, pdo->sync_manager);
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
        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
  1100
            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
  1101
                    pdo_entry->name ? pdo_entry->name : "???",
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1102
                    pdo_entry->index, pdo_entry->subindex,
a355b587b4bc Ausgaben verbessert, Mini-Modul angepasst.
Florian Pose <fp@igh-essen.com>
parents: 145
diff changeset
  1103
                    pdo_entry->bit_length);
140
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1104
        }
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1105
    }
b09658e50d6f Verbosity level in ecrt_master_print().
Florian Pose <fp@igh-essen.com>
parents: 139
diff changeset
  1106
157
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1107
    if (verbosity < 2) return;
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1108
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1109
    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
  1110
        EC_INFO("    SDO-Dictionary:\n");
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1111
        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
  1112
            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
  1113
                    sdo->name ? sdo->name : "");
175
2e4b18203ade Altered CoE "Get object description response" fields
Florian Pose <fp@igh-essen.com>
parents: 164
diff changeset
  1114
            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
  1115
            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
  1116
                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
  1117
                        sdo->index, sdo_entry->subindex,
37c6dd0ff0b1 Bugfix: Crash after failing to fetch SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents: 155
diff changeset
  1118
                        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
  1119
                        sdo_entry->data_type, sdo_entry->bit_length);
139
998215ab9b92 Laden der SDO-Subindizes.
Florian Pose <fp@igh-essen.com>
parents: 138
diff changeset
  1120
            }
135
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1121
        }
80d493917205 Laden der SDO Dictionaries funktioniert.
Florian Pose <fp@igh-essen.com>
parents: 133
diff changeset
  1122
    }
123
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1123
}
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1124
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1125
/*****************************************************************************/
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1126
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1127
/**
4d5dc58d48e2 Weitere EEPROM-Daten.
Florian Pose <fp@igh-essen.com>
parents: 122
diff changeset
  1128
   Gibt die Zählerstände der CRC-Fault-Counter aus und setzt diese zurück.
74
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1129
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1130
   \return 0 bei Erfolg, sonst < 0
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1131
*/
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1132
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1133
int ec_slave_check_crc(ec_slave_t *slave /**< EtherCAT-Slave */)
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1134
{
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1135
    ec_command_t *command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1136
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1137
    command = &slave->master->simple_command;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1138
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1139
    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
  1140
    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
  1141
        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
  1142
                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
  1143
        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
  1144
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1145
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1146
    // No CRC faults.
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1147
    if (!EC_READ_U32(command->data)) return 0;
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1148
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1149
    if (EC_READ_U8(command->data))
132
63a5b40eb7da CRC-Counter nach ESC-Datasheet implementiert.
Florian Pose <fp@igh-essen.com>
parents: 127
diff changeset
  1150
        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
  1151
                EC_READ_U8(command->data),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1152
                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
  1153
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1154
    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
  1155
        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
  1156
                EC_READ_U8(command->data + 1),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1157
                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
  1158
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1159
    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
  1160
        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
  1161
                EC_READ_U8(command->data + 2),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1162
                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
  1163
                slave->ring_position);
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1164
    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
  1165
        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
  1166
                EC_READ_U8(command->data + 3),
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1167
                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
  1168
                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
  1169
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1170
    // Reset CRC counters
144
fdc24bf62f80 Dynamischer Kommandospeicher, Domain-Kommandos als Liste.
Florian Pose <fp@igh-essen.com>
parents: 142
diff changeset
  1171
    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
  1172
    EC_WRITE_U32(command->data, 0x00000000);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
  1173
    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
  1174
        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
  1175
                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
  1176
        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
  1177
    }
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1178
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1179
    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
  1180
}
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
/*****************************************************************************/
9bf603942791 Neues Slave-Interface, CRC-Pr?fung und mehrfaches Scannen nun ungef?hrlich.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
  1183
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
  1184
/**
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1185
   Schreibt den "Configured station alias".
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1186
   \return 0, wenn alles ok, sonst < 0
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1187
*/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1188
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1189
int ecrt_slave_write_alias(ec_slave_t *slave, /** EtherCAT-Slave */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1190
                           uint16_t alias /** Neuer Alias */
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1191
                           )
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1192
{
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1193
    return ec_slave_sii_write16(slave, 0x0004, alias);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1194
}
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1195
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1196
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1197
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1198
/**
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1199
   Formatiert Attribut-Daten für lesenden Zugriff im SysFS
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1200
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1201
   \return Anzahl Bytes im Speicher
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1202
*/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1203
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1204
ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< KObject */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1205
                                struct attribute *attr, /**< Attribut */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1206
                                char *buffer /**< Speicher für die Daten */
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1207
                                )
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1208
{
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1209
    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
  1210
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1211
    if (attr == &attr_ring_position) {
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1212
        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
  1213
    }
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
  1214
    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
  1215
        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
  1216
                       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
  1217
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1218
    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
  1219
        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
  1220
            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
  1221
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1222
    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
  1223
        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
  1224
            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
  1225
    }
8ae1e011e96c More slave fields in SysFS; DL link status for 4 ports
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
  1226
    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
  1227
        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
  1228
            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
  1229
    }
185
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1230
    else if (attr == &attr_type) {
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1231
        if (slave->type) {
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1232
            if (slave->type->special == EC_TYPE_BUS_COUPLER)
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1233
                return sprintf(buffer, "coupler\n");
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1234
            else
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1235
                return sprintf(buffer, "normal\n");
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1236
        }
af570302dcee Slave (special) type in SysFS
Florian Pose <fp@igh-essen.com>
parents: 184
diff changeset
  1237
    }
182
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1238
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1239
    return 0;
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1240
}
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1241
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1242
/*****************************************************************************/
8c0bc99229a9 Slaves stored in list, slaves in SysFS
Florian Pose <fp@igh-essen.com>
parents: 175
diff changeset
  1243
164
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1244
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
  1245
    {0x0001, "Unspecified error"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1246
    {0x0011, "Invalud requested state change"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1247
    {0x0012, "Unknown requested state"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1248
    {0x0013, "Bootstrap not supported"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1249
    {0x0014, "No valid firmware"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1250
    {0x0015, "Invalid mailbox configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1251
    {0x0016, "Invalid mailbox configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1252
    {0x0017, "Invalid sync manager configuration"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1253
    {0x0018, "No valid inputs available"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1254
    {0x0019, "No valid outputs"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1255
    {0x001A, "Synchronisation error"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1256
    {0x001B, "Sync manager watchdog"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1257
    {0x0020, "Slave needs cold start"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1258
    {0x0021, "Slave needs INIT"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1259
    {0x0022, "Slave needs PREOP"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1260
    {0x0023, "Slave needs SAVEOP"},
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1261
    {}
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1262
};
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1263
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1264
/*****************************************************************************/
ed85368b2b2e AL status code reading after failed state transition.
Florian Pose <fp@igh-essen.com>
parents: 163
diff changeset
  1265
138
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1266
EXPORT_SYMBOL(ecrt_slave_write_alias);
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1267
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1268
/*****************************************************************************/
7e743a61a991 SDO-Schnittstelle verbessert.
Florian Pose <fp@igh-essen.com>
parents: 136
diff changeset
  1269
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1270
/* Emacs-Konfiguration
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1271
;;; Local Variables: ***
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
  1272
;;; c-basic-offset:4 ***
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1273
;;; End: ***
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
  1274
*/
114
e4b4b5a85e75 Slave alias implementiert.
Florian Pose <fp@igh-essen.com>
parents: 113
diff changeset
  1275