blob: 8002e0cc4d9b972a4a2694fde4f9054a1923d864 [file] [log] [blame]
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001/****************************************************************************
2
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
5
6 Project: openPOWERLINK
7
8 Description: include file for api function of the sdo module
9
10 License:
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
15
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of SYSTEC electronic GmbH nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without prior written permission. For written
26 permission, please contact info@systec-electronic.com.
27
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
40
41 Severability Clause:
42
43 If a provision of this License is or becomes illegal, invalid or
44 unenforceable in any jurisdiction, that shall not affect:
45 1. the validity or enforceability in that jurisdiction of any other
46 provision of this License; or
47 2. the validity or enforceability in other jurisdictions of that or
48 any other provision of this License.
49
50 -------------------------------------------------------------------------
51
52 $RCSfile: EplSdo.h,v $
53
54 $Author: D.Krueger $
55
56 $Revision: 1.6 $ $Date: 2008/04/17 21:36:32 $
57
58 $State: Exp $
59
60 Build Environment:
61 GCC V3.4
62
63 -------------------------------------------------------------------------
64
65 Revision History:
66
67 2006/06/26 k.t.: start of the implementation
68
Daniel Krueger9d7164c2008-12-19 11:41:57 -080069****************************************************************************/
70
71#include "EplInc.h"
72#include "EplFrame.h"
73#include "EplSdoAc.h"
74
75#ifndef _EPLSDO_H_
76#define _EPLSDO_H_
77
Daniel Krueger9d7164c2008-12-19 11:41:57 -080078//---------------------------------------------------------------------------
79// const defines
80//---------------------------------------------------------------------------
81// global defines
82#ifndef EPL_SDO_MAX_PAYLOAD
83#define EPL_SDO_MAX_PAYLOAD 256
84#endif
85
86// handle between Protocol Abstraction Layer and asynchronous SDO Sequence Layer
87#define EPL_SDO_UDP_HANDLE 0x8000
88#define EPL_SDO_ASND_HANDLE 0x4000
89#define EPL_SDO_ASY_HANDLE_MASK 0xC000
90#define EPL_SDO_ASY_INVALID_HDL 0x3FFF
91
92// handle between SDO Sequence Layer and sdo command layer
93#define EPL_SDO_ASY_HANDLE 0x8000
94#define EPL_SDO_PDO_HANDLE 0x4000
95#define EPL_SDO_SEQ_HANDLE_MASK 0xC000
96#define EPL_SDO_SEQ_INVALID_HDL 0x3FFF
97
98#define EPL_ASND_HEADER_SIZE 4
99//#define EPL_SEQ_HEADER_SIZE 4
100#define EPL_ETHERNET_HEADER_SIZE 14
101
102#define EPL_SEQ_NUM_MASK 0xFC
103
104// size for send buffer and history
105#define EPL_MAX_SDO_FRAME_SIZE EPL_C_IP_MIN_MTU
106// size for receive frame
107// -> needed because SND-Kit sends up to 1518 Byte
108// without Sdo-Command: Maximum Segment Size
109#define EPL_MAX_SDO_REC_FRAME_SIZE EPL_C_IP_MAX_MTU
110
111//---------------------------------------------------------------------------
112// typedef
113//---------------------------------------------------------------------------
114// handle between Protocol Abstraction Layer and asynchronuus SDO Sequence Layer
115typedef unsigned int tEplSdoConHdl;
116
117// callback function pointer for Protocol Abstraction Layer to call
118// asynchronuus SDO Sequence Layer
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700119typedef tEplKernel(*tEplSequLayerReceiveCb) (tEplSdoConHdl ConHdl_p,
120 tEplAsySdoSeq *pSdoSeqData_p,
121 unsigned int uiDataSize_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800122
123// handle between asynchronuus SDO Sequence Layer and SDO Command layer
124typedef unsigned int tEplSdoSeqConHdl;
125
126// callback function pointer for asynchronuus SDO Sequence Layer to call
127// SDO Command layer for received data
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700128typedef tEplKernel(* tEplSdoComReceiveCb) (tEplSdoSeqConHdl SdoSeqConHdl_p,
129 tEplAsySdoCom *pAsySdoCom_p,
130 unsigned int uiDataSize_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800131
132// status of connection
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800133typedef enum {
134 kAsySdoConStateConnected = 0x00,
135 kAsySdoConStateInitError = 0x01,
136 kAsySdoConStateConClosed = 0x02,
137 kAsySdoConStateAckReceived = 0x03,
138 kAsySdoConStateFrameSended = 0x04,
139 kAsySdoConStateTimeout = 0x05
140} tEplAsySdoConState;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800141
142// callback function pointer for asynchronuus SDO Sequence Layer to call
143// SDO Command layer for connection status
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700144typedef tEplKernel(* tEplSdoComConCb) (tEplSdoSeqConHdl SdoSeqConHdl_p,
145 tEplAsySdoConState AsySdoConState_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800146
147// handle between SDO Command layer and application
148typedef unsigned int tEplSdoComConHdl;
149
150// status of connection
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800151typedef enum {
152 kEplSdoComTransferNotActive = 0x00,
153 kEplSdoComTransferRunning = 0x01,
154 kEplSdoComTransferTxAborted = 0x02,
155 kEplSdoComTransferRxAborted = 0x03,
156 kEplSdoComTransferFinished = 0x04,
157 kEplSdoComTransferLowerLayerAbort = 0x05
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800158} tEplSdoComConState;
159
160// SDO Services and Command-Ids from DS 1.0.0 p.152
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800161typedef enum {
162 kEplSdoServiceNIL = 0x00,
163 kEplSdoServiceWriteByIndex = 0x01,
164 kEplSdoServiceReadByIndex = 0x02
165 //--------------------------------
166 // the following services are optional and
167 // not supported now
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800168/*
169 kEplSdoServiceWriteAllByIndex = 0x03,
170 kEplSdoServiceReadAllByIndex = 0x04,
171 kEplSdoServiceWriteByName = 0x05,
172 kEplSdoServiceReadByName = 0x06,
173
174 kEplSdoServiceFileWrite = 0x20,
175 kEplSdoServiceFileRead = 0x21,
176
177 kEplSdoServiceWriteMultiByIndex = 0x31,
178 kEplSdoServiceReadMultiByIndex = 0x32,
179
180 kEplSdoServiceMaxSegSize = 0x70
181
182 // 0x80 - 0xFF manufacturer specific
183
184 */
185} tEplSdoServiceType;
186
187// describes if read or write access
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800188typedef enum {
189 kEplSdoAccessTypeRead = 0x00,
190 kEplSdoAccessTypeWrite = 0x01
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800191} tEplSdoAccessType;
192
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800193typedef enum {
194 kEplSdoTypeAuto = 0x00,
195 kEplSdoTypeUdp = 0x01,
196 kEplSdoTypeAsnd = 0x02,
197 kEplSdoTypePdo = 0x03
198} tEplSdoType;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800199
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800200typedef enum {
201 kEplSdoTransAuto = 0x00,
202 kEplSdoTransExpedited = 0x01,
203 kEplSdoTransSegmented = 0x02
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800204} tEplSdoTransType;
205
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800206// structure to inform application about finish of SDO transfer
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800207typedef struct {
208 tEplSdoComConHdl m_SdoComConHdl;
209 tEplSdoComConState m_SdoComConState;
Greg Kroah-Hartmand539cfb2009-03-23 12:51:37 -0700210 u32 m_dwAbortCode;
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800211 tEplSdoAccessType m_SdoAccessType;
212 unsigned int m_uiNodeId; // NodeId of the target
213 unsigned int m_uiTargetIndex; // index which was accessed
214 unsigned int m_uiTargetSubIndex; // subindex which was accessed
215 unsigned int m_uiTransferredByte; // number of bytes transferred
216 void *m_pUserArg; // user definable argument pointer
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800217
218} tEplSdoComFinished;
219
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800220// callback function pointer to inform application about connection
Greg Kroah-Hartmand10f4692009-03-23 10:45:12 -0700221typedef tEplKernel(* tEplSdoFinishedCb) (tEplSdoComFinished *pSdoComFinished_p);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800222
223// structure to init SDO transfer to Read or Write by Index
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800224typedef struct {
225 tEplSdoComConHdl m_SdoComConHdl;
226 unsigned int m_uiIndex;
227 unsigned int m_uiSubindex;
228 void *m_pData;
229 unsigned int m_uiDataSize;
230 unsigned int m_uiTimeout; // not used in this version
231 tEplSdoAccessType m_SdoAccessType;
232 tEplSdoFinishedCb m_pfnSdoFinishedCb;
233 void *m_pUserArg; // user definable argument pointer
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800234
235} tEplSdoComTransParamByIndex;
236
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800237//---------------------------------------------------------------------------
238// function prototypes
239//---------------------------------------------------------------------------
240
Greg Kroah-Hartmane0ca0592008-12-19 17:09:38 -0800241#endif // #ifndef _EPLSDO_H_