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

📄 cd.h

📁 基于EthernetIP协议的应用程序,可以读取AB公司Controllogix系列Ethernetip协议PLC数据. 此软件代码可用于工业控制.
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** CD.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** Communications Device Public Interfaces.
**
** Public interface definitions for the Communications Device, a "virtual"
** hardware device that is a device independent abstraction of any
** general communications device.
**
** The device independent CD interface shields the upper level software
** from any device specific details.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major>         Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
** ASIC independent public services: (found in cd.h or cd_util.c)
**
**    CD_Init()               - One time initialization
**    CD_QueueConfigTx()      - Queue a configuration packet for transmission
**    CD_QueueUnschedTx()     - Queue an unscheduled packet for transmission
**    CD_SetFixedTag()        - Enable/disable reception of a fixed tag
**    CD_TxUnscheduledTask()  - Unscheduled packet transmit processing task
**    CD_ValidPortNum()       - Checks for a valid port number
**
**
** ASIC dependent public services: (found in either ca_cd.c or sm_cd.c)
**
**    CD_ConfigTask()         - Device configuration request processing task
**    CD_GetLeds()            - Get current state of both LEDS in comm device
**    CD_GetTransportBuffer() - Attempt to get a Tx buffer
**    CD_PutTransportBuffer() - Indicate a gotten Tx buffer is ready to send
**
**
** Hardware dependent public service: (found in either ca_hw.c or sm_hw.c)
**
**    CD_HardResetAsic()      - Yank the reset pin on the ASIC
**
*****************************************************************************
*****************************************************************************
**                                                                         **
** 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 CD_H
#define CD_H

#include "ab.h"

/****************************************************************************
*****************************************************************************
**
** Network object interface - Constants
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** LED bit masks and state definitions.
** States apply to both LEDs.
** Shift LED B value right 4 bits to convert to state.
** Phase indicates which half of a flash cycle the LEDs are in.
**
**---------------------------------------------------------------------------
*/

#define CD_LED_CHAN_A_MASK          0x07
#define CD_LED_CHAN_B_MASK          0x70
#define CD_LED_PHASE_MASK           0x08

#define CD_LED_OFF                  0x00
#define CD_LED_RESET                0x00

#define CD_LED_GREEN                0x01
#define CD_LED_NETWORK_OK           0x01

#define CD_LED_FLASH_GREEN          0x02
#define CD_LED_TEMP_NETWORK_ERROR   0x02

#define CD_LED_FLASH_RED            0x03
#define CD_LED_LONELY               0x03

#define CD_LED_FLASH_RED_GREEN      0x04
#define CD_LED_BAD_CHANNEL          0x04

#define CD_LED_RR_RED               0x05
#define CD_LED_ROGUE                0x05

#define CD_LED_RR_RED_GREEN         0x06
#define CD_LED_SELF_TEST            0x06

#define CD_LED_RED                  0x07
#define CD_LED_FAULT                0x07



/*---------------------------------------------------------------------------
**
** Network mode states returned from cd_GetNetMode().
**
**---------------------------------------------------------------------------
*/

#define CD_NM_INVALID               0
#define CD_NM_POWER_UP              1
#define CD_NM_CHECK_4_CABLE         2
#define CD_NM_WAITING_2_ROGUE       3
#define CD_NM_CHECK_4_MODERATOR     4
#define CD_NM_IM_ALIVE              5
#define CD_NM_ATTACHED              6
#define CD_NM_FORCED_LISTEN_ONLY    7
#define CD_NM_DUP_NODE              8



/****************************************************************************
*****************************************************************************
**
** Network object interface - Packets
**
*****************************************************************************
*****************************************************************************
*/

/* None defined */



#ifdef CD_EN_OBJECTS

#include "gs.h"         /* General Services                                */
#include "cb.h"         /* ComBuf support                                  */
#include "ci.h"         /* General ControlNet International definitions    */
#include "cm.h"         /* Connection Manager publics                      */



/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Constants
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** The link timeout that would be calculated for default network parameters.
** And the undocumented, but nevertheless required, lower bound on the
** unconnected transmit retry timeout.
**
**---------------------------------------------------------------------------
*/

#define CD_DEFAULT_LINK_TIMEOUT  182L
#define CD_MIN_LINK_TIMEOUT      80L

#define EN_CD_DEFAULT_LINK_TIMEOUT  10000L



/*---------------------------------------------------------------------------
**
** Max number of transports that can be active at one time.
**
**---------------------------------------------------------------------------
*/

#define CD_NUM_TRANSPORTS  ( ( ( CD_NUM_CLASS_1 ) * 2 ) + ( CD_NUM_CLASS_3 ) )
#define EN_CD_NUM_TRANSPORTS  ( ( ( EN_CD_NUM_CLASS_1 ) * 2 ) + ( EN_CD_NUM_CLASS_3 ) )


/*---------------------------------------------------------------------------
**
** Size of the CD packet header plus any ASIC specific requirements.
**
**---------------------------------------------------------------------------
*/

#define CD_PACKET_HEADER_SIZE    4



/*---------------------------------------------------------------------------
**
** The different styles of run/idle status that may be
** produced and/or consumed by a class 1 transport.
**
** Note: These definitions MUST match the connection flag definitions
** in the CC object (these definitions are right justified bit-wise).
**
**---------------------------------------------------------------------------
*/

#define CD_RI_STYLE_32_BIT       0x0000
#define CD_RI_STYLE_ZERO_LEN     0x0001
#define CD_RI_STYLE_PURE_DATA    0x0002
#define CD_RI_STYLE_HEARTBEAT    0x0003
#define CD_RI_STYLE_NONE         0x0007



/*---------------------------------------------------------------------------
**
** Types of transports for Class1 connections.
**
**---------------------------------------------------------------------------
*/

#define CD_XPORT_TYPE_DEFAULT          0  /* Use default method to talk to internal obj.
                                          */

#define CD_XPORT_TYPE_PROVIDE_FUNCTION 1  /* Provide a function that will be called when data
                                          ** is available (producer) or is needed (consumer).
                                          */

#define CD_XPORT_TYPE_CALL_FUNCTION    2  /* Call a function when data
                                          ** is available (consumer) or is needed (producer).
                                          */

#define CD_XPORT_TYPE_PROVIDE_BUFFER   3  /* Provide a buffer that will be accessed when data
                                          ** is available (producer) or is needed (consumer).
                                          */

#define CD_XPORT_TYPE_ACCESS_BUFFER    4  /* Access a buffer when data
                                          ** is available (consumer) or is needed (producer).
                                          */

#define CD_XPORT_TYPE_MASK 0x0F           /* Mask to be used when testing for above values. */

#define CD_XPORT_BRIDGED_MASK 0x80        /* This Xport is part of a bridged connection and
                                          ** therefore is paired with another Xport on the other
                                          ** side of the bridge.
                                          */

/*---------------------------------------------------------------------------
**
** Which portions of the CD configuration to apply to the
** network interface hardware. Used with CD_ConfigTrrblType.
**
**---------------------------------------------------------------------------
*/

#define CD_CONFIG_NOTHING        0x0000
#define CD_CONFIG_HOST           0x0001
#define CD_CONFIG_PSYNC          0x0002
#define CD_CONFIG_SCREENERS      0x0004
#define CD_CONFIG_LINK           0x0008
#define CD_CONFIG_ALL            0x7FFF

#define CD_CONFIG_BROADCAST      0x8000


/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Enums
**
*****************************************************************************
*****************************************************************************
*/

/* None defined */



/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Structures
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** All public global data associated with a communications device.
** There is a separate structure to hold the private globals.
**
**---------------------------------------------------------------------------
*/

typedef struct CD_DataType
{
   /*
   ** MAC address for this device
   */

   UINT8 bMacId;

   /*
   ** Unscheduled traffic timeout (in milliseconds)
   ** Unscheduled traffic retry limit
   */

   GS_MSecType nLinkTimeout;
   UINT8       bRetryLimit;

   /*
   ** Number of transports for this port, and
   ** a pointer to the transport record array
   */

   UINT16  iNumTransports;
   struct cd_TransportRecordType  **papTransportRecords;

   /*
   ** Copy of pending and current link configuration parameters
   ** Copy of the current error log
   */

   BOOL                      fValidLinkConfig;

   /*
   ** Configuration task request queue
   ** High and low priority unscheduled transmit task requests queues
   ** UCMM & Connection Manager task request queues
   */

   GS_MsgQueueType    xConfigQid;
   GS_MsgQueueType    xTxUnschedHiQid;
   GS_MsgQueueType    xTxUnschedLoQid;
   GS_MsgQueueType    xUMQid;
   GS_MsgQueueType    xCMQid;

   /*
   ** Override the ucmm code in client requests?
   */

   UINT8              bUcmmCodeOverRide;

   /*
   ** Unconnected Send Loopback flag.
   */

   BOOL               fUcSendLoopback;

   /*
   ** Does this cd support network schedule segments (CNet e.g.)
   */

   BOOL               fUsesScheduleSegs;

   /*
   ** This is the percentage of CPU time used by the CD layer
   ** even when there are no connections open.
   ** Note: 100% = 1000000
   ** The ControlNet CD needs to reserve CPU bandwidth.
   ** However, other CD implementations may not.
   */

   INT32              lCPUresourceAllocated;

   /*
   ** Pointer to function which returns the net mode
   */

   /* jjw 11/1/99
   ** Port level specific routines
   */
   UINT8 *(*GetTransportBuffer)( UINT16 iTransport );
   void (*PutTransportBuffer)( UINT16 iTransport );
   UINT32 (*StartTransport)(  struct cd_TransportRecordType  *pTransport  );
   void (*StopTransport)(  struct cd_TransportRecordType  *pTransport  );
}
CD_DataType;

/****************************************************************************
*****************************************************************************
**
** Public internal object interface - Tribbles
**
*****************************************************************************
*****************************************************************************
*/

/*---------------------------------------------------------------------------
**
** CD_PacketTrrblType
**
** General use tribble for handling fixed tag packets and class 3 packets.
** Destination objects are not required to make a distinction to
** successfully process the packet, but object that care can determine
** what kind of packet it is by the following:
**
** For fixed tag packets, the tag and mac id will be filled in,
** and the transport id 0'd.
**
** For class 3 packets, the tag and mac id will be 0'd,
** and the transport id filled in.
**
**---------------------------------------------------------------------------
*/

typedef struct CD_PacketTrrblType

⌨️ 快捷键说明

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