1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: include file for EPL frames
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: EplFrame.h,v $
56 $Revision: 1.5 $ $Date: 2008/06/23 14:56:33 $
63 -------------------------------------------------------------------------
67 2006/05/22 d.k.: start of the implementation, version 1.00
69 ****************************************************************************/
74 //---------------------------------------------------------------------------
76 //---------------------------------------------------------------------------
78 // defines for EplFrame.m_wFlag
79 #define EPL_FRAME_FLAG1_RD 0x01 // ready (PReq, PRes)
80 #define EPL_FRAME_FLAG1_ER 0x02 // exception reset (error signalling) (SoA)
81 #define EPL_FRAME_FLAG1_EA 0x04 // exception acknowledge (error signalling) (PReq, SoA)
82 #define EPL_FRAME_FLAG1_EC 0x08 // exception clear (error signalling) (StatusRes)
83 #define EPL_FRAME_FLAG1_EN 0x10 // exception new (error signalling) (PRes, StatusRes)
84 #define EPL_FRAME_FLAG1_MS 0x20 // multiplexed slot (PReq)
85 #define EPL_FRAME_FLAG1_PS 0x40 // prescaled slot (SoC)
86 #define EPL_FRAME_FLAG1_MC 0x80 // multiplexed cycle completed (SoC)
87 #define EPL_FRAME_FLAG2_RS 0x07 // number of pending requests to send (PRes, StatusRes, IdentRes)
88 #define EPL_FRAME_FLAG2_PR 0x38 // priority of requested asynch. frame (PRes, StatusRes, IdentRes)
89 #define EPL_FRAME_FLAG2_PR_SHIFT 3 // shift of priority of requested asynch. frame
91 // error history/status entry types
92 #define EPL_ERR_ENTRYTYPE_STATUS 0x8000
93 #define EPL_ERR_ENTRYTYPE_HISTORY 0x0000
94 #define EPL_ERR_ENTRYTYPE_EMCY 0x4000
95 #define EPL_ERR_ENTRYTYPE_MODE_ACTIVE 0x1000
96 #define EPL_ERR_ENTRYTYPE_MODE_CLEARED 0x2000
97 #define EPL_ERR_ENTRYTYPE_MODE_OCCURRED 0x3000
98 #define EPL_ERR_ENTRYTYPE_MODE_MASK 0x3000
99 #define EPL_ERR_ENTRYTYPE_PROF_VENDOR 0x0001
100 #define EPL_ERR_ENTRYTYPE_PROF_EPL 0x0002
101 #define EPL_ERR_ENTRYTYPE_PROF_MASK 0x0FFF
103 // defines for EPL version / PDO version
104 #define EPL_VERSION_SUB 0x0F // sub version
105 #define EPL_VERSION_MAIN 0xF0 // main version
107 //---------------------------------------------------------------------------
109 //---------------------------------------------------------------------------
111 // $$$ d.k.: move this definition to global.h
112 // byte-align structures
114 # pragma pack( push, packing )
117 #elif defined( __GNUC__ )
118 # define PACK_STRUCT __attribute__((packed))
120 # error you must byte-align these structures with the appropriate compiler directives
125 u8 m_le_bRes1; // reserved
127 u8 m_le_bFlag1; // Flags: MC, PS
129 u8 m_le_bFlag2; // Flags: res
131 tEplNetTime m_le_NetTime; // supported if D_NMT_NetTimeIsRealTime_BOOL is set
133 u64 m_le_RelativeTime; // in us (supported if D_NMT_RelativeTime_BOOL is set)
135 } PACK_STRUCT tEplSocFrame;
139 u8 m_le_bRes1; // reserved
141 u8 m_le_bFlag1; // Flags: MS, EA, RD
143 u8 m_le_bFlag2; // Flags: res
147 u8 m_le_bRes2; // reserved
151 u8 m_le_abPayload[256 /*D_NMT_IsochrRxMaxPayload_U16 */ ];
153 } PACK_STRUCT tEplPreqFrame;
157 u8 m_le_bNmtStatus; // NMT state
159 u8 m_le_bFlag1; // Flags: MS, EN, RD
161 u8 m_le_bFlag2; // Flags: PR, RS
165 u8 m_le_bRes2; // reserved
169 u8 m_le_abPayload[256 /*D_NMT_IsochrRxMaxPayload_U16
170 / D_NMT_IsochrTxMaxPayload_U16 */ ];
172 } PACK_STRUCT tEplPresFrame;
176 u8 m_le_bNmtStatus; // NMT state
178 u8 m_le_bFlag1; // Flags: EA, ER
180 u8 m_le_bFlag2; // Flags: res
182 u8 m_le_bReqServiceId;
184 u8 m_le_bReqServiceTarget;
188 } PACK_STRUCT tEplSoaFrame;
193 tEplNetTime m_TimeStamp;
196 } PACK_STRUCT tEplErrHistoryEntry;
200 u8 m_le_bFlag1; // Flags: EN, EC
201 u8 m_le_bFlag2; // Flags: PR, RS
202 u8 m_le_bNmtStatus; // NMT state
204 u64 m_le_qwStaticError; // static error bit field
205 tEplErrHistoryEntry m_le_aErrHistoryEntry[14];
207 } PACK_STRUCT tEplStatusResponse;
211 u8 m_le_bFlag1; // Flags: res
212 u8 m_le_bFlag2; // Flags: PR, RS
213 u8 m_le_bNmtStatus; // NMT state
214 u8 m_le_bIdentRespFlags; // Flags: FW
215 u8 m_le_bEplProfileVersion;
217 u32 m_le_dwFeatureFlags; // NMT_FeatureFlags_U32
218 u16 m_le_wMtu; // NMT_CycleTiming_REC.AsyncMTU_U16: C_IP_MIN_MTU - C_IP_MAX_MTU
219 u16 m_le_wPollInSize; // NMT_CycleTiming_REC.PReqActPayload_U16
220 u16 m_le_wPollOutSize; // NMT_CycleTiming_REC.PResActPayload_U16
221 u32 m_le_dwResponseTime; // NMT_CycleTiming_REC.PResMaxLatency_U32
223 u32 m_le_dwDeviceType; // NMT_DeviceType_U32
224 u32 m_le_dwVendorId; // NMT_IdentityObject_REC.VendorId_U32
225 u32 m_le_dwProductCode; // NMT_IdentityObject_REC.ProductCode_U32
226 u32 m_le_dwRevisionNumber; // NMT_IdentityObject_REC.RevisionNo_U32
227 u32 m_le_dwSerialNumber; // NMT_IdentityObject_REC.SerialNo_U32
228 u64 m_le_qwVendorSpecificExt1;
229 u32 m_le_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
230 u32 m_le_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
231 u32 m_le_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
232 u32 m_le_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
233 u32 m_le_dwIpAddress;
234 u32 m_le_dwSubnetMask;
235 u32 m_le_dwDefaultGateway;
236 u8 m_le_sHostname[32];
237 u8 m_le_abVendorSpecificExt2[48];
239 } PACK_STRUCT tEplIdentResponse;
243 u8 m_le_bNmtCommandId;
245 u8 m_le_abNmtCommandData[32];
247 } PACK_STRUCT tEplNmtCommandService;
251 u8 m_le_bTransactionId;
254 u16 m_le_wSegmentSize;
256 u8 m_le_abCommandData[8]; // just reserve a minimum number of bytes as a placeholder
258 } PACK_STRUCT tEplAsySdoCom;
260 // asynchronous SDO Sequence Header
262 u8 m_le_bRecSeqNumCon;
263 u8 m_le_bSendSeqNumCon;
264 u8 m_le_abReserved[2];
265 tEplAsySdoCom m_le_abSdoSeqPayload;
267 } PACK_STRUCT tEplAsySdoSeq;
271 u8 m_le_bNmtCommandId;
272 u8 m_le_bTargetNodeId;
273 u8 m_le_abNmtCommandData[32];
275 } PACK_STRUCT tEplNmtRequestService;
279 tEplStatusResponse m_StatusResponse;
280 tEplIdentResponse m_IdentResponse;
281 tEplNmtCommandService m_NmtCommandService;
282 tEplNmtRequestService m_NmtRequestService;
283 tEplAsySdoSeq m_SdoSequenceFrame;
284 u8 m_le_abPayload[256 /*D_NMT_ASndTxMaxPayload_U16
285 / D_NMT_ASndRxMaxPayload_U16 */ ];
293 tEplAsndPayload m_Payload;
295 } PACK_STRUCT tEplAsndFrame;
300 tEplPreqFrame m_Preq;
301 tEplPresFrame m_Pres;
303 tEplAsndFrame m_Asnd;
309 u8 m_be_abDstMac[6]; // MAC address of the addressed nodes
311 u8 m_be_abSrcMac[6]; // MAC address of the transmitting node
313 u16 m_be_wEtherType; // Ethernet message type (big endian)
315 u8 m_le_bMessageType; // EPL message type
317 u8 m_le_bDstNodeId; // EPL node ID of the addressed nodes
319 u8 m_le_bSrcNodeId; // EPL node ID of the transmitting node
321 tEplFrameData m_Data;
323 } PACK_STRUCT tEplFrame;
325 // un-byte-align structures
327 # pragma pack( pop, packing )
331 kEplMsgTypeNonEpl = 0x00,
332 kEplMsgTypeSoc = 0x01,
333 kEplMsgTypePreq = 0x03,
334 kEplMsgTypePres = 0x04,
335 kEplMsgTypeSoa = 0x05,
336 kEplMsgTypeAsnd = 0x06,
340 //---------------------------------------------------------------------------
341 // function prototypes
342 //---------------------------------------------------------------------------
344 #endif // #ifndef _EPL_FRAME_H_