⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 en_util.h

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 H
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** EN_UTIL.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Communications Device common code private interfaces.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major>         Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
**    en_cd_Class1TxPacket()        - transmit a Class1 packet
**    en_cd_DropMulticast()         - drop from a multicast group
**    en_cd_FreeIpMcastAddress()    - Mark allocated IP multicast addr free
**    en_cd_JoinMulticast()         - join a multicast group
**    en_cd_LoadUnschedTxPacket()   - load an unscheduled TX packet
**    en_cd_ParseClass1Packet()     - Parse a Classs 1 packet
**    en_cd_ParseLpacket()          - Parses a RX Lpacket
**    en_cd_SaveSendToAddress()     - For FWD_OPEN reply
**    en_cd_StartTransport()        - specific transport setup
**    en_cd_StopTransport()         - specific transport shutdown
**    en_cd_TxClass3Packet()        - Transmit a class 3 packet
**    en_cd_TxFixedTagPacket()      - Transmit any fixed tag packet
**
**
*****************************************************************************
*****************************************************************************
**                                                                         **
** ETHERNET/IP EXAMPLE CODE                                                **
** COPYRIGHT (c) 2000-2005 ODVA (Open DeviceNet Vendor Association)		   **
**						   & ControlNet International Ltd.                 **
**                                                                         **
** All rights reserved, except as specifically licensed in writing.        **
** Use of the Ethernet/IP Example Protocol Software is subject to          **
** ODVA's and ControlNet International's Terms of Use Agreement.           **
** The following work constitutes example program code and is intended     **
** merely to illustrate useful programming techniques.  The user is        **
** responsible for applying the code correctly.  The code is provided      **
** AS IS without warranty and is in no way guaranteed to be error-free.    **
**                                                                         **
*****************************************************************************
*****************************************************************************
*/

/****************************************************************************
*****************************************************************************
**
** Change Log
** ----------
**
**  
**
*****************************************************************************
*****************************************************************************
*/

#ifndef EN_UTIL_H
#define EN_UTIL_H


/*
** Determine if this code is to be included
*/

#ifdef CD_EN_OBJECTS

/****************************************************************************
**
** Symbols
**
*****************************************************************************
*/


/****************************************************************************
**
** Typedefs
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** en_TagEntryType
**
** Generic Tag Table Entry
**
**---------------------------------------------------------------------------
*/

typedef struct
{
   cd_TransportRecordType  *pTranRec;
   BOOL                     fTagInUse;
} en_TagEntryType;



/****************************************************************************
**
** Private Services
**
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** en_cd_JoinMulticast()
**
** 
**
**---------------------------------------------------------------------------
**
** Inputs:
**    struct sockaddr_in *mc_addr	Multicast IP address
**    
**
** Outputs:
**
** Returns:
**    UINT32    Status                  0 if successful, Non Zero if failed.
**
** Usage:
**    en_cd_JoinMulticast();
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT32  en_cd_JoinMulticast( struct sockaddr_in *mc_addr);

/*---------------------------------------------------------------------------
**
** en_cd_DropMulticast()
**
** 
**
**---------------------------------------------------------------------------
**
** Inputs:
**    struct sockaddr_in *mc_addr	Multicast IP address
**    
**
** Outputs:
**
** Returns:
**    UINT32    Status                  0 if successful, Non Zero if failed.
**
** Usage:
**    en_cd_DropMulticast();
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT32  en_cd_DropMulticast( struct sockaddr_in *mc_addr);



/*---------------------------------------------------------------------------
**
** en_cd_LoadUnschedTxPacket()
**
** Load one unscheduled packet for Tx by ethernet socket. The packet can be
** any sort of unscheduled packet, with either a fixed or generic tag.
** It could also be a configuration packet.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pTrrbl                  - Pointer to trrbl/combuf containing the packet
**    pabHeader               - Pointer to header of packet
**                              (size-control-tag bytes)
**    iHeaderSize             - Number of bytes in the header
**    iTotalSize              - Number of bytes in the packet & header
**    fConfig                 - Configuration or normal packet
**
** Outputs:
**    None
**
** Usage:
**
**    en_cd_LoadUnschedTxPacket( pTrrbl, (UINT8*)(&sHeader),
**                            iHeaderSize, iTotalSize, FALSE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_LoadUnschedTxPacket( CD_PacketTrrblType *pTrrbl,
                                     UINT8              *pabHeader,
                                     cd_TransportRecordType  *pTranRec,
                                     UINT16              iHeaderSize,
                                     UINT16              iTotalSize,
                                     BOOL                fConfig
                                   );

/*---------------------------------------------------------------------------
**
** en_cd_ParseLpacket()
**
** This function reads a single Lpacket from the MainRx Buffer and decides
** what to do with it.  Fixed tag Lpackets are either processed directly
** through SMAC driver function calls or are passed to a task.  Generic tag
** Lpackets are either copied by a transport function or are passed to a
** task.  Lpackets are passed to a task by copying them into a ComBuf and
** placing a ComBuf pointer into a message queue.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    PKTBUF_P msg		Pointer to PKTBUF containing the message
**    ECE *ece		ENCAP connection endpoint structure
**
**
** Outputs:
**    None
**
** Usage:
** void en_cd_ParseLpacket( PKTBUF_P msg, ECE * ece )
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT32 en_cd_ParseLpacket( PKTBUF_P msg, ECE * ece );


/*---------------------------------------------------------------------------
**
** en_cd_Class1TxPacket()
**
** This function transmits a class 1 packet
**
**---------------------------------------------------------------------------
**
** Inputs:
**    UINT8                   *pBuf      Pointer to xmit buffer.
**    cd_TransportRecordType  *pTranRec  Pointer to Transport record
**
**
** Outputs:
**    None
**
** Usage:
** void  en_cd_Class1TxPacket( UINT8 *pBuf, cd_TransportRecordType  *pTranRec)
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_Class1TxPacket( UINT8 *pBuf, cd_TransportRecordType  *pTranRec);

/*---------------------------------------------------------------------------
**
** en_cd_ParseClass1Packet()
**
** This function handles a class 1 packet received via TCP/IP
**
**---------------------------------------------------------------------------
**
** Inputs:
**    PKTBUF_P msg    Pointer to PKTBUF containing the message
**
**
** Outputs:
**    None
**
** Usage:
** void en_cd_ParseClass1Packet( PKTBUF_P msg )
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT32 en_cd_ParseClass1Packet(PKTBUF  *psPacketBuf);


/*---------------------------------------------------------------------------
**
** en_cd_FreeIpMcastAddress()
**
** For Class 1 multicast connections (producer and consumer are both handled
** here).
** For producer, mark the Allocated IP multicast Address in the Mcast
** allocation table as free.
** For consumer, just GS_Free() the sEce.psMcast pointer.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    psConnRecord                  - Pointer to CM_ConnectionRecordType
**
** Outputs:
**    None
**
** Usage:
**
**    en_cd_FreeIpMcastAddress( psConnRecord );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_FreeIpMcastAddress( CM_ConnectionRecordType  *psConnRecord );



/*---------------------------------------------------------------------------
**
** en_cd_ProducerCopyFunction()
**
** This routine is called when an application has data that needs to be
** produced or when the other port's CD layer has received data that needs 
** to be bridged/sent-out the Ethernet port.
**
** Returns the number of bytes copied to the Ethernet port.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pvxAppHandle            - Pointer to the CD Transport Record.
**    pui16LeSeqCount         - Pointer to transport layer's sequence count.
**    paui8DataIn             - Pointer to data to be sent.
**    ui16DataLen             - Number of bytes of data to be sent.
**
** Outputs:
**    NONE.
**
** Usage:
**
**    en_cd_ProducerCopyFunction( xAppHandle, pui16LeSeqCount, paui8DataIn,
**                                ui16DataLen );
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT16  en_cd_ProducerCopyFunction( void     *pvAppHandle, 
                                            LeUINT16 *pui16LeSeqCount, 
                                            UINT8    *paui8DataIn, 
                                            UINT16    ui16DataLen );



/*---------------------------------------------------------------------------
**
** en_cd_SaveSendToAddress()
**
**
**---------------------------------------------------------------------------
**
** Inputs:
**    none
**
** Outputs:
**    none
**
** Return
**    none
**
** Usage:
**    en_cd_SaveSendToAddress();
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_SaveSendToAddress( CM_ConnectionRecordType *psConnRecord );





/*---------------------------------------------------------------------------
**
** en_cd_StartTransport()
**
** ASIC specific initializing and starting up of a transport.
** (one side of a class 1 or both sides of a class 3 connection).
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pTransport              - Pointer to transport record
**
** Outputs:
**    Return                  - Success/failure status
**
** Usage:
**
**    eStatus = en_cd_StartTransport( pTransport );
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType en_cd_StartTransport( cd_TransportRecordType *pTransport );



/*---------------------------------------------------------------------------
**
** en_cd_StopTransport()
**
** ASIC specific stopping and cleaning up of a transport.
** (one side of a class 1 or both sides of a class 3 connection).
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pTransport              - Pointer to transport record
**
** Outputs:
**    None
**
** Usage:
**
**    en_cd_StopTransport( pTransport );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_StopTransport( cd_TransportRecordType *pTransport );



/*---------------------------------------------------------------------------
**
** en_cd_TxClass3Packet()
**
** Initiate the transfer of a class 3 packet into the ASIC for transmission.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pTrrbl                    - Pointer to tribble/combuf to transmit
**    pTranRec                  - Pointer to the transaction record
** Outputs:
**    None
**
** Usage:
**    en_cd_TxClass3Packet( pTrrbl, cd_TransportRecordType    *pTranRec  );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_TxClass3Packet( CD_PacketTrrblType *pTrrbl, cd_TransportRecordType    *pTranRec  );



/*---------------------------------------------------------------------------
**
** en_cd_TxFixedTagPacket()
**
** Initiate the transfer of a fixed tag packet into the ASIC for transmission.
** Delete the combuf and return the tribble when the transfer is complete.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pTrrbl                  - Pointer to tribble/combuf to transmit
**
** Outputs:
**    None
**
** Usage:
**
**    en_cd_TxFixedTagPacket( pTrrbl );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void en_cd_TxFixedTagPacket( CD_PacketTrrblType *pTrrbl );



#endif  /* #ifdef CD_EN_OBJECTS */
#endif  /* inclusion lock */

/****************************************************************************
**
** End of EN_UTIL.H
**
*****************************************************************************
*/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -