author | Florian Pose <fp@igh-essen.com> |
Mon, 28 Jul 2008 08:16:01 +0000 | |
branch | stable-1.3 |
changeset 1756 | dbe4a4219aa5 |
parent 1746 | 72e7507b3f1b |
permissions | -rw-r--r-- |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
8 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
12 |
* License, or (at your option) any later version. |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
13 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
17 |
* GNU General Public License for more details. |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
18 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
196
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
201
diff
changeset
|
31 |
* |
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
32 |
*****************************************************************************/ |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
34 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
35 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
EtherCAT master driver module. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
37 |
*/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
38 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
39 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
40 |
|
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include <linux/module.h> |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include <linux/kernel.h> |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include <linux/init.h> |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
184
2fc86cec12df
Macro for SysFS attribute definition
Florian Pose <fp@igh-essen.com>
parents:
178
diff
changeset
|
45 |
#include "globals.h" |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
46 |
#include "master.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
47 |
#include "device.h" |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
48 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
49 |
/*****************************************************************************/ |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
50 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
51 |
#define MAX_MASTERS 5 /**< maximum number of masters */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
52 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
53 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
54 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
55 |
int __init ec_init_module(void); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
56 |
void __exit ec_cleanup_module(void); |
52 | 57 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
58 |
static int ec_mac_parse(uint8_t *, const char *, int); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
59 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
60 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
61 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
62 |
struct kobject kobj; /**< kobject for master module */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
63 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
64 |
static char *main[MAX_MASTERS]; /**< main devices parameter */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
65 |
static char *backup[MAX_MASTERS]; /**< backup devices parameter */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
66 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
67 |
static ec_master_t *masters; /**< master array */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
68 |
static struct semaphore master_sem; /**< master semaphore */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
69 |
static unsigned int master_count; /**< number of masters */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
70 |
static unsigned int backup_count; /**< number of backup devices */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
71 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
72 |
static uint8_t macs[MAX_MASTERS][2][ETH_ALEN]; /**< MAC addresses */ |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
|
1746
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
74 |
char *ec_master_version_str = EC_MASTER_VERSION; /**< master version string */ |
1732
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
75 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
76 |
/*****************************************************************************/ |
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
77 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
78 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
79 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
80 |
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>"); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
81 |
MODULE_DESCRIPTION("EtherCAT master driver module"); |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
MODULE_LICENSE("GPL"); |
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
83 |
MODULE_VERSION(EC_MASTER_VERSION); |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
84 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
85 |
module_param_array(main, charp, &master_count, S_IRUGO); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
86 |
MODULE_PARM_DESC(main, "MAC addresses of main devices"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
87 |
module_param_array(backup, charp, &backup_count, S_IRUGO); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
88 |
MODULE_PARM_DESC(backup, "MAC addresses of backup devices"); |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
89 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
90 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
91 |
|
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
92 |
/*****************************************************************************/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
93 |
|
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
94 |
/** |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
95 |
* Module initialization. |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
96 |
* Initializes \a ec_master_count masters. |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
97 |
* \return 0 on success, else < 0 |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
98 |
*/ |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
99 |
|
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
100 |
int __init ec_init_module(void) |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
{ |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
102 |
int i, ret = 0; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
103 |
|
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
104 |
EC_INFO("Master driver %s\n", EC_MASTER_VERSION); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
105 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
106 |
init_MUTEX(&master_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
107 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
108 |
// init kobject and add it to the hierarchy |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
109 |
memset(&kobj, 0x00, sizeof(struct kobject)); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
110 |
kobject_init(&kobj); // no ktype |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
111 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
112 |
if (kobject_set_name(&kobj, "ethercat")) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
113 |
EC_ERR("Failed to set module kobject name.\n"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
114 |
ret = -ENOMEM; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
115 |
goto out_put; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
116 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
117 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
118 |
if (kobject_add(&kobj)) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
119 |
EC_ERR("Failed to add module kobject.\n"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
120 |
ret = -EEXIST; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
121 |
goto out_put; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
122 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
123 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
124 |
// zero MAC addresses |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
125 |
memset(macs, 0x00, sizeof(uint8_t) * MAX_MASTERS * 2 * ETH_ALEN); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
126 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
127 |
// process MAC parameters |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
128 |
for (i = 0; i < master_count; i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
129 |
if (ec_mac_parse(macs[i][0], main[i], 0)) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
130 |
ret = -EINVAL; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
131 |
goto out_del; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
132 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
133 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
134 |
if (i < backup_count && ec_mac_parse(macs[i][1], backup[i], 1)) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
135 |
ret = -EINVAL; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
136 |
goto out_del; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
137 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
138 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
139 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
140 |
if (master_count) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
141 |
if (!(masters = kmalloc(sizeof(ec_master_t) * master_count, |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
142 |
GFP_KERNEL))) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
143 |
EC_ERR("Failed to allocate memory for EtherCAT masters.\n"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
144 |
ret = -ENOMEM; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
145 |
goto out_del; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
146 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
147 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
148 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
149 |
for (i = 0; i < master_count; i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
150 |
if (ec_master_init(&masters[i], &kobj, i, macs[i][0], macs[i][1])) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
151 |
ret = -EIO; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
152 |
goto out_free_masters; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
153 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
154 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
155 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
156 |
EC_INFO("%u master%s waiting for devices.\n", |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
157 |
master_count, (master_count == 1 ? "" : "s")); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
158 |
return ret; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
159 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
160 |
out_free_masters: |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
161 |
for (i--; i >= 0; i--) ec_master_clear(&masters[i]); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
162 |
kfree(masters); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
163 |
out_del: |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
164 |
kobject_del(&kobj); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
165 |
out_put: |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
166 |
kobject_put(&kobj); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
167 |
return ret; |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
} |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
170 |
/*****************************************************************************/ |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
|
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
173 |
Module cleanup. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
174 |
Clears all master instances. |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
*/ |
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
177 |
void __exit ec_cleanup_module(void) |
27
d75ef6b46e33
EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
{ |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
179 |
unsigned int i; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
180 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
181 |
for (i = 0; i < master_count; i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
182 |
ec_master_clear(&masters[i]); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
183 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
184 |
if (master_count) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
185 |
kfree(masters); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
186 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
187 |
kobject_del(&kobj); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
188 |
kobject_put(&kobj); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
189 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
190 |
EC_INFO("Master module cleaned up.\n"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
191 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
192 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
193 |
/***************************************************************************** |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
194 |
* MAC address functions |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
195 |
****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
196 |
|
1746
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
197 |
/** |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
198 |
* \return true, if two MAC addresses are equal. |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
199 |
*/ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
200 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
201 |
int ec_mac_equal(const uint8_t *mac1, const uint8_t *mac2) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
202 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
203 |
unsigned int i; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
204 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
205 |
for (i = 0; i < ETH_ALEN; i++) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
206 |
if (mac1[i] != mac2[i]) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
207 |
return 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
208 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
209 |
return 1; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
210 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
211 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
212 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
213 |
|
1746
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
214 |
/** |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
215 |
* Print a MAC address to a buffer. |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
216 |
* \return number of bytes written. |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
217 |
*/ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
218 |
|
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
219 |
ssize_t ec_mac_print( |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
220 |
const uint8_t *mac, /**< MAC address */ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
221 |
char *buffer /**< target buffer */ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
222 |
) |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
223 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
224 |
off_t off = 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
225 |
unsigned int i; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
226 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
227 |
for (i = 0; i < ETH_ALEN; i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
228 |
off += sprintf(buffer + off, "%02X", mac[i]); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
229 |
if (i < ETH_ALEN - 1) off += sprintf(buffer + off, ":"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
230 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
231 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
232 |
return off; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
233 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
234 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
235 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
236 |
|
1746
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
237 |
/** |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
238 |
* \return true, if the MAC address is all-zero. |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
239 |
*/ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
240 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
241 |
int ec_mac_is_zero(const uint8_t *mac) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
242 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
243 |
unsigned int i; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
244 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
245 |
for (i = 0; i < ETH_ALEN; i++) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
246 |
if (mac[i]) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
247 |
return 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
248 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
249 |
return 1; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
250 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
251 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
252 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
253 |
|
1746
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
254 |
/** |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
255 |
* \return true, if the given MAC address is the broadcast address. |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
256 |
*/ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
257 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
258 |
int ec_mac_is_broadcast(const uint8_t *mac) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
259 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
260 |
unsigned int i; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
261 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
262 |
for (i = 0; i < ETH_ALEN; i++) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
263 |
if (mac[i] != 0xff) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
264 |
return 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
265 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
266 |
return 1; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
267 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
268 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
269 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
270 |
|
1746
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
271 |
/** |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
272 |
* Parse a MAC address from a string. |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
273 |
* The MAC address must follow the regexp |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
274 |
* "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}". |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
275 |
\return 0 on success, else < 0 |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
276 |
*/ |
72e7507b3f1b
merge -r931:HEAD svn://yak/vol/projekte/msr_messen_steuern_regeln/ethercat/rep/trunk .
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
277 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
278 |
static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
279 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
280 |
unsigned int i, value; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
281 |
const char *orig = src; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
282 |
char *rem; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
283 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
284 |
if (!strlen(src)) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
285 |
if (allow_empty){ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
286 |
return 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
287 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
288 |
else { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
289 |
EC_ERR("MAC address may not be empty.\n"); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
290 |
return -EINVAL; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
291 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
292 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
293 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
294 |
for (i = 0; i < ETH_ALEN; i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
295 |
value = simple_strtoul(src, &rem, 16); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
296 |
if (rem != src + 2 |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
297 |
|| value > 0xFF |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
298 |
|| (i < ETH_ALEN - 1 && *rem != ':')) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
299 |
EC_ERR("Invalid MAC address \"%s\".\n", orig); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
300 |
return -EINVAL; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
301 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
302 |
mac[i] = value; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
303 |
if (i < ETH_ALEN - 1) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
304 |
src = rem + 1; // skip colon |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
305 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
306 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
307 |
return 0; |
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
308 |
} |
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
309 |
|
196
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
310 |
/*****************************************************************************/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
311 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
312 |
/** |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
313 |
Outputs frame contents for debugging purposes. |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
314 |
*/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
315 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
316 |
void ec_print_data(const uint8_t *data, /**< pointer to data */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
317 |
size_t size /**< number of bytes to output */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
318 |
) |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
319 |
{ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
320 |
unsigned int i; |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
321 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
322 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
323 |
for (i = 0; i < size; i++) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
324 |
printk("%02X ", data[i]); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
325 |
if ((i + 1) % 16 == 0) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
326 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
327 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
328 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
329 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
330 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
331 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
332 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
333 |
/*****************************************************************************/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
334 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
335 |
/** |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
336 |
Outputs frame contents and differences for debugging purposes. |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
337 |
*/ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
338 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
339 |
void ec_print_data_diff(const uint8_t *d1, /**< first data */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
340 |
const uint8_t *d2, /**< second data */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
341 |
size_t size /** number of bytes to output */ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
342 |
) |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
343 |
{ |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
344 |
unsigned int i; |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
345 |
|
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
346 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
347 |
for (i = 0; i < size; i++) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
348 |
if (d1[i] == d2[i]) printk(".. "); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
349 |
else printk("%02X ", d2[i]); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
350 |
if ((i + 1) % 16 == 0) { |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
351 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
352 |
EC_DBG(""); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
353 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
354 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
355 |
printk("\n"); |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
356 |
} |
f8a1e9f364a3
Introduced version number define.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
357 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
358 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
359 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
360 |
/** |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
361 |
Prints slave states in clear text. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
362 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
363 |
|
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
364 |
size_t ec_state_string(uint8_t states, /**< slave states */ |
1732
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
365 |
char *buffer /**< target buffer |
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
366 |
(min. EC_STATE_STRING_SIZE bytes) */ |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
367 |
) |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
368 |
{ |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
369 |
off_t off = 0; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
370 |
unsigned int first = 1; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
371 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
372 |
if (!states) { |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
373 |
off += sprintf(buffer + off, "(unknown)"); |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
374 |
return off; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
375 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
376 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
377 |
if (states & EC_SLAVE_STATE_INIT) { |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
378 |
off += sprintf(buffer + off, "INIT"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
379 |
first = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
380 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
381 |
if (states & EC_SLAVE_STATE_PREOP) { |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
382 |
if (!first) off += sprintf(buffer + off, ", "); |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
383 |
off += sprintf(buffer + off, "PREOP"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
384 |
first = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
385 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
386 |
if (states & EC_SLAVE_STATE_SAVEOP) { |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
387 |
if (!first) off += sprintf(buffer + off, ", "); |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
388 |
off += sprintf(buffer + off, "SAVEOP"); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
389 |
first = 0; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
390 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
391 |
if (states & EC_SLAVE_STATE_OP) { |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
392 |
if (!first) off += sprintf(buffer + off, ", "); |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
393 |
off += sprintf(buffer + off, "OP"); |
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
394 |
} |
1732
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
395 |
if (states & EC_SLAVE_STATE_ACK_ERR) { |
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
396 |
if (!first) off += sprintf(buffer + off, " + "); |
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
397 |
off += sprintf(buffer + off, "ERROR"); |
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
398 |
} |
1715
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
399 |
|
e675450f2174
MERGE trunk -r463:494 -> branches/stable-1.1 (Version 1.1)
Florian Pose <fp@igh-essen.com>
parents:
286
diff
changeset
|
400 |
return off; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
401 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
249
diff
changeset
|
402 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
403 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
404 |
* Device interface |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
405 |
*****************************************************************************/ |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
406 |
|
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
407 |
/** |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
408 |
Offers an EtherCAT device to a certain master. |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
409 |
The master decides, if it wants to use the device for EtherCAT operation, |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
410 |
or not. It is important, that the offered net_device is not used by |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
411 |
the kernel IP stack. If the master, accepted the offer, the address of |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
412 |
the newly created EtherCAT device is written to the ecdev pointer, else |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
413 |
the pointer is written to zero. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
414 |
\return 0 on success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
415 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
416 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
417 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
418 |
int ecdev_offer(struct net_device *net_dev, /**< net_device to offer */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
419 |
ec_pollfunc_t poll, /**< device poll function */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
420 |
struct module *module, /**< pointer to the module */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
421 |
ec_device_t **ecdev /**< pointer to store a device on success */ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
422 |
) |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
423 |
{ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
424 |
ec_master_t *master; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
425 |
char str[20]; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
426 |
unsigned int i; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
427 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
428 |
for (i = 0; i < master_count; i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
429 |
master = &masters[i]; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
430 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
431 |
down(&master->device_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
432 |
if (master->main_device.dev) { // master already has a device |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
433 |
up(&master->device_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
434 |
continue; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
435 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
436 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
437 |
if (ec_mac_equal(master->main_mac, net_dev->dev_addr) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
438 |
|| ec_mac_is_broadcast(master->main_mac)) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
439 |
ec_mac_print(net_dev->dev_addr, str); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
440 |
EC_INFO("Accepting device %s for master %u.\n", |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
441 |
str, master->index); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
442 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
443 |
ec_device_attach(&master->main_device, net_dev, poll, module); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
444 |
up(&master->device_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
445 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
446 |
sprintf(net_dev->name, "ec%u", master->index); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
447 |
*ecdev = &master->main_device; // offer accepted |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
448 |
return 0; // no error |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
449 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
450 |
else { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
451 |
up(&master->device_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
452 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
453 |
if (master->debug_level) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
454 |
ec_mac_print(net_dev->dev_addr, str); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
455 |
EC_DBG("Master %u declined device %s.\n", master->index, str); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
456 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
457 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
458 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
459 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
460 |
*ecdev = NULL; // offer declined |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
461 |
return 0; // no error |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
462 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
463 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
464 |
/*****************************************************************************/ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
465 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
466 |
/** |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
467 |
Withdraws an EtherCAT device from the master. |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
468 |
The device is disconnected from the master and all device ressources |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
469 |
are freed. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
470 |
\attention Before calling this function, the ecdev_stop() function has |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
471 |
to be called, to be sure that the master does not use the device any more. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
472 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
473 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
474 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
475 |
void ecdev_withdraw(ec_device_t *device /**< EtherCAT device */) |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
476 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
477 |
ec_master_t *master = device->master; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
478 |
char str[20]; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
479 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
480 |
ec_mac_print(device->dev->dev_addr, str); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
481 |
EC_INFO("Master %u releasing main device %s.\n", master->index, str); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
482 |
|
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
483 |
down(&master->device_sem); |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
484 |
ec_device_detach(device); |
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
485 |
up(&master->device_sem); |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
486 |
} |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
487 |
|
191 | 488 |
/*****************************************************************************/ |
489 |
||
490 |
/** |
|
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
491 |
Opens the network device and makes the master enter IDLE mode. |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
492 |
\return 0 on success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
493 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
494 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
495 |
|
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
496 |
int ecdev_open(ec_device_t *device /**< EtherCAT device */) |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
497 |
{ |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
498 |
if (ec_device_open(device)) { |
191 | 499 |
EC_ERR("Failed to open device!\n"); |
500 |
return -1; |
|
501 |
} |
|
502 |
||
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
503 |
if (ec_master_enter_idle_mode(device->master)) { |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
504 |
EC_ERR("Failed to enter idle mode!\n"); |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
505 |
return -1; |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
506 |
} |
1732
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
507 |
|
191 | 508 |
return 0; |
509 |
} |
|
510 |
||
511 |
/*****************************************************************************/ |
|
512 |
||
513 |
/** |
|
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
514 |
Makes the master leave IDLE mode and closes the network device. |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
515 |
\return 0 on success, else < 0 |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
516 |
\ingroup DeviceInterface |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
517 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
518 |
|
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
519 |
void ecdev_close(ec_device_t *device /**< EtherCAT device */) |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
520 |
{ |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
521 |
ec_master_leave_idle_mode(device->master); |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
522 |
|
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
523 |
if (ec_device_close(device)) |
191 | 524 |
EC_WARN("Failed to close device!\n"); |
525 |
} |
|
526 |
||
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
527 |
/****************************************************************************** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
528 |
* Realtime interface |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
529 |
*****************************************************************************/ |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
530 |
|
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
531 |
/** |
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
532 |
* Returns the version magic of the realtime interface. |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
533 |
* \return ECRT version magic. |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
534 |
* \ingroup RealtimeInterface |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
535 |
*/ |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
536 |
|
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
537 |
unsigned int ecrt_version_magic(void) |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
538 |
{ |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
539 |
return ECRT_VERSION_MAGIC; |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
540 |
} |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
541 |
|
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
542 |
/*****************************************************************************/ |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
543 |
|
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
544 |
/** |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
545 |
Reserves an EtherCAT master for realtime operation. |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
546 |
\return pointer to reserved master, or NULL on error |
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
547 |
\ingroup RealtimeInterface |
91
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
548 |
*/ |
0120d6214948
Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents:
88
diff
changeset
|
549 |
|
178
b84f69db8566
MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents:
161
diff
changeset
|
550 |
ec_master_t *ecrt_request_master(unsigned int master_index |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
191
diff
changeset
|
551 |
/**< master index */ |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
552 |
) |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
553 |
{ |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
554 |
ec_master_t *master; |
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
555 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
556 |
EC_INFO("Requesting master %u...\n", master_index); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
557 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
558 |
if (master_index >= master_count) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
559 |
EC_ERR("Invalid master index %u.\n", master_index); |
191 | 560 |
goto out_return; |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
561 |
} |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
562 |
master = &masters[master_index]; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
563 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
564 |
down(&master_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
565 |
if (master->reserved) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
566 |
up(&master_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
567 |
EC_ERR("Master %u is already in use!\n", master_index); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
568 |
goto out_return; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
569 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
570 |
master->reserved = 1; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
571 |
up(&master_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
572 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
573 |
down(&master->device_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
574 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
575 |
if (master->mode != EC_MASTER_MODE_IDLE) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
576 |
up(&master->device_sem); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
577 |
EC_ERR("Master %u still waiting for devices!\n", master_index); |
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
578 |
goto out_release; |
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
579 |
} |
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
580 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
581 |
if (!try_module_get(master->main_device.module)) { |
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
582 |
up(&master->device_sem); |
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
583 |
EC_ERR("Device module is unloading!\n"); |
191 | 584 |
goto out_release; |
585 |
} |
|
586 |
||
1731
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
587 |
up(&master->device_sem); |
60b2aad9d40b
MERGE trunk -r573:587 -> branches/stable-1.1 (race, bootstrap, mailbox bugfix, debug interface switch)
Florian Pose <fp@igh-essen.com>
parents:
1728
diff
changeset
|
588 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
589 |
if (!master->main_device.link_state) { |
1728
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
590 |
EC_ERR("Link is DOWN.\n"); |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
591 |
goto out_module_put; |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
592 |
} |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
593 |
|
1732
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
594 |
if (ec_master_enter_operation_mode(master)) { |
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
595 |
EC_ERR("Failed to enter OPERATION mode!\n"); |
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
596 |
goto out_module_put; |
1728
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
597 |
} |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
598 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
599 |
EC_INFO("Successfully requested master %u.\n", master_index); |
73
9f4ea66d89a3
Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents:
64
diff
changeset
|
600 |
return master; |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
601 |
|
191 | 602 |
out_module_put: |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
603 |
module_put(master->main_device.module); |
1728
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
604 |
out_release: |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
605 |
master->reserved = 0; |
1728
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
606 |
out_return: |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
607 |
return NULL; |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
608 |
} |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
609 |
|
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
610 |
/*****************************************************************************/ |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
611 |
|
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
612 |
/** |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
613 |
Releases a reserved EtherCAT master. |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
614 |
\ingroup RealtimeInterface |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
615 |
*/ |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
616 |
|
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
617 |
void ecrt_release_master(ec_master_t *master /**< EtherCAT master */) |
4cf9c3e9f0bd
MERGE trunk -r564:568 -> branches/stable-1.1 (doc, master output, atomic flag)
Florian Pose <fp@igh-essen.com>
parents:
1721
diff
changeset
|
618 |
{ |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
619 |
EC_INFO("Releasing master %u...\n", master->index); |
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
620 |
|
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
621 |
if (master->mode != EC_MASTER_MODE_OPERATION) { |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
622 |
EC_WARN("Master %u was was not requested!\n", master->index); |
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
623 |
return; |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
624 |
} |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
625 |
|
1732
1cc865ba17c2
MERGE trunk -r588:681 -> branches/stable-1.1 (Bugfixes, Ack behaviour, CoE via Sysfs, PDO ranges, 2.6.17 support, improved autotools, documentation)
Florian Pose <fp@igh-essen.com>
parents:
1731
diff
changeset
|
626 |
ec_master_leave_operation_mode(master); |
151
1961b674466c
Plugfest: master_open()/close() ausgelagert.
Florian Pose <fp@igh-essen.com>
parents:
127
diff
changeset
|
627 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
628 |
module_put(master->main_device.module); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
629 |
master->reserved = 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
630 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
631 |
EC_INFO("Released master %u.\n", master->index); |
33
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
632 |
} |
f4171b8aadf8
Master-Reservierung und Use-Count f?r NIC-Treiber.
Florian Pose <fp@igh-essen.com>
parents:
27
diff
changeset
|
633 |
|
39
6965c23a6826
likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents:
34
diff
changeset
|
634 |
/*****************************************************************************/ |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
635 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
636 |
/** \cond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
637 |
|
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
638 |
module_init(ec_init_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
639 |
module_exit(ec_cleanup_module); |
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
640 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
641 |
EXPORT_SYMBOL(ecdev_offer); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1739
diff
changeset
|
642 |
EXPORT_SYMBOL(ecdev_withdraw); |
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
643 |
EXPORT_SYMBOL(ecdev_open); |
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
644 |
EXPORT_SYMBOL(ecdev_close); |
104
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
645 |
EXPORT_SYMBOL(ecrt_request_master); |
052bc82d5442
MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents:
101
diff
changeset
|
646 |
EXPORT_SYMBOL(ecrt_release_master); |
1739
5fcbd29151d2
MERGE -r688:759 trunk -> branches/stable-1.2 (release 1.2, part one).
Florian Pose <fp@igh-essen.com>
parents:
1732
diff
changeset
|
647 |
EXPORT_SYMBOL(ecrt_version_magic); |
54
7506e67dd122
Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents:
52
diff
changeset
|
648 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
649 |
/** \endcond */ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
650 |
|
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
651 |
/*****************************************************************************/ |