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

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

?? udprotcl.c

?? 工業(yè)組態(tài)軟件modbus驅動源代碼, 包括幫助文件.共享.
?? C
?? 第 1 頁 / 共 5 頁
字號:
        valid = GetMsgAsBinary ((LPSTR) &lpPort->mbRspBuffer[0], &len);
        lpPort->mbRspIndex = len;
    \*******************************************************************/

/* check whether received message was valid */
	// 3/4/2000 modify by Chen jun
	int len;
	WORD cks;
	BYTE cks1,cks2;

	len = lpPort->mbRspIndex;
    cks = CRC16((BYTE*)lpPort->mbRspBuffer,len-2);
	cks1 = (BYTE)(cks%256);
	cks2 = (BYTE)(cks/256);
	// 3/5/2000 modify by Chen jun	
	if (lpPort->mbRspBuffer[1] & 0x80) {
		UdprotHandleRspError(lpPort);
		debug ("Error message received.");
		lpPort->mbState = PROT_WAITQUIET;
	}
	else {
		
		if  (lpPort->mbRspBuffer[len-2] != cks1 ||lpPort->mbRspBuffer[len-1] != cks2){
			UdprotHandleRspError(lpPort);
			debug ("Error message received.");
			lpPort->mbState = PROT_WAITQUIET;
		}
		else
			ProcessValidResponse(lpPort);
	}

    /* check the port for errors and log them */
    checkEvents(lpPort);
    /* set up new poll of current station */
    UdprotPoll(lpPort);
} /* UdprotProcessResponse */

/***********************************************************************/
/** Read port and check for complete message.
    Check the communications port for a completed message ending in a return
    character, too many characters received, or a timeout while waiting for
    completion.
    Called from DoProtocol( )
    returns TRUE if complete message has been received.   **/

BOOL
WINAPI
UdprotGetResponse(LPPORT   lpPort)
{
    int     iWCRet;
    int     total_len;
    LPSTAT  lpTopic;
    LPSTR   topic_name;

    /*******************************************************************\
       For variable length messages, you should normally wait for the
       number of bytes required to insure that the length field of the
       message has been received.  Then calculate the total length of
       the message.
       When the entire message has been received, this function should
       return TRUE.
       In ALL other cases, it should return FALSE.
    \*******************************************************************/

    /* attempt to read message from port, check result */
    if (PortHasData (lpPort)) {
        /* check for response data */
        iWCRet = ReadPortMsg (lpPort);
        if (iWCRet < 0) {
            /* serious error encountered, wait for quiet recovery */
            lpPort->mbState = PROT_WAITQUIET;
            /* indicate message not complete */
            return FALSE;
        }
    } else {
        /* indicate no new response data */
        iWCRet = 0;
    }

    /* check for receive timeout */
    if (lpPort->mbRspIndex < lpPort->mbRspExpLen) {
        /* number of characters less than number expected, check timing */
        if ((lpPort->mbTimer -= tickChange) <= 0) {
            /* timed out, clear timer */
            lpPort->mbTimer = (WORD) GetDeltaTime ();
            if (ShowingErrors) {
                /* get name of topic for timeout message */
                lpTopic = lpPort->mbCurTopic;
                if (lpTopic != (LPSTAT) NULL) {
                    topic_name = lpTopic->statTopicName;
                } else {
                    topic_name = (LPSTR) "<none>";
                }
                /* "Response Timeout (wait=%d, got=%d, topic=\"%Fs\", port=%Fs)" */
                sprintf(dbgBuf, GetString(STRUSER + 105),
                    (int) lpPort->mbRspExpLen, (int) lpPort->mbRspIndex,
                    topic_name, lpPort->mbPortName);
                debug(dbgBuf);
            }
            /* handle response error */
            UdprotHandleRspError(lpPort);
        }
        /* indicate message not complete */
        return FALSE;
    }

    /* not timed out, handle according to protocol state */
    switch (lpPort->mbState) {
    case PROT_WAITHDR:
        /* waiting for header with length, check length of response */
        if (lpPort->mbRspIndex < lpPort->mbRspExpLen) {
            /* expected length not yet received, indicate message not complete */
            return FALSE;
        }
        /*******************************************************************\
            At this point, we have received enough bytes to pick the
            length out of the message header.  Validate the message
            header and calculate the total length of the message.
            Then set the new expected length with the following statement:

            lpPort->mbRspExpLen = total message length;
        \*******************************************************************/
        /* check whether message format is valid so far, get total length */
//        if (IsHeaderValid ((LPSTR) &lpPort->mbRspBuffer[0],
//                           lpPort->mbRspIndex, &total_len)) {
            /* update expected length for total message */
//            lpPort->mbRspExpLen = total_len;
//        } else {
            /** indicate problem with the message header,
                wait for message to end */
//            debug ("Bad header");
//            lpPort->mbTimer = (WORD) GetDeltaTime () + ERRORDELAY;
//            lpPort->mbState = PROT_PROTERRORDELAY;
//            return (FALSE);
//        }
        /* advance to next state, waiting for remainder of message */
        lpPort->mbState = PROT_WAITRESP;
        /* fall through to next case */

    case PROT_WAITRESP:
        /* waiting for complete response, check length of response */
        /***************************************************************\
          Note:  We may have recalculated the response length
                 based on information in the message header.
                 Check to see if the entire message has been received.
        \***************************************************************/
        if (lpPort->mbRspIndex < lpPort->mbRspExpLen) {
            /* expected length not yet received, indicate message not complete */
            return FALSE;
        }
        /* We have received the entire message. */
        if (ShowingReceive)
            /* have logger display received message */
            showReceivedData(lpPort);
        /* indicate complete message received */
        return TRUE;

    default:
        /* this is not a valid state for the protocol, report error */
        lpPort->mbTimer = (WORD) GetDeltaTime () + ERRORDELAY;
        lpPort->mbState = PROT_PROTERRORDELAY;
        checkEvents(lpPort);
        sprintf(dbgBuf, "Illogical Protocol State: %d", lpPort->mbState);
        debug(dbgBuf);
        break;
    }
    /* indicate message not complete */
    return FALSE;
} /* UdprotGetResponse */

/***********************************************************************/
/** advance message timers on indicated port **/

void
WINAPI
UdprotAdvanceMsgTimers(LPPORT    lpPort)
{
    LPSTAT          lpTopic;
    LPUDMSG         lpMsg;
    CHAINSCANNER    station_scanner;
    CHAINSCANNER    message_scanner;

    /* get pointer to first station on port */
    lpTopic = (LPSTAT) FindFirstItem (&lpPort->mbTopicList, SCAN_FROM_HEAD,
                                      NULL, NULL, &station_scanner);

    /* examine each station on the port */
    while (lpTopic != (LPSTAT) NULL) {
        /* check for topic being delayed after errors */
        if (lpTopic->statDelay != 0L) {
            /* decrement delay timer */
            if ((lpTopic->statDelay -= (LONG) tickChange) <= 0L) {
                /* end of delay reached, clear delay count */
                lpTopic->statDelay = 0L;
            }
        } else {
            /* no topic delay, examine every message on the topic */
            lpMsg = (LPUDMSG) FindFirstItem (&lpTopic->statReadMsgList,
                                             SCAN_FROM_HEAD,
                                             NULL, NULL, &message_scanner);
            while (lpMsg != (LPUDMSG) NULL) {
                /* check whether message is active and still waiting */
                if (lpMsg->mmActiveCt && lpMsg->mmScanTimer) {
                    /* decrement scan timer */
                    if ((lpMsg->mmScanTimer -= tickChange) <= 0) {
                        /* end of scan interval reached, reload */
                        lpMsg->mmScanTimer = lpMsg->mmScanReload;
                        /* indicate message is due */
                        lpMsg->mmDue = TRUE;
                    }
                }
                /* advance to next message on this station */
                lpMsg = (LPUDMSG) FindNextItem (&message_scanner);
            }
        }
        /* advance to next station on this port */
        lpTopic = (LPSTAT) FindNextItem (&station_scanner);
    }
} /* UdprotAdvanceMsgTimers */

/***********************************************************************/
/** This function will be called periodically by ProtTimerEvent().
    All continuing protocol activity will be controlled by this function.
    A state-machine is used to control the events of the protocol
    from call to call.  This function is the heartbeat of the protocol.  **/

LPPORT
WINAPI
UdprotDoProtocol(LPPORT lpPort)
{
    /* check pointer to port structure */
    if (lpPort == (LPPORT)NULL) {
        /* nothing to do, just return */
        return (LPPORT) NULL;
    }

    /* advance all message timers on this port */
    UdprotAdvanceMsgTimers(lpPort);

    /* handle port activity according to state */
    switch (lpPort->mbState) {
    case PROT_IDLE:
        /* port is idle, check for something to do */
        UdprotPoll(lpPort);
        break;

    case PROT_WAITHDR:
    case PROT_WAITRESP:
        /* port is waiting for a message to come in, check if complete */
        if (UdprotGetResponse(lpPort)) {
            /* complete message received, process it */
            UdprotProcessResponse(lpPort);
        }
        break;

    case PROT_WAITQUIET:
        /* receive error occurred, wait for receive to stop. */
        if (WaitForQuietPort (lpPort, (LPSTR) "Port has data during wait for quiet:")) {
            /* quiet, handle response error, then continue */
            UdprotHandleRspError(lpPort);
        }
        break;

    case PROT_PROTERRORDELAY:
        /* error delay on port, update delay timer */
        if ((lpPort->mbTimer -= tickChange) <= 0) {
            /* error delay complete, clear delay counter */
            lpPort->mbTimer = (WORD) GetDeltaTime ();
            if (bFlushOnError)
                /* flush port buffers */
                FlushPort (lpPort, (LPSTR) "");
            /* set up new poll of current station */
            UdprotPoll(lpPort);
        }
        break;

    default:
        /* this is not a valid state for the protocol, report error */
        /* "Invalid Protocol State (%d) on %Fs" */
        sprintf(dbgBuf, GetString(STRUSER + 106),
                lpPort->mbState, lpPort->mbPortName);
        lpPort->mbTimer = (WORD) GetDeltaTime () + ERRORDELAY;
        lpPort->mbState = PROT_PROTERRORDELAY;
        debug(dbgBuf);
        break;
    }

    /* return pointer to next port in list */
    return ((LPPORT) lpPort->mbChainLink.next_item.ptr);
} /* UdprotDoProtocol */

/********************************************************************/
/* convert binary value to BCD */

WORD
WINAPI
UdprotCvtBinToBCD ( WORD BinaryValue )
{
   WORD   BcdVal;
   div_t  temp;
   ldiv_t tempL;

   /* get ones digit */
   tempL = ldiv ((long) BinaryValue, 10L);
   BcdVal = (WORD) tempL.rem;

   /* get tens digit */
   temp = div ((int) tempL.quot, 10);
   BcdVal |= ((WORD) temp.rem << 4);

   /* get hundreds digit */
   temp = div (temp.quot, 10);
   BcdVal |= ((WORD) temp.rem << 8);

   /* get thousands digit */
#ifdef ENSURE_BCD
   temp = div (temp.quot, 10);
   BcdVal |= ((WORD) temp.rem << 12);
#else
   BcdVal |= ((WORD) temp.quot << 12);
#endif

   /* return result */
   return BcdVal;
} /*UdprotCvtBinToBCD*/

/********************************************************************/
/* convert BCD value to binary */

WORD
WINAPI
UdprotCvtBCDToBin ( WORD BcdVal

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久久久久久久| 欧美激情一区二区三区全黄| 欧洲亚洲精品在线| 在线欧美日韩国产| 色一情一乱一乱一91av| 在线看国产日韩| 精品视频在线免费看| 欧美日韩高清在线| 欧美一区二区福利视频| 日韩精品一区二区三区在线观看 | 亚洲国产婷婷综合在线精品| 亚洲视频在线观看三级| 一区二区三区欧美日| 亚洲国产日日夜夜| 日本亚洲三级在线| 久久成人精品无人区| 国产成人精品免费| 色哟哟国产精品免费观看| 欧美三级资源在线| 日韩欧美在线123| 久久综合狠狠综合久久综合88 | 国产精品伊人色| 成人高清视频免费观看| 在线亚洲欧美专区二区| 91麻豆精品国产91久久久资源速度| 欧美一区国产二区| 久久精品在线观看| 亚洲免费电影在线| 亚洲一区二区三区美女| 久久精品久久综合| 成人精品视频一区| 欧美浪妇xxxx高跟鞋交| 日韩欧美亚洲国产另类| 国产日本欧美一区二区| 一区二区三区国产豹纹内裤在线 | 欧美丝袜丝交足nylons图片| 日韩欧美一区在线观看| 国产精品国产自产拍高清av| 尤物av一区二区| 日本不卡一区二区三区| 成人国产精品视频| 欧美久久久影院| 国产欧美一区二区精品性色 | 欧美怡红院视频| 日韩精品一区二区三区老鸭窝| 国产日本一区二区| 婷婷丁香激情综合| 成人性视频网站| 宅男在线国产精品| 国产精品成人免费| 欧美aaaaaa午夜精品| 99精品在线免费| 欧美videossexotv100| 最新国产の精品合集bt伙计| 久久精品国产色蜜蜜麻豆| 成人精品亚洲人成在线| 欧美一区二区三区视频免费 | 亚洲女人小视频在线观看| 日日嗨av一区二区三区四区| 国产成人h网站| 欧美日韩一区二区三区视频| 日本一区二区视频在线| 亚洲一区二区三区四区不卡| 国产91精品露脸国语对白| 欧美日韩一区不卡| 国产精品久久久久久久久免费桃花 | 亚瑟在线精品视频| 国产91精品在线观看| 在线成人av影院| 亚洲欧美日韩在线| 国产剧情一区在线| 制服.丝袜.亚洲.中文.综合| 亚洲少妇最新在线视频| 国产乱人伦偷精品视频不卡| 欧美一区欧美二区| 亚洲电影你懂得| 97精品国产露脸对白| 国产亚洲欧美在线| 久久99精品久久久久久| 欧美偷拍一区二区| 亚洲精品免费在线观看| 成年人国产精品| 亚洲欧洲色图综合| 成人午夜av影视| 欧美激情一区二区三区全黄| 国模冰冰炮一区二区| 制服丝袜亚洲播放| 五月婷婷欧美视频| 精品1区2区3区| 亚洲一区二区三区不卡国产欧美| 99re成人精品视频| 亚洲国产成人一区二区三区| 国产一区免费电影| 精品国产髙清在线看国产毛片| 三级一区在线视频先锋| 欧美日韩国产综合视频在线观看| 一区二区三区四区精品在线视频| 97精品电影院| 亚洲欧美日韩国产成人精品影院| av不卡在线播放| 国产精品久久久久一区二区三区| 国产91精品一区二区麻豆网站| 国产欧美一区二区三区在线看蜜臀 | 一区二区三区丝袜| 欧美最新大片在线看| 亚洲国产视频直播| 欧美日韩免费电影| 青椒成人免费视频| 精品日韩在线一区| 国产成人精品影院| 国产精品不卡视频| 色久优优欧美色久优优| 亚洲一区二区成人在线观看| 欧美理论电影在线| 麻豆成人久久精品二区三区小说| 欧美mv日韩mv| 国产一区二区91| 国产精品欧美精品| 色av成人天堂桃色av| 日韩专区中文字幕一区二区| 日韩欧美视频一区| 国产宾馆实践打屁股91| 中文字幕中文乱码欧美一区二区| 91视频.com| 亚洲国产视频a| 精品久久99ma| 成人激情免费视频| 一区二区理论电影在线观看| 7777精品伊人久久久大香线蕉的 | 成人性视频网站| 亚洲男人都懂的| 91精品啪在线观看国产60岁| 国产一区二区三区av电影| 国产精品不卡一区| 欧美挠脚心视频网站| 国产毛片精品一区| 亚洲精品日韩一| 日韩欧美在线观看一区二区三区| 国产激情偷乱视频一区二区三区| 一区二区三区日韩欧美| 日韩精品一区二区三区在线观看 | 国产色婷婷亚洲99精品小说| 99re成人精品视频| 日本三级亚洲精品| 国产精品三级av在线播放| 91精彩视频在线| 韩国午夜理伦三级不卡影院| 一区二区三区在线免费| 精品国产三级a在线观看| 91理论电影在线观看| 免费看欧美美女黄的网站| 中文字幕一区二区三区精华液| 欧美日韩二区三区| 不卡av在线网| 日本vs亚洲vs韩国一区三区二区| 国产精品高潮久久久久无| 欧美一级电影网站| 99九九99九九九视频精品| 另类综合日韩欧美亚洲| 亚洲精品视频免费观看| 久久亚洲捆绑美女| 欧美日韩一区二区在线观看视频| 国产精品99久久久久久久vr| 午夜精品福利久久久| 中文字幕亚洲电影| 久久久影院官网| 在线播放国产精品二区一二区四区 | 成人av在线播放网址| 日本中文在线一区| 亚洲日本免费电影| 国产丝袜在线精品| 日韩一级高清毛片| 欧美日免费三级在线| 成人激情视频网站| 激情文学综合丁香| 婷婷久久综合九色国产成人| 亚洲日本电影在线| 国产色91在线| 日韩欧美综合在线| 欧美久久久影院| 91国内精品野花午夜精品| jiyouzz国产精品久久| 国产乱码字幕精品高清av| 日本aⅴ免费视频一区二区三区 | 日本午夜一本久久久综合| 一区二区三区国产精品| 最新热久久免费视频| 国产亚洲一区二区三区在线观看 | 一区二区三区加勒比av| 国产精品成人免费在线| 国产欧美一区二区三区在线看蜜臀 | 色天天综合久久久久综合片| 成人午夜电影小说| 国产成人在线色| 国产尤物一区二区| 国产一区二区三区四区在线观看| 久久精品国产亚洲一区二区三区| 日韩电影在线看| 肉色丝袜一区二区| 日本伊人午夜精品|