author | Florian Pose <fp@igh-essen.com> |
Fri, 16 Dec 2011 16:26:16 +0100 | |
changeset 2181 | cac59f7a42c4 |
parent 2094 | 83e9160319ec |
child 2589 | 2b9c78543663 |
permissions | -rw-r--r-- |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
6 |
* |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
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:
195
diff
changeset
|
8 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
11 |
* published by the Free Software Foundation. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
12 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
16 |
* Public License for more details. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
17 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1313
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
197
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b9a6e2c22745
GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents:
195
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
199
diff
changeset
|
27 |
* |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
199
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
30 |
/** |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
31 |
\file |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
32 |
Mailbox functionality. |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
33 |
*/ |
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 |
/*****************************************************************************/ |
04ecf40fc2e9
Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents:
197
diff
changeset
|
36 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <linux/slab.h> |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include <linux/delay.h> |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
40 |
#include "slave.h" |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "mailbox.h" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
42 |
#include "datagram.h" |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "master.h" |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
45 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
46 |
/*****************************************************************************/ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
47 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
48 |
/** |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
49 |
Mailbox constructor. |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
50 |
*/ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
51 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
52 |
void ec_mbox_init(ec_mailbox_t* mbox, /** mailbox */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
53 |
ec_datagram_t* datagram /**< Datagram used for the mailbox content. */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
54 |
) |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
55 |
{ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
56 |
mbox->datagram = datagram; |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
57 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
58 |
ec_datagram_init(&mbox->end_datagram); |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
59 |
#endif |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
60 |
} |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
61 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
62 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
63 |
/*****************************************************************************/ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
64 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
65 |
/** |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
66 |
Clears mailbox datagrams. |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
67 |
*/ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
68 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
69 |
void ec_mbox_clear(ec_mailbox_t* mbox /** mailbox */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
70 |
) |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
71 |
{ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
72 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
73 |
ec_datagram_clear(&mbox->end_datagram); |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
74 |
#endif |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
75 |
} |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
76 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
77 |
|
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
78 |
/*****************************************************************************/ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
79 |
|
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
80 |
/** Queues the slave datagrams. |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
81 |
*/ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
82 |
void ec_slave_mbox_queue_datagrams( |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
83 |
const ec_slave_t *slave, /** slave */ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
84 |
ec_mailbox_t *mbox /** mailbox */ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
85 |
) |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
86 |
{ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
87 |
ec_master_queue_request_fsm_datagram(slave->master, mbox->datagram); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
88 |
|
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
89 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
90 |
if (mbox->end_datagram.type != EC_DATAGRAM_NONE) { |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
91 |
ec_master_queue_request_fsm_datagram(slave->master, |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
92 |
&mbox->end_datagram); |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
93 |
} |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
94 |
#endif |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
95 |
} |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
96 |
|
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
97 |
/*****************************************************************************/ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
98 |
|
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
99 |
/** Queues the datagrams. |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
100 |
*/ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
101 |
void ec_master_mbox_queue_datagrams( |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
102 |
ec_master_t *master, /** master */ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
103 |
ec_mailbox_t *mbox /** mailbox */ |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
104 |
) |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
105 |
{ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
106 |
ec_master_queue_fsm_datagram(master, mbox->datagram); |
2094
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
107 |
|
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
108 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
83e9160319ec
Minor: Fixed line wraps and spacing.
Florian Pose <fp@igh-essen.com>
parents:
2045
diff
changeset
|
109 |
if (mbox->end_datagram.type != EC_DATAGRAM_NONE) { |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
110 |
ec_master_queue_fsm_datagram(master, &mbox->end_datagram); |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
111 |
} |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
112 |
#endif |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
113 |
} |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
114 |
|
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/** |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
118 |
Prepares a mailbox-send datagram. |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
119 |
\return Pointer to mailbox datagram data, or ERR_PTR() code. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
120 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
121 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
122 |
uint8_t *ec_slave_mbox_prepare_send(const ec_slave_t* slave, /** slave */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
123 |
ec_mailbox_t* mbox, /** mailbox */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
124 |
uint8_t type, /**< mailbox protocol */ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
125 |
size_t size /**< size of the data */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
{ |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
128 |
ec_datagram_t* datagram = mbox->datagram; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
size_t total_size; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
130 |
int ret; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
815
diff
changeset
|
132 |
if (unlikely(!slave->sii.mailbox_protocols)) { |
1921 | 133 |
EC_SLAVE_ERR(slave, "Slave does not support mailbox" |
134 |
" communication!\n"); |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
135 |
return ERR_PTR(-EPROTONOSUPPORT); |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
|
1217
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
138 |
total_size = EC_MBOX_HEADER_SIZE + size; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
139 |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
140 |
if (unlikely(total_size > slave->configured_rx_mailbox_size)) { |
1921 | 141 |
EC_SLAVE_ERR(slave, "Data size (%zu) does not fit in mailbox (%u)!\n", |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
142 |
total_size, slave->configured_rx_mailbox_size); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
143 |
return ERR_PTR(-EOVERFLOW); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
144 |
} |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
145 |
|
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
146 |
ret = ec_datagram_fpwr(datagram, slave->station_address, |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
147 |
slave->configured_rx_mailbox_offset, |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
148 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
149 |
total_size |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
150 |
#else |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
151 |
slave->configured_rx_mailbox_size |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
152 |
#endif |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
153 |
); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
154 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
155 |
return ERR_PTR(ret); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
156 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
157 |
EC_WRITE_U16(datagram->data, size); // mailbox service data length |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
158 |
EC_WRITE_U16(datagram->data + 2, slave->station_address); // station addr. |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
159 |
EC_WRITE_U8 (datagram->data + 4, 0x00); // channel & priority |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
160 |
EC_WRITE_U8 (datagram->data + 5, type); // underlying protocol type |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
161 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
162 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
163 |
/* in order to fulfil the ESC's mailbox protocol, |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
164 |
at least the last byte of the mailbox must be written */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
165 |
if (total_size < slave->configured_rx_mailbox_size) { |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
166 |
ret = ec_datagram_fpwr(&mbox->end_datagram, slave->station_address, |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
167 |
slave->configured_rx_mailbox_offset+slave->configured_rx_mailbox_size-1, |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
168 |
1); |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
169 |
if (ret) |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
170 |
return ERR_PTR(ret); |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
171 |
} |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
172 |
#endif |
1217
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
173 |
return datagram->data + EC_MBOX_HEADER_SIZE; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
174 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
175 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
176 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
177 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
178 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
179 |
Prepares a datagram for checking the mailbox state. |
786 | 180 |
\todo Determine sync manager used for receive mailbox |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
181 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
182 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
183 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
184 |
int ec_slave_mbox_prepare_check(const ec_slave_t* slave, /** slave */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
185 |
ec_mailbox_t* mbox /** mailbox */ |
279
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
276
diff
changeset
|
186 |
) |
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
276
diff
changeset
|
187 |
{ |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
188 |
ec_datagram_t* datagram = mbox->datagram; |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
189 |
int ret = ec_datagram_fprd(datagram, slave->station_address, 0x808, 8); |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
190 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
191 |
return ret; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
|
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1217
diff
changeset
|
193 |
ec_datagram_zero(datagram); |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
194 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
195 |
mbox->end_datagram.type = EC_DATAGRAM_NONE; |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
196 |
#endif |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
return 0; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
/** |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
203 |
Processes a mailbox state checking datagram. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
204 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
205 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
206 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
207 |
int ec_slave_mbox_check(ec_mailbox_t* mbox /** mailbox */) |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
208 |
{ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
209 |
return EC_READ_U8(mbox->datagram->data + 5) & 8 ? 1 : 0; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
210 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
211 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
212 |
/*****************************************************************************/ |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
213 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
214 |
/** |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
215 |
Prepares a datagram to fetch mailbox data. |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
216 |
\return 0 in case of success, else < 0 |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
217 |
*/ |
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
218 |
|
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
219 |
int ec_slave_mbox_prepare_fetch(const ec_slave_t* slave, /** slave */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
220 |
ec_mailbox_t* mbox /** mailbox */ |
279
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
276
diff
changeset
|
221 |
) |
12f48c1cb143
Removed mbox_command out of slave.
Florian Pose <fp@igh-essen.com>
parents:
276
diff
changeset
|
222 |
{ |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
223 |
ec_datagram_t* datagram = mbox->datagram; |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
224 |
int ret = ec_datagram_fprd(datagram, slave->station_address, |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
225 |
slave->configured_tx_mailbox_offset, |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
226 |
slave->configured_tx_mailbox_size); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
227 |
if (ret) |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
228 |
return ret; |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1217
diff
changeset
|
229 |
|
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1217
diff
changeset
|
230 |
ec_datagram_zero(datagram); |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
231 |
#ifdef EC_REDUCE_MBOXFRAMESIZE |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
232 |
mbox->end_datagram.type = EC_DATAGRAM_NONE; |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
233 |
#endif |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
return 0; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
} |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
/*****************************************************************************/ |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
|
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
/** |
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
240 |
Mailbox error codes. |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
241 |
*/ |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
242 |
|
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
243 |
const ec_code_msg_t mbox_error_messages[] = { |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
244 |
{0x00000001, "MBXERR_SYNTAX"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
245 |
{0x00000002, "MBXERR_UNSUPPORTEDPROTOCOL"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
246 |
{0x00000003, "MBXERR_INVAILDCHANNEL"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
247 |
{0x00000004, "MBXERR_SERVICENOTSUPPORTED"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
248 |
{0x00000005, "MBXERR_INVALIDHEADER"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
249 |
{0x00000006, "MBXERR_SIZETOOSHORT"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
250 |
{0x00000007, "MBXERR_NOMOREMEMORY"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
251 |
{0x00000008, "MBXERR_INVALIDSIZE"}, |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
252 |
{} |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
253 |
}; |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
254 |
|
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
255 |
/*****************************************************************************/ |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
256 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
257 |
/** Processes received mailbox data. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
258 |
* |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
259 |
* \return Pointer to the received data, or ERR_PTR() code. |
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
260 |
*/ |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
261 |
uint8_t *ec_slave_mbox_fetch(const ec_slave_t* slave, /** slave */ |
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
262 |
ec_mailbox_t* mbox, /** mailbox */ |
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
263 |
uint8_t *type, /**< expected mailbox protocol */ |
195
674071846ee3
Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents:
154
diff
changeset
|
264 |
size_t *size /**< size of the received data */ |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
) |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
{ |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
1921
diff
changeset
|
267 |
ec_datagram_t* datagram = mbox->datagram; |
145
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
size_t data_size; |
11a82e4fd31b
Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
|
431
47e7f99005c0
Improved output at mailbox error.
Florian Pose <fp@igh-essen.com>
parents:
424
diff
changeset
|
270 |
data_size = EC_READ_U16(datagram->data); |
47e7f99005c0
Improved output at mailbox error.
Florian Pose <fp@igh-essen.com>
parents:
424
diff
changeset
|
271 |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
272 |
if (data_size + EC_MBOX_HEADER_SIZE > slave->configured_tx_mailbox_size) { |
1921 | 273 |
EC_SLAVE_ERR(slave, "Corrupt mailbox response received!\n"); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
274 |
ec_print_data(datagram->data, slave->configured_tx_mailbox_size); |
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
275 |
return ERR_PTR(-EPROTO); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
276 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
279
diff
changeset
|
277 |
|
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
278 |
*type = EC_READ_U8(datagram->data + 5) & 0x0F; |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
279 |
*size = data_size; |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
280 |
|
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
281 |
if (*type == 0x00) { |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
282 |
const ec_code_msg_t *mbox_msg; |
1217
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
283 |
uint16_t code = EC_READ_U16(datagram->data + 8); |
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
284 |
|
1921 | 285 |
EC_SLAVE_ERR(slave, "Mailbox error response received - "); |
1217
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
286 |
|
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
287 |
for (mbox_msg = mbox_error_messages; mbox_msg->code; mbox_msg++) { |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
288 |
if (mbox_msg->code != code) |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
289 |
continue; |
431
47e7f99005c0
Improved output at mailbox error.
Florian Pose <fp@igh-essen.com>
parents:
424
diff
changeset
|
290 |
printk("Code 0x%04X: \"%s\".\n", |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
291 |
mbox_msg->code, mbox_msg->message); |
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
292 |
break; |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
293 |
} |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
294 |
|
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
295 |
if (!mbox_msg->code) |
431
47e7f99005c0
Improved output at mailbox error.
Florian Pose <fp@igh-essen.com>
parents:
424
diff
changeset
|
296 |
printk("Unknown error reply code 0x%04X.\n", code); |
47e7f99005c0
Improved output at mailbox error.
Florian Pose <fp@igh-essen.com>
parents:
424
diff
changeset
|
297 |
|
47e7f99005c0
Improved output at mailbox error.
Florian Pose <fp@igh-essen.com>
parents:
424
diff
changeset
|
298 |
if (slave->master->debug_level) |
1217
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
299 |
ec_print_data(datagram->data + EC_MBOX_HEADER_SIZE, data_size); |
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
300 |
|
1313
ed15eef57d5c
Improved error case return codes of many functions.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
301 |
return ERR_PTR(-EPROTO); |
1217
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
302 |
} |
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
303 |
|
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
304 |
return datagram->data + EC_MBOX_HEADER_SIZE; |
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
305 |
} |
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
306 |
|
e8a9785e63c3
Introduced EC_MBOX_HEADER_SIZE.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
307 |
/*****************************************************************************/ |