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

📄 o22siomm.h

📁 从linux系统opto移植到vxworks的网口通信代码
💻 H
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------//// O22SIOMM.h// Copyright (c) 1999 - 2002 by Opto 22//// Header for the O22SnapIoMemMap C++ class.  // // The O22SnapIoMemMap C++ class is used to communicate from a computer to an// Opto 22 SNAP Ethernet I/O unit.//// The basic procedure for using this class is:////   1. Create an instance of the O22SnapIoMemMap class//   2. Call OpenEnet() or OpenEnet2() to start connecting to an I/O unit//   3. Call IsOpenDone() to complete the connection  process//   4. Call SetCommOptions() to set the desired timeout value//   5. Call any of the memory map functions, such as ConfigurePt(),//      GetAnaPtValue(), SetDigBankPointStates(), and ReadBlock(), to //      communicate with the I/O unit.  Repeat as neccessary.//   6. Call Close() when done.//// While this code was developed on Microsoft Windows 32-bit operating // systems, it is intended to be as generic as possible.  For Windows specific// code, search for "_WIN32" and "_WIN32_WCE".  For Linux specific code, search// for "_LINUX".//-----------------------------------------------------------------------------#ifndef __O22SIOMM_H_#define __O22SIOMM_H_#ifndef __O22SIOUT_H#include "O22SIOUT.h"#endif#ifndef __O22STRCT_H#include "O22STRCT.h"#endif  // Transaction code used by the I/O unit#define SIOMM_TCODE_WRITE_QUAD_REQUEST   0#define SIOMM_TCODE_WRITE_BLOCK_REQUEST  1#define SIOMM_TCODE_WRITE_RESPONSE       2#define SIOMM_TCODE_READ_QUAD_REQUEST    4#define SIOMM_TCODE_READ_BLOCK_REQUEST   5#define SIOMM_TCODE_READ_QUAD_RESPONSE   6#define SIOMM_TCODE_READ_BLOCK_RESPONSE  7// Sizes of the read/write requests and responses#define SIOMM_SIZE_WRITE_QUAD_REQUEST    16   #define SIOMM_SIZE_WRITE_BLOCK_REQUEST   16   #define SIOMM_SIZE_WRITE_RESPONSE        12#define SIOMM_SIZE_READ_QUAD_REQUEST     12#define SIOMM_SIZE_READ_QUAD_RESPONSE    16#define SIOMM_SIZE_READ_BLOCK_REQUEST    16#define SIOMM_SIZE_READ_BLOCK_RESPONSE   16// Response codes from the I/O unit#define SIOMM_RESPONSE_CODE_ACK          0#define SIOMM_RESPONSE_CODE_NAK          7// Memory Map values// Status read area of the memory map#define SIOMM_STATUS_READ_BASE                 0xF0300000#define SIOMM_STATUS_READ_PUC_FLAG             0xF0300004#define SIOMM_STATUS_READ_LAST_ERROR           0xF030000C#define SIOMM_STATUS_READ_BOOTP_FLAG           0xF0300048#define SIOMM_STATUS_READ_DEGREES_FLAG         0xF030004C#define SIOMM_STATUS_READ_WATCHDOG_TIME        0xF0300054#define SIOMM_STATUS_READ_PART_NUMBER          0xF0300080#define SIOMM_STATUS_READ_PART_NUMBER_SIZE     0x00000020// Date and Time#define SIOMM_DATE_AND_TIME_BASE               0xF0350000#define SIOMM_DATE_AND_TIME_SIZE               0x00000017// Serial Module#define SIOMM_SERIAL_MODULE_CONFIG_BASE        0xF03A8000#define SIOMM_SERIAL_MODULE_CONFIG_BOUNDARY    0x00000010#define SIOMM_SERIAL_MODULE_EOM_BASE           0xF03A8200#define SIOMM_SERIAL_MODULE_EOM_BOUNDARY       0x00000010// Status write area of the memory map#define SIOMM_STATUS_WRITE_OPERATION           0xF0380000#define SIOMM_STATUS_WRITE_BOOTP               0xF0380004#define SIOMM_STATUS_WRITE_TEMP_DEGREES        0xF0380008#define SIOMM_STATUS_WRITE_WATCHDOG_TIME       0xF0380010// Streaming configuration area of the memory map#define SIOMM_STREAM_CONFIG_BASE               0xF03FFFC4#define SIOMM_STREAM_CONFIG_ON_FLAG            0xF03FFFD0#define SIOMM_STREAM_CONFIG_INTERVAL           0xF03FFFD4#define SIOMM_STREAM_CONFIG_PORT               0xF03FFFD8#define SIOMM_STREAM_TARGET_BOUNDARY           0x00000004#define SIOMM_STREAM_TARGET_BASE               0xF03FFFE0// Digital bank read area of the memory map#define SIOMM_DBANK_READ_AREA_BASE             0xF0400000#define SIOMM_DBANK_READ_POINT_STATES          0xF0400000#define SIOMM_DBANK_READ_ON_LATCH_STATES       0xF0400008#define SIOMM_DBANK_READ_OFF_LATCH_STATES      0xF0400010#define SIOMM_DBANK_READ_ACTIVE_COUNTERS       0xF0400018#define SIOMM_DBANK_READ_COUNTER_DATA_BASE     0xF0400100#define SIOMM_DBANK_READ_COUNTER_DATA_BOUNDARY 0x00000004#define SIOMM_DBANK_MAX_FEATURE_ELEMENTS       0x00000040// Digital bank write area of the memory map#define SIOMM_DBANK_WRITE_AREA_BASE            0xF0500000#define SIOMM_DBANK_WRITE_TURN_ON_MASK         0xF0500000#define SIOMM_DBANK_WRITE_TURN_OFF_MASK        0xF0500008#define SIOMM_DBANK_WRITE_ACT_COUNTERS_MASK    0xF0500010#define SIOMM_DBANK_WRITE_DEACT_COUNTERS_MASK  0xF0500018// Analog bank read area of the memory map#define SIOMM_ABANK_READ_AREA_BASE             0xF0600000#define SIOMM_ABANK_READ_POINT_VALUES          0xF0600000#define SIOMM_ABANK_READ_POINT_COUNTS          0xF0600100#define SIOMM_ABANK_READ_POINT_MIN_VALUES      0xF0600200#define SIOMM_ABANK_READ_POINT_MAX_VALUES      0xF0600300// Analog bank write area of the memory map#define SIOMM_ABANK_WRITE_AREA_BASE            0xF0700000#define SIOMM_ABANK_WRITE_POINT_VALUES         0xF0700000#define SIOMM_ABANK_WRITE_POINT_COUNTS         0xF0700100#define SIOMM_ABANK_MAX_BYTES                  0x00000100#define SIOMM_ABANK_MAX_ELEMENTS               0x00000040// Digital point read area of the memory map#define SIOMM_DPOINT_READ_BOUNDARY             0x00000040#define SIOMM_DPOINT_READ_AREA_BASE            0xF0800000#define SIOMM_DPOINT_READ_STATE                0xF0800000#define SIOMM_DPOINT_READ_ONLATCH_STATE        0xF0800004#define SIOMM_DPOINT_READ_OFFLATCH_STATE       0xF0800008#define SIOMM_DPOINT_READ_ACTIVE_COUNTER       0xF080000C#define SIOMM_DPOINT_READ_COUNTER_DATA         0xF0800010// Digital point write area of the memory map#define SIOMM_DPOINT_WRITE_BOUNDARY            0x00000040#define SIOMM_DPOINT_WRITE_TURN_ON_BASE        0xF0900000#define SIOMM_DPOINT_WRITE_TURN_OFF_BASE       0xF0900004#define SIOMM_DPOINT_WRITE_ACTIVATE_COUNTER    0xF0900008#define SIOMM_DPOINT_WRITE_DEACTIVATE_COUNTER  0xF090000C// Analog point read area of the memory map#define SIOMM_APOINT_READ_BOUNDARY             0x00000040#define SIOMM_APOINT_READ_AREA_BASE            0xF0A00000#define SIOMM_APOINT_READ_VALUE_BASE           0xF0A00000#define SIOMM_APOINT_READ_COUNTS_BASE          0xF0A00004#define SIOMM_APOINT_READ_MIN_VALUE_BASE       0xF0A00008#define SIOMM_APOINT_READ_MAX_VALUE_BASE       0xF0A0000C#define SIOMM_APOINT_READ_TPO_PERIOD_BASE      0xF0B0000C// Analog point write area of the memory map#define SIOMM_APOINT_WRITE_BOUNDARY            0x00000040#define SIOMM_APOINT_WRITE_VALUE_BASE          0xF0B00000#define SIOMM_APOINT_WRITE_COUNTS_BASE         0xF0B00004#define SIOMM_APOINT_WRITE_TPO_PERIOD_BASE     0xF0B0000C// Point configuration area of the memory map#define SIOMM_POINT_CONFIG_BOUNDARY               0x00000040#define SIOMM_POINT_CONFIG_READ_MOD_TYPE_BASE     0xF0C00000#define SIOMM_POINT_CONFIG_WRITE_TYPE_BASE        0xF0C00004#define SIOMM_POINT_CONFIG_WRITE_FEATURE_BASE     0xF0C00008#define SIOMM_POINT_CONFIG_WRITE_OFFSET_BASE      0xF0C0000C#define SIOMM_POINT_CONFIG_WRITE_GAIN_BASE        0xF0C00010#define SIOMM_POINT_CONFIG_WRITE_HISCALE_BASE     0xF0C00014#define SIOMM_POINT_CONFIG_WRITE_LOSCALE_BASE     0xF0C00018#define SIOMM_POINT_CONFIG_WRITE_WDOG_VALUE_BASE  0xF0C00024#define SIOMM_POINT_CONFIG_WRITE_WDOG_ENABLE_BASE 0xF0C00028#define SIOMM_POINT_CONFIG_NAME_SIZE              0x00000010// Digital point read and clear area of the memory map#define SIOMM_DPOINT_READ_CLEAR_BOUNDARY       0x00000004#define SIOMM_DPOINT_READ_CLEAR_COUNTS_BASE    0xF0F00000#define SIOMM_DPOINT_READ_CLEAR_ON_LATCH_BASE  0xF0F00100#define SIOMM_DPOINT_READ_CLEAR_OFF_LATCH_BASE 0xF0F00200// Analog point read and clear area of the memory map#define SIOMM_APOINT_READ_CLEAR_BOUNDARY       0x00000004#define SIOMM_APOINT_READ_CLEAR_MIN_VALUE_BASE 0xF0F80000#define SIOMM_APOINT_READ_CLEAR_MAX_VALUE_BASE 0xF0F80100// Analog point calc and set area of the memory map#define SIOMM_APOINT_READ_CALC_SET_BOUNDARY    0x00000004#define SIOMM_APOINT_READ_CALC_SET_OFFSET_BASE 0xF0E00000#define SIOMM_APOINT_READ_CALC_SET_GAIN_BASE   0xF0E00100// Streaming read area of the memory map#define SIOMM_STREAM_READ_AREA_BASE            0xF1000000#define SIOMM_STREAM_READ_AREA_SIZE            0x00000220// Scratch pad aread of the memory map#define SIOMM_SCRATCHPAD_BITS_BASE             0xF0D80000#define SIOMM_SCRATCHPAD_BITS_ON_MASK_BASE     0xF0D80400#define SIOMM_SCRATCHPAD_BITS_OFF_MASK_BASE    0xF0D80408#define SIOMM_SCRATCHPAD_INTEGER_BASE          0xF0D81000#define SIOMM_SCRATCHPAD_INTEGER_MAX_BYTES     0x00000400#define SIOMM_SCRATCHPAD_INTEGER_MAX_ELEMENTS  0x00000100#define SIOMM_SCRATCHPAD_FLOAT_BASE            0xF0D82000#define SIOMM_SCRATCHPAD_FLOAT_MAX_BYTES       0x00000400#define SIOMM_SCRATCHPAD_FLOAT_MAX_ELEMENTS    0x00000100#define SIOMM_SCRATCHPAD_STRING_BASE           0xF0D83000#define SIOMM_SCRATCHPAD_STRING_LENGTH_BASE    0xF0D83000#define SIOMM_SCRATCHPAD_STRING_LENGTH_SIZE    0x00000002#define SIOMM_SCRATCHPAD_STRING_DATA_BASE      0xF0D83002#define SIOMM_SCRATCHPAD_STRING_DATA_SIZE      0x00000080#define SIOMM_SCRATCHPAD_STRING_BOUNDARY       0x00000082#define SIOMM_SCRATCHPAD_STRING_MAX_BYTES      0x00000410#define SIOMM_SCRATCHPAD_STRING_MAX_ELEMENTS   0x00000008class O22SnapIoMemMap {  public:  // Public data    // Public Construction/Destruction    O22SnapIoMemMap();    ~O22SnapIoMemMap();  // Public Members    // Connection functions    LONG OpenEnet (char * pchIpAddressArg, long nPort, long nOpenTimeOutMS, long nAutoPUC);    LONG OpenEnet2(char * pchIpAddressArg, long nPort, long nOpenTimeOutMS, long nAutoPUC,                    long nConnectionType);    //---------------------------------------------------------------------------------------------    //  Usage  : Starts the connection process to a SNAP Ethernet brain.     //           Use the IsOpenDone() method to check if the open connection is completed.     //           OpenEnet() creates a TCP connection while OpenEnet2() allows the connection    //           type to be specified.    //    //  Input  : pchIpAddressArg - IP address of I/O unit in "X.X.X.X" form.    //           nPort - The Ethernet port to connect to, such as 2001    //           nOpenTimeOutMS - a timeout value for the open process. Used by IsOpenDone()    //                            to determine if the open process has timed out.    //           nAutoPUC - used to automatically read and clear the I/O unit's Powerup Clear flag.    //           nConnectionType - SIOMM_TCP for TCP connection, SIOMM_UDP for UDP connection    //  Output : none    //  Returns: SIOMM_OK if everything is OK, an error otherwise.    //---------------------------------------------------------------------------------------------    LONG IsOpenDone();    //---------------------------------------------------------------------------------------------    //  Usage  : Called after OpenEnet() to determine if the connection process is completed yet.    //           This should be called until it doesn't return SIOMM_ERROR_NOT_CONNECTED_YET.    //           If SIOMM_OK is returned, the connection process is complete and there is a     //           connection to the I/O unit.

⌨️ 快捷键说明

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