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(PUBLIC * tEplSequLayerReceiveCb) (tEplSdoConHdl ConHdl_p,
122 unsigned int uiDataSize_p);
124 // handle between asynchronuus SDO Sequence Layer and SDO Command layer
125 typedef unsigned int tEplSdoSeqConHdl;
127 // callback function pointer for asynchronuus SDO Sequence Layer to call
128 // SDO Command layer for received data
129 typedef tEplKernel(PUBLIC *
130 tEplSdoComReceiveCb) (tEplSdoSeqConHdl SdoSeqConHdl_p,
131 tEplAsySdoCom * pAsySdoCom_p,
132 unsigned int uiDataSize_p);
134 // status of connection
136 kAsySdoConStateConnected = 0x00,
137 kAsySdoConStateInitError = 0x01,
138 kAsySdoConStateConClosed = 0x02,
139 kAsySdoConStateAckReceived = 0x03,
140 kAsySdoConStateFrameSended = 0x04,
141 kAsySdoConStateTimeout = 0x05
142 } tEplAsySdoConState;
144 // callback function pointer for asynchronuus SDO Sequence Layer to call
145 // SDO Command layer for connection status
146 typedef tEplKernel(PUBLIC * tEplSdoComConCb) (tEplSdoSeqConHdl SdoSeqConHdl_p,
150 // handle between SDO Command layer and application
151 typedef unsigned int tEplSdoComConHdl;
153 // status of connection
155 kEplSdoComTransferNotActive = 0x00,
156 kEplSdoComTransferRunning = 0x01,
157 kEplSdoComTransferTxAborted = 0x02,
158 kEplSdoComTransferRxAborted = 0x03,
159 kEplSdoComTransferFinished = 0x04,
160 kEplSdoComTransferLowerLayerAbort = 0x05
161 } tEplSdoComConState;
163 // SDO Services and Command-Ids from DS 1.0.0 p.152
165 kEplSdoServiceNIL = 0x00,
166 kEplSdoServiceWriteByIndex = 0x01,
167 kEplSdoServiceReadByIndex = 0x02
168 //--------------------------------
169 // the following services are optional and
172 kEplSdoServiceWriteAllByIndex = 0x03,
173 kEplSdoServiceReadAllByIndex = 0x04,
174 kEplSdoServiceWriteByName = 0x05,
175 kEplSdoServiceReadByName = 0x06,
177 kEplSdoServiceFileWrite = 0x20,
178 kEplSdoServiceFileRead = 0x21,
180 kEplSdoServiceWriteMultiByIndex = 0x31,
181 kEplSdoServiceReadMultiByIndex = 0x32,
183 kEplSdoServiceMaxSegSize = 0x70
185 // 0x80 - 0xFF manufacturer specific
188 } tEplSdoServiceType;
190 // describes if read or write access
192 kEplSdoAccessTypeRead = 0x00,
193 kEplSdoAccessTypeWrite = 0x01
197 kEplSdoTypeAuto = 0x00,
198 kEplSdoTypeUdp = 0x01,
199 kEplSdoTypeAsnd = 0x02,
200 kEplSdoTypePdo = 0x03
204 kEplSdoTransAuto = 0x00,
205 kEplSdoTransExpedited = 0x01,
206 kEplSdoTransSegmented = 0x02
209 // structure to inform application about finish of SDO transfer
211 tEplSdoComConHdl m_SdoComConHdl;
212 tEplSdoComConState m_SdoComConState;
214 tEplSdoAccessType m_SdoAccessType;
215 unsigned int m_uiNodeId; // NodeId of the target
216 unsigned int m_uiTargetIndex; // index which was accessed
217 unsigned int m_uiTargetSubIndex; // subindex which was accessed
218 unsigned int m_uiTransferredByte; // number of bytes transferred
219 void *m_pUserArg; // user definable argument pointer
221 } tEplSdoComFinished;
223 // callback function pointer to inform application about connection
224 typedef tEplKernel(PUBLIC * tEplSdoFinishedCb) (tEplSdoComFinished *
227 // structure to init SDO transfer to Read or Write by Index
229 tEplSdoComConHdl m_SdoComConHdl;
230 unsigned int m_uiIndex;
231 unsigned int m_uiSubindex;
233 unsigned int m_uiDataSize;
234 unsigned int m_uiTimeout; // not used in this version
235 tEplSdoAccessType m_SdoAccessType;
236 tEplSdoFinishedCb m_pfnSdoFinishedCb;
237 void *m_pUserArg; // user definable argument pointer
239 } tEplSdoComTransParamByIndex;
241 //---------------------------------------------------------------------------
242 // function prototypes
243 //---------------------------------------------------------------------------
245 #endif // #ifndef _EPLSDO_H_