📄 ci.h
字号:
/****************************************************************************
*****************************************************************************
**
** File Name
** ---------
**
** CI.H
**
*****************************************************************************
*****************************************************************************
**
** Description
** -----------
**
** ControlNet International basic definitions.
**
*****************************************************************************
*****************************************************************************
**
** Source Change Indices
** ---------------------
**
** Porting: <none>0----<major> Customization: <none>0----<major>
**
*****************************************************************************
*****************************************************************************
**
** Services List
** -------------
**
** CI_IoiPathSize() - Returns size in bytes of an IOI or path
** CI_StripIoiPath() - Strip an entire IOI or path
**
** CI_ParseSegment() - Parse/remove one segment
** CI_ParseIoiSegment() - Parse/remove one IOI segment
** CI_ParseIoiClassInstance() - Parse/remove class & instance from IOI
** CI_ParsePathSegment() - Parse/remove one path segment
**
** CI_PrependIoi() - Prepend an IOI to a packet
** CI_PrependReplyHeader() - Prepend a reply header to a packet
** CI_PrependReplyHeaderWithExtendedERC()
** - Prepend header with extended error code
**
*****************************************************************************
*****************************************************************************
** **
** 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 CI_H
#define CI_H
/*
** Determine if this code is to be included.
*/
#ifdef CD_EN_OBJECTS
/****************************************************************************
**
** Constants
**
*****************************************************************************
*/
/*---------------------------------------------------------------------------
**
** Default Network Attributes (for wake up on quiet network)
**
**---------------------------------------------------------------------------
*/
#define CI_NUT 10000 /* Network Update Time (word) in */
/* 10 us ticks */
#define CI_SMAX 0 /* SMAX - max scheduled MAC addr */
#define CI_UMAX 99 /* UMAX - max unscheduled MAC addr */
#define CI_SLOTTIME 254 /* Slot Time in 1us ticks */
#define CI_BLANKTIME 6 /* Blanking Time in bytes */
#define CI_GBSTART 61 /* Guardband Start in 10us ticks */
#define CI_GBCENTER 45 /* Guardband Center in 10us ticks */
#define CI_IMODULUS 127 /* Interval Count Modulus (max NUT) */
#define CI_GBPRESTART 92 /* GB PreStart */
#define CI_REDUNDANCY_BOTH 3 /* Various redundancy settings */
#define CI_REDUNDANCY_A_ONLY 2
#define CI_REDUNDANCY_NAP_ONLY 0
/*---------------------------------------------------------------------------
**
** ControlNet Basic Packet Constants
**
**---------------------------------------------------------------------------
*/
/*
** Bit definitions for packet Control byte.
*/
#define CI_CTRL_FIXED_TAG 0x01 /* fixed tag packet */
#define CI_CTRL_TAG_PAD 0x02 /* tag pad */
#define CI_CTRL_DATA_PAD 0x04 /* data pad */
#define CI_CTRL_WORD_DATA 0x08 /* word data (!byte data) */
#define CI_CTRL_ACCEPT_ALWAYS 0x10 /* always accept gen tag packets */
/*
** Defined fixed tags.
** First group are ASIC configuration and status tags.
** Second group are higher level software defined tags.
*/
#define CI_MODERATOR_FTAG 0x00 /* Moderator */
#define CI_R_CUR_CONFIG_FTAG 0x0A /* Read current net config */
#define CI_R_STATION_STAT_FTAG 0x11 /* Read station status */
#define CI_R_COUNTERS_FTAG 0x12 /* Read diag counters */
#define CI_R_CLEAR_COUNTERS_FTAG 0x13 /* Read and clear diag counters */
#define CI_T_MINUS_FTAG 0x15 /* T-Minus (start config change) */
#define CI_W_HOST_PARAMS_FTAG 0x16 /* Host interface parameters */
#define CI_W_NET_PARAMS_FTAG 0x17 /* Pending network parameters */
#define CI_W_STREAM_PARAMS_FTAG 0x18 /* Tx stream & P-sync parameters */
#define CI_W_FIX_SCREEN_LO_FTAG 0x1C /* Fixed screener write */
#define CI_W_FIX_SCREEN_HI_FTAG 0x1D /* Lo and hi halves (use together) */
#define CI_RESPONSE_FTAG 0x20 /* Bits to OR to make a request */
/* packet a response packet */
#define CI_CUR_CONFIG_FTAG 0x2A /* Current net config response */
#define CI_STATION_STAT_FTAG 0x31 /* Station status response */
#define CI_COUNTERS_FTAG 0x32 /* Diag counters response */
#define CI_CLEAR_COUNTERS_FTAG 0x33 /* Diag counters response */
#define CI_LAST_CNET_OBJECT_FTAG 0x33 /* Highest tag the CNet obj wants */
#define CI_FIRST_FTAG 0x80 /* lowest general use fixed tag */
#define CI_IM_ALIVE_FTAG 0x80 /* I'm alive (startup) */
#define CI_LINK_CONFIG_FTAG 0x81 /* Set link configuration */
#define CI_UCMM_FTAG 0x83 /* UCMM */
#define CI_TUI_FTAG 0x84 /* TUI */
#define CI_WAMI_FTAG 0x86 /* Where am I */
#define CI_UCMM_ALT_FTAG 0x88 /* Keeper UCMM */
#define CI_DIAGNOSTIC_FTAG 0x90 /* General diagnostic fixed tag */
#define CI_DEBUG_ECHO_FTAG 0x7D /* debug echo */
#define CI_DEBUG_REQ_FTAG 0x7E /* debug request */
#define CI_DEBUG_RESP_FTAG 0x7F /* debug response */
#define CI_LAST_FTAG 0x7F /* highest general use fixed tag */
/*---------------------------------------------------------------------------
**
** ControlNet Broadcast Mac-ID
**
**---------------------------------------------------------------------------
*/
#define CI_BROADCAST_MAC_ID 0xFF /* reserved broadcast Mac-ID */
/*---------------------------------------------------------------------------
**
** TUI packet flag bits
**
**---------------------------------------------------------------------------
*/
#define CI_TUI_REDUNDANCY 0x0003 /* Desired network redundancy */
#define CI_TUI_CHANNEL_B 0x0001
#define CI_TUI_CHANNEL_A 0x0002
#define CI_TUI_REDUNDANT 0x0003
#define CI_TUI_NET_RESOURCE 0x0004 /* Network resource being held */
#define CI_TUI_NET_CHANGING 0x0008 /* Sync network change in progress */
#define CI_TUI_MASTER 0x0010 /* TUI is from a master keeper */
#define CI_TUI_CONFIGURED 0x0020 /* TUI is from a configured keeper */
/*---------------------------------------------------------------------------
**
** IOI Segment Type Mask and Values
**
**---------------------------------------------------------------------------
*/
#define CI_SEGMENT_TYPE_MASK 0xE0 /* IOI Segment Type Mask */
#define CI_PATH_SEGMENT 0x00 /* Path type segment indicator */
#define CI_LOGICAL_SEGMENT 0x20 /* logical type segment indicator */
#define CI_NETWORK_SEGMENT 0x40 /* when/how to send */
#define CI_SYMBOLIC_SEGMENT 0x60 /* symbolic type segment indicator */
#define CI_DATA_SEGMENT 0x80 /* data segment indicator */
/*---------------------------------------------------------------------------
**
** IOI path segment types and formats.
**
** Segment syntax:
**
** [ps][xx] - 8 bit node address xx
** [ps][ss][xxxx]... - ss byte long node address xxxx
**
**---------------------------------------------------------------------------
*/
#define CI_PATH_SEG_SIZE_MASK 0x10
#define CI_PATH_SEG_8_BIT 0x00
#define CI_PATH_SEG_N_BIT 0x10
#define CI_PATH_SEG_PORT_MASK 0x07
/*---------------------------------------------------------------------------
**
** IOI logical segment types & formats.
**
** Segment syntax:
**
** [ls][xx] - 8 bit logical segment xx
** [ls][pp][xx][xx] - 16 bit logical segment xxxx
** [34][04][kkkk][kkkk][kkkk][kkkk] - Electronic key
**
** where:
** ls is 20 = 8 bit class
** 21 = 16 bit class
** 24 = 8 bit instance
** 25 = 16 bit instance
** 2c = 8 bit connection point
** 2d = 16 bit connection point
** 30 = 8 bit attribute number
** 31 = 16 bit attribute number
** pp is a pad byte
** xx,xxxx are the identifiers
** kkkk are electronic key structure values
**
**---------------------------------------------------------------------------
*/
#define CI_LOGICAL_SEG_TYPE_MASK 0x1C
#define CI_LOGICAL_SEG_CLASS 0x20
#define CI_LOGICAL_SEG_INSTANCE 0x24
#define CI_LOGICAL_SEG_STRUCTURE 0x28
#define CI_LOGICAL_SEG_CON_POINT 0x2C
#define CI_LOGICAL_SEG_ATTRIBUTE 0x30
#define CI_LOGICAL_SEG_KEY 0x34
#define CI_LOGICAL_SEG_FORMAT_MASK 0x03
#define CI_LOGICAL_SEG_8_BIT 0x00
#define CI_LOGICAL_SEG_16_BIT 0x01
/*---------------------------------------------------------------------------
**
** IOI network segment types & formats.
**
** Segment syntax:
**
** [41][xx] - Schedule segment - xx = Starting NUT + Update Interval
** [42][yy] - Fixed tag segment - yy = Fixed tag to use
** [43][zz] - production ihibit segment - zz = minimum ms between productions
**
**---------------------------------------------------------------------------
*/
#define CI_NETWORK_SEG_TYPE_MASK 0x07
#define CI_NETWORK_SEG_SCHEDULE 0x01
#define CI_NETWORK_SEG_FIXED_TAG 0x02
#define CI_NETWORK_SEG_PROD_INHIBIT 0x03
/*---------------------------------------------------------------------------
**
** IOI symbolic segment not supported in the example code at this time.
**
**---------------------------------------------------------------------------
*/
/*---------------------------------------------------------------------------
**
** IOI data segment types & formats.
**
** Segment syntax:
**
** [ds][sw][xxxx][xxxx][xxxx] ... - Simple data segment
** [ds][sb][xx][xx][xx] ... [pp] - ANSI Extended Symbol segment
**
** where:
** ds is 80 = Simple data segment.
** 91 = ANSI Extended Symbol segment
** sw is size in 16 bit words.
** sb is size in bytes.
** xx is a byte datum.
** xxxx is a 16 bit word datum
** pp is a pad byte (optional - only included if [sb] is odd)
**
** For more information see Chapter 4 section 3.2.2.6 of the
** ControlNet International spec.
**
**---------------------------------------------------------------------------
*/
#define CI_DATA_SEG_SIMPLE 0x80 /* Simple data segment. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -