1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: include file for api function of the sdo module
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
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.
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.
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.
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.
50 -------------------------------------------------------------------------
52 $RCSfile: EplSdo.h,v $
56 $Revision: 1.6 $ $Date: 2008/04/17 21:36:32 $
63 -------------------------------------------------------------------------
67 2006/06/26 k.t.: start of the implementation
69 ****************************************************************************/
78 //---------------------------------------------------------------------------
80 //---------------------------------------------------------------------------
82 #ifndef EPL_SDO_MAX_PAYLOAD
83 #define EPL_SDO_MAX_PAYLOAD 256
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
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
98 #define EPL_ASND_HEADER_SIZE 4
99 //#define EPL_SEQ_HEADER_SIZE 4
100 #define EPL_ETHERNET_HEADER_SIZE 14
102 #define EPL_SEQ_NUM_MASK 0xFC
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
111 //---------------------------------------------------------------------------
113 //---------------------------------------------------------------------------
114 // handle between Protocol Abstraction Layer and asynchronuus SDO Sequence Layer
115 typedef unsigned int tEplSdoConHdl
;
117 // callback function pointer for Protocol Abstraction Layer to call
118 // asynchronuus SDO Sequence Layer
119 typedef tEplKernel(*tEplSequLayerReceiveCb
) (tEplSdoConHdl ConHdl_p
,
120 tEplAsySdoSeq
*pSdoSeqData_p
,
121 unsigned int uiDataSize_p
);
123 // handle between asynchronuus SDO Sequence Layer and SDO Command layer
124 typedef unsigned int tEplSdoSeqConHdl
;
126 // callback function pointer for asynchronuus SDO Sequence Layer to call
127 // SDO Command layer for received data
128 typedef tEplKernel(* tEplSdoComReceiveCb
) (tEplSdoSeqConHdl SdoSeqConHdl_p
,
129 tEplAsySdoCom
*pAsySdoCom_p
,
130 unsigned int uiDataSize_p
);
132 // status of connection
134 kAsySdoConStateConnected
= 0x00,
135 kAsySdoConStateInitError
= 0x01,
136 kAsySdoConStateConClosed
= 0x02,
137 kAsySdoConStateAckReceived
= 0x03,
138 kAsySdoConStateFrameSended
= 0x04,
139 kAsySdoConStateTimeout
= 0x05
140 } tEplAsySdoConState
;
142 // callback function pointer for asynchronuus SDO Sequence Layer to call
143 // SDO Command layer for connection status
144 typedef tEplKernel(* tEplSdoComConCb
) (tEplSdoSeqConHdl SdoSeqConHdl_p
,
145 tEplAsySdoConState AsySdoConState_p
);
147 // handle between SDO Command layer and application
148 typedef unsigned int tEplSdoComConHdl
;
150 // status of connection
152 kEplSdoComTransferNotActive
= 0x00,
153 kEplSdoComTransferRunning
= 0x01,
154 kEplSdoComTransferTxAborted
= 0x02,
155 kEplSdoComTransferRxAborted
= 0x03,
156 kEplSdoComTransferFinished
= 0x04,
157 kEplSdoComTransferLowerLayerAbort
= 0x05
158 } tEplSdoComConState
;
160 // SDO Services and Command-Ids from DS 1.0.0 p.152
162 kEplSdoServiceNIL
= 0x00,
163 kEplSdoServiceWriteByIndex
= 0x01,
164 kEplSdoServiceReadByIndex
= 0x02
165 //--------------------------------
166 // the following services are optional and
169 kEplSdoServiceWriteAllByIndex = 0x03,
170 kEplSdoServiceReadAllByIndex = 0x04,
171 kEplSdoServiceWriteByName = 0x05,
172 kEplSdoServiceReadByName = 0x06,
174 kEplSdoServiceFileWrite = 0x20,
175 kEplSdoServiceFileRead = 0x21,
177 kEplSdoServiceWriteMultiByIndex = 0x31,
178 kEplSdoServiceReadMultiByIndex = 0x32,
180 kEplSdoServiceMaxSegSize = 0x70
182 // 0x80 - 0xFF manufacturer specific
185 } tEplSdoServiceType
;
187 // describes if read or write access
189 kEplSdoAccessTypeRead
= 0x00,
190 kEplSdoAccessTypeWrite
= 0x01
194 kEplSdoTypeAuto
= 0x00,
195 kEplSdoTypeUdp
= 0x01,
196 kEplSdoTypeAsnd
= 0x02,
197 kEplSdoTypePdo
= 0x03
201 kEplSdoTransAuto
= 0x00,
202 kEplSdoTransExpedited
= 0x01,
203 kEplSdoTransSegmented
= 0x02
206 // structure to inform application about finish of SDO transfer
208 tEplSdoComConHdl m_SdoComConHdl
;
209 tEplSdoComConState m_SdoComConState
;
211 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
218 } tEplSdoComFinished
;
220 // callback function pointer to inform application about connection
221 typedef tEplKernel(* tEplSdoFinishedCb
) (tEplSdoComFinished
*pSdoComFinished_p
);
223 // structure to init SDO transfer to Read or Write by Index
225 tEplSdoComConHdl m_SdoComConHdl
;
226 unsigned int m_uiIndex
;
227 unsigned int m_uiSubindex
;
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
235 } tEplSdoComTransParamByIndex
;
237 //---------------------------------------------------------------------------
238 // function prototypes
239 //---------------------------------------------------------------------------
241 #endif // #ifndef _EPLSDO_H_