author | Florian Pose <fp@igh-essen.com> |
Tue, 06 Jul 2010 17:40:20 +0200 | |
changeset 1948 | fa1c4fb0a8da |
parent 1944 | 73896ef6d077 |
child 1952 | 7d9fb723fc4b |
permissions | -rw-r--r-- |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* published by the Free Software Foundation. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* Public License for more details. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* --- |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** \file |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* Sercos-over-EtherCAT request functions. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
#include <linux/module.h> |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include <linux/jiffies.h> |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "soe_request.h" |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
/** Default timeout in ms to wait for SoE responses. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
#define EC_SOE_REQUEST_RESPONSE_TIMEOUT 1000 |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
void ec_soe_request_clear_data(ec_soe_request_t *); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
/** SoE request constructor. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
void ec_soe_request_init( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
ec_soe_request_t *req /**< SoE request. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
{ |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1907
diff
changeset
|
59 |
req->al_state = EC_AL_STATE_INIT; |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
req->data = NULL; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
req->mem_size = 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
req->data_size = 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
req->dir = EC_DIR_INVALID; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
req->state = EC_INT_REQUEST_INIT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
req->jiffies_sent = 0U; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
req->error_code = 0x0000; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
/** SoE request destructor. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
void ec_soe_request_clear( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
ec_soe_request_t *req /**< SoE request. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
ec_soe_request_clear_data(req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
1843
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
82 |
/** Copy another SoE request. |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
83 |
*/ |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
84 |
int ec_soe_request_copy( |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
85 |
ec_soe_request_t *req, /**< SoE request. */ |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
86 |
const ec_soe_request_t *other /**< Other SoE request to copy from. */ |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
87 |
) |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
88 |
{ |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
89 |
req->idn = other->idn; |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1907
diff
changeset
|
90 |
req->al_state = other->al_state; |
1843
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
91 |
return ec_soe_request_copy_data(req, other->data, other->data_size); |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
92 |
} |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
93 |
|
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
94 |
/*****************************************************************************/ |
4d44d8bee580
Added ec_soe_request_copy() method.
Florian Pose <fp@igh-essen.com>
parents:
1831
diff
changeset
|
95 |
|
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
/** Set IDN. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
void ec_soe_request_set_idn( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
ec_soe_request_t *req, /**< SoE request. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
uint16_t idn /** IDN. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
req->idn = idn; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
/** Free allocated memory. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
void ec_soe_request_clear_data( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
ec_soe_request_t *req /**< SoE request. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
if (req->data) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
kfree(req->data); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
req->data = NULL; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
req->mem_size = 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
req->data_size = 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
/** Pre-allocates the data memory. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
* If the \a mem_size is already bigger than \a size, nothing is done. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
* \return 0 on success, otherwise -ENOMEM. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
int ec_soe_request_alloc( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
ec_soe_request_t *req, /**< SoE request. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
size_t size /**< Data size to allocate. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
if (size <= req->mem_size) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
return 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
ec_soe_request_clear_data(req); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
if (!(req->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
EC_ERR("Failed to allocate %zu bytes of SoE memory.\n", size); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
return -ENOMEM; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
req->mem_size = size; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
req->data_size = 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
return 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
/** Copies SoE data from an external source. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
* If the \a mem_size is to small, new memory is allocated. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
* |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
* \retval 0 Success. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
* \retval <0 Error code. |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
*/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
int ec_soe_request_copy_data( |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
ec_soe_request_t *req, /**< SoE request. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
const uint8_t *source, /**< Source data. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
size_t size /**< Number of bytes in \a source. */ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
int ret = ec_soe_request_alloc(req, size); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
if (ret < 0) |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
return ret; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
memcpy(req->data, source, size); |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
req->data_size = size; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
return 0; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
|
1864
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
177 |
/** Copies SoE data from an external source. |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
178 |
* |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
179 |
* If the \a mem_size is to small, new memory is allocated. |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
180 |
* |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
181 |
* \retval 0 Success. |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
182 |
* \retval <0 Error code. |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
183 |
*/ |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
184 |
int ec_soe_request_append_data( |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
185 |
ec_soe_request_t *req, /**< SoE request. */ |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
186 |
const uint8_t *source, /**< Source data. */ |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
187 |
size_t size /**< Number of bytes in \a source. */ |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
188 |
) |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
189 |
{ |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
190 |
if (req->data_size + size > req->mem_size) { |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
191 |
size_t new_size = req->mem_size ? req->mem_size * 2 : size; |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
192 |
uint8_t *new_data = (uint8_t *) kmalloc(new_size, GFP_KERNEL); |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
193 |
if (!new_data) { |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
194 |
EC_ERR("Failed to allocate %zu bytes of SoE memory.\n", |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
195 |
new_size); |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
196 |
return -ENOMEM; |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
197 |
} |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
198 |
memcpy(new_data, req->data, req->data_size); |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
199 |
kfree(req->data); |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
200 |
req->data = new_data; |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
201 |
req->mem_size = new_size; |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
202 |
} |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
203 |
|
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
204 |
memcpy(req->data + req->data_size, source, size); |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
205 |
req->data_size += size; |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
206 |
return 0; |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
207 |
} |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
208 |
|
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
209 |
/*****************************************************************************/ |
0a6b3aacc847
Implemented SoE fragmented reading.
Florian Pose <fp@igh-essen.com>
parents:
1843
diff
changeset
|
210 |
|
1907
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
211 |
/** Request a read operation. |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
212 |
*/ |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
213 |
void ec_soe_request_read( |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
214 |
ec_soe_request_t *req /**< SoE request. */ |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
215 |
) |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
req->dir = EC_DIR_INPUT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
req->state = EC_INT_REQUEST_QUEUED; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
req->error_code = 0x0000; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
/*****************************************************************************/ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
1907
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
224 |
/** Request a write operation. |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
225 |
*/ |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
226 |
void ec_soe_request_write( |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
227 |
ec_soe_request_t *req /**< SoE request. */ |
dd276ae226b4
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
1864
diff
changeset
|
228 |
) |
1831
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
{ |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
req->dir = EC_DIR_OUTPUT; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
req->state = EC_INT_REQUEST_QUEUED; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
req->error_code = 0x0000; |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
} |
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
|
1875b9fea0ba
Implemented reading Sercos-over-EtherCAT services. To be continued...
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
/*****************************************************************************/ |