亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? udbldmsg.c

?? 工業組態軟件modbus驅動源代碼, 包括幫助文件.共享.
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* $Header: "%n Ver=%v  %f  LastEdit=%w  Locker=%l" */
/* "UDBLDMSG.C Ver=3  26-Nov-97,11:20:02  LastEdit=JIMV  Locker=***_NOBODY_***" */
/***********************************************************************\
*                                                                       *
*       Copyright Wonderware Software Development Corp. 1992-1997       *
*                                                                       *
*               ThisFileName="L:\ww\dde_serv\src\udsample\udbldmsg.c"   *
*               LastEditDate="1997 Nov 26  11:20:00"                    *
*                                                                       *
\***********************************************************************/

#define LINT_ARGS

#include <windows.h>
#include <stdio.h>
#include <string.h>

#include "ntconv.h"
#include "hmemcpy.h"
#include "uddefs.h"
#include "debug.h"
#include "wwassert.h"
#include "Utitech.h"
#include "CheckItem.h"

USES_ASSERT

static char msg[120+1];        /* local buffer for creating message */

static VOID WINAPI ShowBldMsg (LPSTR lpStr, WORD len);

#ifndef USE_ASCII_HEX_MESSAGES
/* >>>>>>>> USE_ASCII_HEX_MESSAGES defined <<<<<<<< */
/***********************************************************************\
    The following three values are protocol-dependent.

    The example code below assumes send and receive messages are ASCII.
    It also assumes a header of the form
        :BBAAAANN
    where BB   is a  command in hex ASCII
          AAAA is an address in hex ASCII
          NN   is a  number of words in hex ASCII
    Alternatively, an error message may be received,
    which will have one of the following forms:
        :000000000000FF;
    for a garbled message
        :00BBAAAANN00XX;
    for an invalid command BB
        :00BBAAAANNDDXX;
    for an invalid number of "cells" to read or write
    So by the ninth character, we know how many are coming.
\***********************************************************************/

BOOL bBldSendMsgInBinary = FALSE;  /* =TRUE if messages are sent in binary */
BOOL bBldRecvMsgInBinary = FALSE;  /* =TRUE if messages are received in binary */
int  nBldRecvMsgMinLen   = 9;      /* min chars needed to get msg length */

#else
/* >>>>>>>> USE_ASCII_HEX_MESSAGES not defined <<<<<<<< */
/***********************************************************************\
    The following three values are protocol-dependent.

    The example code below assumes send and receive messages are binary.
    It also assumes a header of the form
        BBAAAANN
    where BB   is a 1-byte command
          AAAA is a 2-byte address
          NN   is a 1-byte number of words
    Alternatively, an error message may be received,
    which will have one of the following forms:
        000000000000FF
    for a garbled message
        00BBAAAANN00XX
    for an invalid command BB
        00BBAAAANNDDXX
    for an invalid number of "cells" to read or write
    So by the fourth character, we know how many are coming.
\***********************************************************************/

BOOL bBldSendMsgInBinary = TRUE;   /* =TRUE if messages are sent in binary */
BOOL bBldRecvMsgInBinary = TRUE;   /* =TRUE if messages are received in binary */
int  nBldRecvMsgMinLen   = 4;      /* min chars needed to get msg length */

#endif

/***********************************************************************/
/** Data conversion tables **/

/** This table provides a simple way of converting binary to ASCII hex **/
char BtoAtable[]=
{
    '0', '1', '2', '3', '4', '5', '6', '7',
    '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};

/** This table provides a simple way of converting hex ASCII to binary **/
BYTE AtoBtable[] = {
    0,  1,  2,  3,  4,  5,  6,  7,
    8,  9,  0,  0,  0,  0,  0,  0,
    0, 10, 11, 12, 13, 14, 15
};

/***********************************************************************/
/** put binary value for byte into indicated string
    returns pointer to end of string */

LPSTR
WINAPI
put_bin_byte (LPSTR lpMsg, BYTE x)
{
    /* put binary character in message */
    *(lpMsg++) = x;

    /* return pointer to end of string */
    return (lpMsg);
} /* put_bin_byte */

/***********************************************************************/
/** put ASCII hex for byte into indicated string
    returns pointer to end of string */

LPSTR
WINAPI
put_hex_byte (LPSTR lpMsg, BYTE x)
{
    int y;
    LPSTR p;

    /* point to end of string */
    lpMsg += 2;
    p = lpMsg;

    /* put hex characters in message, starting at lsnybble */
    y = x;
    *(--p) = BtoAtable[y & 0x0F];
    y = y >> 4;
    *(--p) = BtoAtable[y & 0x0F];

    /* return pointer to end of string */
    return (lpMsg);
} /* put_hex_byte */

/***********************************************************************/
/** put binary value for word into indicated string
    returns pointer to end of string */

LPSTR
WINAPI
put_bin_word (LPSTR lpMsg, WORD x)
{
    int y;
    LPSTR p;

    /* point to end of string */
    lpMsg += 2;
    p = lpMsg;

    /* put binary characters in message, starting at lsbyte */
    y = x;
    *(--p) = (BYTE) (y & 0x00FF);
    y = y >> 8;
    *(--p) = (BYTE) (y & 0x00FF);

    /* return pointer to end of string */
    return (lpMsg);
} /* put_bin_word */

/***********************************************************************/
/** put ASCII hex for word into indicated string
    returns pointer to end of string */

LPSTR
WINAPI
put_hex_word (LPSTR lpMsg, WORD x)
{
    int y;
    LPSTR p;

    /* point to end of string */
    lpMsg += 4;
    p = lpMsg;

    /* put hex characters in message, starting at lsnybble */
    y = x;
    *(--p) = BtoAtable[y & 0x000F];
    y = y >> 4;
    *(--p) = BtoAtable[y & 0x000F];
    y = y >> 4;
    *(--p) = BtoAtable[y & 0x000F];
    y = y >> 4;
    *(--p) = BtoAtable[y & 0x000F];

    /* return pointer to end of string */
    return (lpMsg);
} /* put_hex_word */

/***********************************************************************/
/** put binary value for long into indicated string
    returns pointer to end of string */

LPSTR
WINAPI
put_bin_long (LPSTR lpMsg, long x)
{
    long y;
    LPSTR p;

    /* point to end of string */
    lpMsg += 4;
    p = lpMsg;

    /* put binary characters in message, starting at lsbyte */
    y = x;
    *(--p) = (BYTE) (y & 0x00FF);
    y = y >> 8;
    *(--p) = (BYTE) (y & 0x00FF);
    y = y >> 8;
    *(--p) = (BYTE) (y & 0x00FF);
    y = y >> 8;
    *(--p) = (BYTE) (y & 0x00FF);

    /* return pointer to end of string */
    return (lpMsg);
} /* put_bin_long */

/***********************************************************************/
/** put ASCII hex for long into indicated string
    returns pointer to end of string */

LPSTR
WINAPI
put_hex_long (LPSTR lpMsg, long x)
{
    long y;
    int i;
    LPSTR p;

    /* point to end of string */
    lpMsg += 8;
    p = lpMsg;

    /* put hex characters in message, starting at lsnybble */
    y = x;
    for (i = 0; i < 7; i++) {
        *(--p) = BtoAtable[y & 0x000F];
        y = y >> 4;
    }
    *(--p) = BtoAtable[y & 0x000F];

    /* return pointer to end of string */
    return (lpMsg);
} /* put_hex_long */

/***********************************************************************/
/* check whether character is hex ASCII */

BOOL
WINAPI
IsHexASCII (char ch)
{
    return ((('0' <= ch) && (ch <= '9')) ||
            (('A' <= ch) && (ch <= 'F')) ||
            (('a' <= ch) && (ch <= 'f')));
} /* IsHexASCII */

/***********************************************************************/
/* convert hex ASCII to binary byte value */

BYTE
WINAPI
ah_to_bin (LPSTR lpStr, BOOL *ok)
{
    char ch;
    int byteval;

    /* initialize return value, validity flag */
    byteval = 0;
    *ok = TRUE;

    /* get character, check it */
    ch = *(lpStr++);
    if (('a' <= ch) && (ch <= 'f')) {
        /* convert to uppper case */
        ch = (char) (ch - 32);
    }
    if ((('0' <= ch) && (ch <= '9')) ||
        (('A' <= ch) && (ch <= 'F')))
        /* valid hex character, get corresponding value */
        byteval = (AtoBtable[ch - (char) '0']) << 4;
    else
        /* invalid hex character, treat as '0' and flag error */
        *ok = FALSE;

    /* get character, check it */
    ch = *lpStr;
    if (('a' <= ch) && (ch <= 'f')) {
        /* convert to uppper case */
        ch = (char) (ch - 32);
    }
    if ((('0' <= ch) && (ch <= '9')) ||
        (('A' <= ch) && (ch <= 'F')))
        /* valid hex character, get corresponding value */
        byteval |= (AtoBtable[ch - (char) '0']);
    else
        /* invalid hex character, treat as '0' and flag error */
        *ok = FALSE;

    /* return value, validity flag */
    return ((BYTE) byteval);
} /* ah_to_bin */

/***********************************************************************/
/** convert hexadecimal digit string to long integer value
    returns errflg TRUE if number is out of range **/

long
WINAPI
GetHexVal (LPSTR scan_ptr, int len, int *errflg)
{
    char ch;
    long x;
    BOOL digit_found;

    /* initialize value, error flags */
    x = 0;
    digit_found = FALSE;
    *errflg = 0;

    /* convert as hexadecimal value */
    while (len > 0) {
        /* get character, decrement count */
        ch = *(scan_ptr++);
        len--;
        /* check character */
        if ((('0' <= ch) && (ch <= '9')) ||
            (('A' <= ch) && (ch <= 'F')) ||
            (('a' <= ch) && (ch <= 'f'))) {
            digit_found = TRUE;
            if (x <= 0x0FFFFFFFL) {
                if (ch >= 'a')
                    ch -= 32;
                if (ch > '9')
                    ch -= 7;
                x = (x << 4) + (ch - '0');
            } else {
                /* value too large, indicate error and quit */
                *errflg = 1;
                len = 0;
            }
        } else {
            /* not a digit, quit */
            len = 0;
        }
    }

    /* check whether any digits were found */
    if (!digit_found)
        /* no digits, indicate error */
        *errflg = 1;

    /* return value */
    return (x);
} /* GetHexVal */

#ifdef USE_ASCII_HEX_MESSAGES
/* >>>>>>>> USE_ASCII_HEX_MESSAGES defined <<<<<<<< */
/***********************************************************************/
/** calculate checksum of message **/

/*************************************************************\
    The content of this routine is protocol dependent.
    Modify it as required.
\*************************************************************/

BYTE
WINAPI
BldCks(LPSTR       lpBuf,     /* pointer to buffer containing message */
       int         len,       /* length of message */
       int        *errflg)    /* nonzero if invalid characters */
{
    int cks, byteval;
    char ch1, ch2;

    /* initialize checksum, error flag */
    cks = 0;
    *errflg = 0;

    /************************************************\
        include byte lpBuf[i] in the checksum
        Example:
    \************************************************/

    /* get byte values, i.e. pairs of hex ASCII characters */
    while (len > 0) {
        /* get pair of characters */
        ch1 = *(lpBuf++); len--;
        ch2 = 0;
        if (len > 0) {
            ch2 = *(lpBuf++); len--;
        }
        /* verify that both are ASCII hex */
        if ((IsHexASCII (ch1)) && IsHexASCII (ch2)) {
            /* get corresponding binary value */
            if (ch1 >= 'a') ch1 -= 32;        /* force to upper case */
            if (ch1 > '9')  ch1 -= 7;         /* subtract offset for A-F */
            byteval = (ch1 - '0');
            if (ch2 >= 'a') ch2 -= 32;        /* force to upper case */
            if (ch2 > '9')  ch2 -= 7;         /* subtract offset for A-F */
            byteval = (byteval << 4) + (ch2 - '0');
            /* update checksum */
            cks = (cks + byteval) & 0xFF;
        } else {
            /* indicate error, force end of scan */
            *errflg = 1;
            len = 0;
        }
    }

    /* invert checksum and return it */
    cks = 0xFF - cks;
    return ((BYTE) cks);
} /* BldCks */

/***********************************************************************/
/** build message to read data from a point in the PLC,
    return length of message **/

/************************************************************************\
  Note: The last four arguments to this routine are protocol-dependent.
  Modify them as required.
\************************************************************************/

WORD
WINAPI
BldRead(BYTE	plcAddr,	  /* 2/28/2000 Modify by Chen jun local PLC address (PLC的通信地址) */
		LPSTR  *plpMsg,       /* pointer to where the message is stored */
        BYTE    plcDataType,  /* type of data to read(查詢數據的PLC) */
       	BYTE    DDEType,      /* type of data to transfer(查詢數據的DDE類型) */
        WORD    addr1,        /* address of point(s) to be accessed(查詢的起始地址) */
        WORD    numRd)        /* number of items to read(一次查詢的寄存器數量) */
{
    LPSTR  ptr;
    BYTE   msgCmd;
    WORD   len;
    WORD   cks;
    //int    errflg;
    len = 0;

      /* determine message command */
	// 3/1/2000 Modify by chen jun
	switch (plcDataType){
		case ITEM_HOLDING_COIL:
             msgCmd = 1;
			 break;
		case ITEM_INPUT_COIL:
             msgCmd = 2;
			 break;
    	case ITEM_HOLDING_REG:
             msgCmd = 3;
			 break;
		case ITEM_INPUT_REG:
             msgCmd = 4;
			 break;
	}
    /* initialize message buffer pointer */
    ptr = (LPSTR) msg;

    /* message type */
	// 2/29/2000 modify by Chen jun
    ptr = put_bin_byte (ptr, plcAddr); len+=1;
    
	ptr = put_bin_byte (ptr, msgCmd);  len+=1;
    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产嫩草影院久久久久| 7777精品伊人久久久大香线蕉的 | 91激情在线视频| 日本电影亚洲天堂一区| 免费成人在线视频观看| 欧美精品一区二| 色欧美日韩亚洲| 精品一区二区三区av| 亚洲一区二区三区中文字幕在线| 久久久久88色偷偷免费| 欧美亚洲日本一区| 美女视频黄久久| 精品国产免费久久| 91在线视频网址| 日韩高清国产一区在线| 中文字幕一区av| 久久免费视频一区| 欧美精品日日鲁夜夜添| 91丝袜美腿高跟国产极品老师| 秋霞电影一区二区| 亚洲综合免费观看高清完整版在线| 欧美日韩黄色影视| 91麻豆精品秘密| 国产美女在线精品| 免费三级欧美电影| 一区二区三区电影在线播| 久久噜噜亚洲综合| 精品久久人人做人人爽| 国产成人精品午夜视频免费| 免费成人在线视频观看| 久久久久综合网| 久久久夜色精品亚洲| 欧美一级理论片| 欧美一区二区国产| 欧美日高清视频| 欧美日韩中文字幕一区| 日本乱人伦一区| 色综合久久天天| 91免费看视频| 91污片在线观看| 色婷婷国产精品综合在线观看| 国内外精品视频| 国产福利一区二区三区视频| 蜜桃av一区二区在线观看| 亚洲成人你懂的| 免费三级欧美电影| 韩国成人精品a∨在线观看| 成人激情免费电影网址| 69精品人人人人| 一色桃子久久精品亚洲| 极品瑜伽女神91| av不卡在线播放| 久久奇米777| 麻豆成人免费电影| 欧美性猛交一区二区三区精品| 久久久噜噜噜久久中文字幕色伊伊| 亚洲一区二区av在线| 成人美女视频在线观看| 精品国产亚洲在线| 日韩国产欧美在线播放| 日本大香伊一区二区三区| 中文字幕免费观看一区| 国模冰冰炮一区二区| 欧美日韩一区二区三区高清| 亚洲美女少妇撒尿| 97久久超碰精品国产| 国产欧美一区二区精品秋霞影院| 蜜臀av一级做a爰片久久| 欧美疯狂性受xxxxx喷水图片| 亚洲黄色小视频| 色播五月激情综合网| 亚洲精品第一国产综合野| 91首页免费视频| 亚洲欧美欧美一区二区三区| 不卡视频在线看| 亚洲视频综合在线| 色婷婷综合激情| 亚洲一区二三区| 欧美三级中文字幕| 日韩制服丝袜先锋影音| 欧美一级理论片| 韩国女主播一区| 国产精品沙发午睡系列990531| 国产精品性做久久久久久| 久久精品欧美一区二区三区麻豆| 久久激情五月婷婷| 精品久久久久一区| 久久丁香综合五月国产三级网站| 日韩视频免费直播| 精品亚洲欧美一区| 国产日韩精品一区二区三区| 国产精品一区二区三区四区| 中文字幕的久久| 色婷婷综合久色| 日韩一区精品视频| 国产亚洲视频系列| av电影在线观看一区| 亚洲第一狼人社区| 精品国产免费视频| 一本大道久久a久久综合| 日日夜夜一区二区| 国产视频亚洲色图| 欧美在线观看视频一区二区| 免费日韩伦理电影| **性色生活片久久毛片| 欧美乱妇15p| 国产99久久久精品| 亚洲成人三级小说| 中文字幕av一区二区三区免费看 | 久久先锋影音av鲁色资源网| 成人av网址在线| 视频一区欧美日韩| 亚洲国产精品精华液2区45| 欧美日韩一级片网站| 国产麻豆日韩欧美久久| 亚洲午夜免费电影| 欧美精品一区二区三区蜜桃视频| 色综合久久久网| 国产麻豆午夜三级精品| 亚洲一区二区中文在线| 中文字幕第一区二区| 日韩欧美一区电影| 欧美三级在线播放| 成人国产在线观看| 久久av老司机精品网站导航| 亚洲欧美成aⅴ人在线观看| 欧美xxxxxxxxx| 9191国产精品| 在线观看亚洲精品视频| 国产精品一卡二卡在线观看| 亚洲国产另类av| 国产精品福利一区| 日韩精品一区国产麻豆| 日本高清不卡在线观看| 成人小视频在线| 国产一区二区成人久久免费影院| 亚洲午夜免费电影| 亚洲免费av网站| 国产日韩成人精品| 日韩一区二区三区在线视频| 欧美在线视频全部完| 波波电影院一区二区三区| 国产美女在线观看一区| 免费在线观看成人| 美女视频黄 久久| 麻豆精品在线视频| 久久精品99国产国产精| 免费精品视频在线| 蜜桃久久精品一区二区| 美国十次综合导航| 久久av老司机精品网站导航| 免费av网站大全久久| 日韩av电影一区| 热久久久久久久| 精品一区二区三区在线观看 | 欧美日本一区二区三区| 日本韩国一区二区三区视频| 91国产福利在线| 欧美人与禽zozo性伦| 日韩午夜激情视频| 日韩精品中午字幕| 久久久精品中文字幕麻豆发布| 精品粉嫩超白一线天av| 久久精品男人的天堂| 亚洲国产电影在线观看| 亚洲乱码一区二区三区在线观看| 亚洲一线二线三线视频| 视频在线在亚洲| 久久国产尿小便嘘嘘尿| 国产乱淫av一区二区三区| 国产不卡视频在线播放| 色综合色综合色综合色综合色综合| 色老汉av一区二区三区| 欧美精品第1页| 国产亚洲一二三区| 亚洲精品视频在线观看免费| 日韩国产在线观看一区| 国产精品66部| 欧美三级资源在线| www激情久久| 亚洲黄色片在线观看| 久国产精品韩国三级视频| 不卡的av中国片| 欧美日韩成人在线| 国产女人18水真多18精品一级做| 一区二区三区欧美久久| 另类小说一区二区三区| 99久久精品免费精品国产| 欧美一区永久视频免费观看| 久久欧美中文字幕| 亚洲一级二级三级| 国产精品一二二区| 欧美日韩一区二区在线视频| 国产精品美女久久久久久久| 日韩成人免费电影| 91蝌蚪国产九色| www国产成人免费观看视频 深夜成人网| 中文字幕一区二区三区在线播放| 日韩av不卡一区二区| 色婷婷综合久久久中文字幕|