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

📄 cd.h

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 H
📖 第 1 页 / 共 2 页
字号:
{
   GS_TRRBL_HEADER;                 /* the standard tribble header         */

   CB_ComBufType *pComBuf;          /* pointer to packet ComBuf            */
   UINT16         iClass;           /* destination object class number     */
   UINT16         iInstance;        /* destination object instance number  */
   UINT16         iPort;            /* communications port number          */

#ifdef CD_EN_OBJECTS
   UINT16         iMsgSeq;          /* Message sequence number (value returned by transport) */
   CB_ComBufType *pCbDestHost;      /* Ptr to hostname/ip addr in a ComBuf */
   UINT8          bRequest;         /* Request/response indication to ENet UCMM */
#endif

   UINT16         iTransport;       /* transport associated with packet    */

   void*          xUserHandle;      /* user handle (class 3 & port-port)   */
   void*          xCdHandle;        /* handle for use by cd layer          */
   void*          xUmHandle;        /* handle for use by UCMM layer:       */
                                    /*   server: ptr to server trans rec   */
                                    /*   client: ptr to client trans rec   */
}
CD_PacketTrrblType;



/*---------------------------------------------------------------------------
**
** CD_TimeoutTrrblType
**
** Tribble for notification when a transport or other comm timer times out.
** Also used to request some special timeout services.
**
**---------------------------------------------------------------------------
*/

typedef struct CD_TimeoutTrrblType
{
   GS_TRRBL_HEADER;                    /* the standard tribble header      */

   /*
   **
   ** Removed  iId per WS class 3 problem.  Moved to the
   ** trrbl header.  Morphing of different tribble
   ** types was causing an overwrite of some
   ** structures
   ** jjw 1/26/00
   UINT16 iId;                         /* Conn or tran that timed out      */
                                       /* or timeout value                 */
   UINT16 iPort;                       /* Port that tran is valid for      */
}
CD_TimeoutTrrblType;



/*---------------------------------------------------------------------------
**
** CD_TransportTrrblType
**
** Tribble used to reserve, start and delete one or two transports.
**
**---------------------------------------------------------------------------
*/

typedef struct CD_TransportTrrblType
{
   GS_TRRBL_HEADER;              /* The standard tribble header            */

   /*
   ** All things of interest are in the connection record.
   */

   CM_ConnectionRecordType *psConnRecord;
}
CD_TransportTrrblType;


/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Globals
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** Public global communications device data.
**
**---------------------------------------------------------------------------
*/

extern volatile CD_DataType CD_s[];



/*---------------------------------------------------------------------------
**
** Various and sundry interesting packets.
**
**---------------------------------------------------------------------------
*/

/* LUMP THIS INTO co_s... */


/****************************************************************************
**
** Public Services
**
*****************************************************************************
*/

/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Services
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** CD_ApplyPendingConfig
**
** Apply some portion of the pending network interface configuration
** the the network interface hardware.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iConfig              - Bit mask of config parts to apply
**    iTicks               - When to apply
**                            0  = Transfer to hardware but don't apply
**                            1  = Transfer and apply immediately
**                            >1 = Transfer and wait for later apply request
**
** Outputs:
**    None
**
** Usage:
**    CD_ApplyPendingConfig( CD_CONFIG_LINK, 0 );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void CD_ApplyPendingConfig( UINT16 iConfig, UINT16 iTicks );



/*---------------------------------------------------------------------------
**
** CD_ConfigTask()
** CD_TxUnscheduledTask()
**
** Communications device configuration request processing task.
** Communications device unscheduled packet transmission processing task.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    None
**
** Usage:
**    GS_NewTask( CD_ConfigTask, ... );
**
**---------------------------------------------------------------------------
*/

EXTFUNC TASKRETURN CD_ConfigTask( TASKPARAM );
EXTFUNC TASKRETURN CD_TxUnscheduledTask( TASKPARAM );



/*---------------------------------------------------------------------------
**
** CD_GetLeds()
**
** Return a one byte value with the current LED A state in the lower nybble
** and the LED B state in the upper nybble. See the CD_LED_xxx definitions
** earlier in this file for details of the LED state values.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    None
**
** Outputs:
**    Return            - Byte containing status of both leds.
**
** Usage:
**    bLeds = CD_GetLeds();
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT8 CD_GetLeds( void );



/*---------------------------------------------------------------------------
**
** CD_GetTransportBuffer()
**
** Attempt to get an available transport buffer for transmission.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iTransportId      - Which transport
**
** Outputs:
**    Return            - Pointer to transport buffer
**                        NULL if none currently available
**
** Usage:
**    pBuffer = CD_GetTransportBuffer( iTransport );
**
**---------------------------------------------------------------------------
*/

EXTFUNC UINT8 *CD_GetTransportBuffer( UINT16 iTransport );



/*---------------------------------------------------------------------------
**
** CD_HardResetAsic()
**
** Hard reset the ControlNet ASIC.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    fRun              - TRUE = Reset, then let the ASIC run
**                        FALSE = Hold the ASIC in reset
**
** Outputs:
**    None
**
** Usage:
**    CD_HardResetAsic( TRUE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void CD_HardResetAsic( BOOL fRun );



/*---------------------------------------------------------------------------
**
** CD_Init()
**
** Communication Device object data/task creation/allocation/initialization.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iOptions                   - Bit mask of initialization options
**
** Outputs:
**    Return                     - Success/failure status
**
** Usage:
**    eStatus = CD_Init( AB_COLD_START_RESOURCE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC StatusType CD_Init( UINT16 iOptions );



/*---------------------------------------------------------------------------
**
** CD_PutTransportBuffer()
**
** Put a previously gotten transport buffer for transmission.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iTransportId      - Which transport
**
** Outputs:
**    None
**
** Usage:
**    CD_PutTransportBuffer( iTransport );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void CD_PutTransportBuffer( UINT16 iTransport );



/*---------------------------------------------------------------------------
**
** CD_QueueConfigTx()
**
** Queue a configuration packet for transmission on the ControlNet
** communications port.
**
** The packet that is given to this service will generally be a statically
** declared template of the packet. Only the data portion of the packet
** need be filled in.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pabPacket         - Pointer to array containing packet
**    iPacketSize       - Size of the data portion of the packet
**    bFixedTag         - Fixed tag for this packet
**    fBroadcast        - TRUE  = Broadcast the packet
**                        FALSE = Transmit to the node's mac id
**
** Outputs:
**    None
**
** Usage:
**    CD_QueueConfigTx( &CD_sTMinusPacket,
**                      sizeof( CD_PacketTMinusType ),
**                      CN_T_MINUS_FTAG,
**                      TRUE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void CD_QueueConfigTx( UINT8 *pabPacket,
                               UINT16   iPacketSIze,
                               UINT8  bFIxedTag,
                               BOOL   fBroadcast );



/*---------------------------------------------------------------------------
**
** CD_QueueUnschedTx()
**
** Queue an unscheduled packet for transmission on the communication port
** indicated in the tribble. Use the low priority unscheduled queue.
**
** The tribble given to this service is of the CD_FixedTagPacketTrrblType.
** The combuf attached to it only contains the data portion of the packet
** and not the ControlNet packet header. The header will be built when
** the packet is queued to the ASIC. The header will be based on the
** mac id and fixed tag contained in tribble.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    pTrrbl            - Pointer to tribble/combuf containing packet
**
** Outputs:
**    None
**
** Usage:
**    CD_QueueUnschedTx( pTrrbl );
**
**---------------------------------------------------------------------------
*/


#define CD_QueueUnschedTx( pTrrbl ) \
   GS_PutTrrbl( CD_s[ ((CD_PacketTrrblType*)(pTrrbl))->iPort ].xTxUnschedLoQid, (pTrrbl) );




/*---------------------------------------------------------------------------
**
** CD_SetFixedTag()
**
** Enable or disable the reception of a fixed tag.
** Several tags can be enabled/disabled prior to activation.
** (Activation is an expensive and time consuming operation.)
**
**---------------------------------------------------------------------------
**
** Inputs:
**    iTagNumber        - Tag number to disable (0-255)
**    fEnable           - Enable the tag (or disable)
**    fActivate         - Activate the new list of tags
**
** Outputs:
**    None
**
** Usage:
**    GS_SetFixedTag( CN_TUI_FTAG, TRUE, TRUE );
**
**---------------------------------------------------------------------------
*/

EXTFUNC void CD_SetFixedTag( UINT16 iTagNumber, BOOL fEnable, BOOL fActivate );


/*---------------------------------------------------------------------------
**
** CD_ValidPortNum()
**
** Check for a valid port number.
**
**---------------------------------------------------------------------------
**
** Inputs:
**    portNum            - The port number to be checked
**
** Outputs:
**    1 (TRUE) if port number is valid; 0 (FALSE) if invalid
**
** Usage:
**    CD_ValidPortNum( iPort );
**
**---------------------------------------------------------------------------
*/


#define CD_ValidPortNum( portNum )  \
        (( portNum != 0 ) &&        \
        ( portNum <= CD_NPORTS ) && \
        ( CD_s[ portNum ].xUMQid != NULL ))


#endif  /* defined(CD_EN_OBJECTS) */
#endif  /* inclusion lock */

/****************************************************************************
**
** End of CD.H
**
*****************************************************************************
*/



⌨️ 快捷键说明

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