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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? utitech.c

?? 工業(yè)組態(tài)軟件modbus驅(qū)動(dòng)源代碼, 包括幫助文件.共享.
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
    len = ReadSimComm(lpPort->mbCid, (LPSTR) lpPort->mbRspBuffer, 1024);
#endif
    if (len < 0) {
        /* error received on COM port, log error message and continue */
        UdprotCheckErrors(lpPort);
    }

    /* indicate whether port is quiet */
    return (len == 0);
} /* WaitForQuietPort */

/***********************************************************************/
/** Write message to indicated port,
    return 1 if successful,
           0 if not successful,
          -1 if serious error **/

int
WINAPI
WritePortMsg (LPPORT lpPort, LPUDMSG lpMsg)
{
    int len;
    int status;

    /* initialize return status */
    status = 1;

    /* write message to serial port, get status */
#ifndef SIMULATING
    len = WriteComm(lpPort->mbCid, (LPSTR) lpMsg->mmData, lpMsg->mmSize);
#else
    len = WriteSimComm(lpPort->mbCid, (LPSTR) lpMsg->mmData, lpMsg->mmSize);
#endif
    if ((len < 0) || (len != lpMsg->mmSize)) {
        /* error occurred on write, identify and display if appropriate */
        if (UdprotCheckErrors(lpPort))
            status = -1;
        else status = 0;
    }
    /* indicate success or failure */
    return (status);
} /* WritePortMsg */

/***********************************************************************/
/** get response from port,
    return 1 if successful,
           0 if not successful,
          -1 if serious error **/

int
WINAPI
ReadPortMsg (LPPORT lpPort)
{
    int len;
    int status;

    /* initialize return status */
    status = 0;

    /* attempt to read data from COM port */
    len = 0;
#ifndef SIMULATING
	len = Utitech_ReadComm(lpPort);
    /*len = ReadComm(lpPort->mbCid,
             (LPSTR) &lpPort->mbRspBuffer[lpPort->mbRspIndex],
             INQSIZE - lpPort->mbRspIndex);*/
#else
    len = ReadSimComm(lpPort->mbCid,
             (LPSTR) &lpPort->mbRspBuffer[lpPort->mbRspIndex],
             INQSIZE - lpPort->mbRspIndex);
#endif
    if (len <= 0) {
        /* if ReadComm() result < 0, it is -count and an error has occurred */
        len = -len;                              /* get actual length count */
        /* check for serious errors, print debug messages showing problem */
        if (UdprotCheckErrors(lpPort)) {
            /* serious error encountered, indicate problem */
            status = -1;
            return (status);
        }
    } else {
        /* indicate data received OK */
        status = 1;
    }

    /* check length of message received, if any */
    if (len > 0) {
        /* update length of message received so far */
        //lpPort->mbRspIndex += len;
    }

    /* indicate whether data was received OK */
    return (status);
} /* ReadPortMsg */

/***********************************************************************/
/** indicate whether port has data in receive buffer **/

BOOL
WINAPI
PortHasData (LPPORT lpPort)
{
    /* always indicate port has data -- at least, potentially */
    return (TRUE);
} /* PortHasData */

/***********************************************************************
 ***********************************************************************
 * PLC SIMULATION ROUTINES                                             *
 ***********************************************************************
 ***********************************************************************/

#ifndef SIMULATING
BOOL WINAPI IsSimulatorEnabled (void)
{
    return (FALSE);
} /* IsSimulatorEnabled */
#else
BOOL WINAPI IsSimulatorEnabled (void)
{
    return (TRUE);
} /* IsSimulatorEnabled */

/** The following routines simulate a simple PLC-type device for testing
    purposes.

    One simulated PLC is implemented for each of COM ports 1..4.

    The simulation has two memory segments:
        NAME  ADDRESS RANGE    DESCRIPTION           FUNCTION
          V      1..512      variable memory    holds value steady
          C      1..512      counter  memory    increments each time read
    Addressing wraps around, so V814 = V((814-1) mod 512)+1 = V302

    Messages are limited to no more than 100 characters, including the
    leading colon, checksum, and trailing semicolon.
    Read messages and write messages can access up to 22 consecutive
    locations (i.e. 44 bytes) within a memory type:
        Write to V  :81AAAANN[CCCC]....[CCCC]XX;
            return value is :81AAAANNXX;
        Write to C  :82AAAANN[CCCC]....[CCCC]XX;
            return value is :82AAAANNXX;
        Read from V :01AAAANNXX;
            return value is :01AAAANN[CCCC]...[CCCC]XX;
        Read from C :02AAAANNXX;
            return value is :02AAAANN[CCCC]...[CCCC]XX;
    where AAAA represents a 4-character hex ASCII address
          NN   represents a 2-character hex ASCII count
          CCCC represents a 4-character hex ASCII value
          XX   represents a 2-character hex ASCII checksum
    Any command which contains invalid hex ASCII characters, an odd number
    of bytes, or an invalid checksum will receive an error response
        :000000000000FF;
    Any command BB besides 01, 02, 81, or 82 will receive an error response
        :00BBAAAANN00XX;
    which echos back the first part of the bad command.
    Any valid command that has a bad address or a bad length (i.e. not
    enough characters, count = 0, or number of write values does not match
    the count) will receive an error response
        :00BBAAAANNDDXX;
    where for a write, DD represents the number of good values received,
    and for a read, DD represents the number of values that will fit.
    Only if the message is valid will the read or write be performed.
**/

/* data storage for simulated PLC */
typedef struct tagSIM_PLC {
         WORD V[512];
         WORD C[512];
        } SIM_PLC;
SIM_PLC sim_plc [4];

/* communications buffers for simulated I/O channels */
typedef struct tagSIM_BUF {
         char read[100+1];
         char write[100+1];
        } SIM_BUF;
SIM_BUF sim_buf [4];

BOOL sim_buf_first = TRUE;
extern BOOL SimulatorWritePaused;
extern BOOL SimulatorReadPaused;

static VOID WINAPI InitializeSimulator (void);

/***********************************************************************/
/* initialize PLC simulator */

static
VOID
WINAPI
InitializeSimulator (void)
{
    int portID;

    sim_buf_first = FALSE;
    for (portID = 0; portID < 4; portID++)
        sim_buf[portID].read[0] = 0;
    debug ("Simulated I/O -- for test purposes only!");
} /* InitializeSimulator */

/***********************************************************************/
/** simulate start-up of communication with COM port **/

BOOL
WINAPI
OpenPort(LPPORT lpPort)
{
    char st [81];

    /* set COM port ID */
    lstrcpy (st, &lpPort->mbPortName[3]);
    lpPort->mbCid = atoi (st) - 1;

    /* check whether valid for simulator */
    if ((lpPort->mbCid < 0) || (3 < lpPort->mbCid)) {
        /* indicate selected COM port cannot be opened */
        lpPort->mbCid = IE_BADID;
        UdprotReportOpenErrorCode(lpPort);
        /* indicate error */
        return (FALSE);
    }

    /* indicate success */
    return (TRUE);
} /* OpenPort */

/***********************************************************************/
/** simulate shut-down of communication with COM port **/

void
WINAPI
ClosePort(LPPORT lpPort)
{
} /* ClosePort */

/***********************************************************************/
/** simulate COM port read from PLC **/

static
int ReadSimComm(int idComDev, void FAR *lpvBuf, int cbRead)
{
    int portID;
    int len;
    LPSTR read_buf;

    /* ensure readbacks are clear the first time */
    if (sim_buf_first) {
        InitializeSimulator ();
    }

    /* indicate nothing read if simulator is paused */
    if (SimulatorReadPaused)
        return (0);

    /* force COM port number to 0..3 */
    portID = idComDev & 0x03;

    /* select appropriate read buffer, get length */
    read_buf = (LPSTR) sim_buf[portID].read;
    len = lstrlen (read_buf);

    /* ensure length is within limits */
    if (len > cbRead)
        len = cbRead;
    if (cbRead > len)
        cbRead = len;

    /* copy read buffer to destination */
    _fstrncpy ((LPSTR) lpvBuf, read_buf, len);

    /* clear read buffer */
    read_buf[0] = '\0';

    /* return length of string */
    return (len);
} /* ReadSimComm */

/***********************************************************************/
/** simulate COM port write to PLC
    prepare read response, return written length **/

static
int WriteSimComm(int idComDev, const void FAR *lpvBuf, int cbWrite)
{
    int portID;
    int len;
    LPSTR write_buf, read_buf, ptr, rsp;
    int cks, cmd;
    WORD addr, count;
    WORD num_val;
    int errflg;
    BOOL bad_cmd;
    SIM_PLC *plc;

    /* ensure readbacks are clear the first time */
    if (sim_buf_first) {
        InitializeSimulator ();
    }

    /* indicate nothing written if simulator is paused */
    if (SimulatorWritePaused)
        return (0);

    /* force COM port number to 0..3 */
    portID = idComDev & 0x03;

    /* select appropriate write, read buffers */
    write_buf = (LPSTR) sim_buf[portID].write;
    read_buf  = (LPSTR) sim_buf[portID].read;

    /* select appropriate simulated PLC memory */
    plc = &sim_plc[portID];

    /* clear response */
    read_buf[0] = 0;

    /* get length of string, ensure within limits */
    if (cbWrite > 100)
        cbWrite = 100;
    len = cbWrite;

    /* copy source to write buffer, append terminating zero */
    _fstrncpy (write_buf, (LPSTR) lpvBuf, len);
    write_buf[len] = 0;

    /* check whether command has valid length, delimiters, checksum */
    if (!IsCommandValid (write_buf, len)) {
        /* bad or corrupt message, return error indicator */
        lstrcpy (read_buf, (LPSTR) ":0000000000FF;");
        /* return length written to simulator */
        return (cbWrite);
    }

    /* initialize pointer, scan length */
    ptr = write_buf+1;
    len -= 4;

    /* initialize flag */
    bad_cmd = FALSE;

    /* get command, update pointer and length, check for error */
    cmd = (int) GetHexVal (ptr, 2, &errflg);
    if ((cmd != 0x01) && (cmd != 0x02) && (cmd != 0x81) && (cmd != 0x82)) {
        /* indicate bad command */
        bad_cmd = TRUE;
    }
    ptr += 2; len -= 2;

    /* get address, update pointer and length, check for error */
    if (len < 4) {
        /* indicate bad command */
        bad_cmd = TRUE;
        /* pad the end with zeros */
        while (len < 4) {
           ptr[len++] = '0';
        }
    }
    addr = (WORD) GetHexVal (ptr, 4, &errflg);
    ptr += 4; len -= 4;

    /* get count, update pointer and length, check for error */
    if (len < 2) {
        /* indicate bad command */
        bad_cmd = TRUE;
        /* pad the end with zeros */
        while (len < 2) {
           ptr[len++] = '0';
        }
    }
    count = (WORD) GetHexVal (ptr, 2, &errflg);
    if (count == 0)
        /* indicate bad command */
        bad_cmd = TRUE;
    ptr += 2; len -= 2;

    /* check whether command is a read or a write */
    num_val = 0;
    if ((cmd == 0x81) || (cmd == 0x82)) {
        /* write, check count vs. number of values */
        if (count * 4 != (WORD) len) {
            /* indicate bad command */
            bad_cmd = TRUE;
            /* determine number of complete values supplied */
            num_val = (WORD) (len / 4);
        }
    }
    if ((cmd == 0x01) || (cmd == 0x02)) {
        /* read, check count vs. available length */
        if (count * 4 > 88) {
            /* indicate bad command */
            bad_cmd = TRUE;
            /* determine max number of values that will fit */
            num_val = 88 / 4;
        }
    }

    /* check whether command is invalid */
    if (bad_cmd) {
        /* construct and return error message */
        rsp = read_buf;
        *(rsp++) = ':';
        rsp = put_hex_byte (rsp, 0x00);
        rsp = put_hex_byte (rsp, (BYTE) cmd);
        rsp = put_hex_word (rsp, addr);
        rsp = put_hex_byte (rsp, (BYTE) count);
        rsp = put_hex_byte (rsp, (BYTE) num_val);
        len = (int) (rsp - read_buf);
        cks = BldCks (read_buf+1, len-1, &errflg);
        rsp = put_hex_byte (rsp, (BYTE) cks);
        *(rsp++) = ';';
        *rsp = 0;
        /* return length written to simulator */
        return (cbWrite);
    }

    /* command is valid, prepare beginnings of response */
    rsp = read_buf;
    *(rsp++) = ':';
    rsp = put_hex_byte (rsp, (BYTE) cmd);
    rsp = put_hex_word (rsp, addr);
    rsp = put_hex_byte (rsp, (BYTE) count);

    /* get (address - 1) mod 512 */
    addr = (WORD) ((addr - 1) & 0x01FF);

    /* determine whether to handle read or write */
    if ((cmd & 0x80) == 0) {
        /* command is a read */
        while (count > 0) {
            /* get appropriate value */
            if (cmd == 0x01) {
                num_val = plc->V[addr];
            } else {
                (plc->C[addr])++;
                num_val = plc->C[addr];
            }
            /* place value in return message */
            rsp = put_hex_word (rsp, num_val);
            /* advance address and decrement count */
            addr = (WORD) ((addr + 1) & 0x01FF);
            count--;
        }
    } else {
        /* command is a write */
        while (count > 0) {
            /* acquire value from write message */
            num_val = (WORD) GetHexVal (ptr, 4, &errflg);
            ptr += 4; len -= 4;
            /* store appropriate value */
            if (cmd == 0x81) {
                plc->V[addr] = num_val;
            } else {
                plc->C[addr] = num_val;
            }
            /* advance address and decrement count */
            addr = (WORD) ((addr + 1) & 0x01FF);
            count--;
        }
    }

    /* command complete, fill in remainder of response */
    len = (int) (rsp - read_buf);
    cks = BldCks (read_buf+1, len-1, &errflg);
    rsp = put_hex_byte (rsp, (BYTE) cks);
    *(rsp++) = ';';
    *rsp = 0;

    /* return length written to simulator */
    return (cbWrite);
} /* WriteSimComm */
#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产九九视频一区二区三区| 中文乱码免费一区二区| 日本欧美久久久久免费播放网| 欧美欧美欧美欧美| 日本不卡的三区四区五区| 日韩欧美亚洲一区二区| 国产美女久久久久| 亚洲欧美影音先锋| 欧美精品自拍偷拍| 精彩视频一区二区| 亚洲色图在线看| 91精品国产一区二区三区蜜臀 | 欧美日韩免费一区二区三区| 蜜臀精品久久久久久蜜臀| 欧美高清在线一区二区| 欧美午夜精品电影| 丁香六月久久综合狠狠色| 一区二区三区资源| 国产喂奶挤奶一区二区三区| 欧美日韩高清一区二区不卡| 国产一区二区电影| 午夜视频在线观看一区| 国产欧美一区二区精品性色超碰| 欧美日韩国产影片| 成人免费视频免费观看| 开心九九激情九九欧美日韩精美视频电影| 欧美激情在线一区二区| 在线成人高清不卡| 色婷婷综合激情| 成人中文字幕在线| 激情国产一区二区 | 中文字幕在线免费不卡| 91精品国产综合久久久久久久 | 国产精品入口麻豆原神| 亚洲精品在线网站| 精品久久久久香蕉网| 欧美日韩国产一二三| 欧美视频在线观看一区| 97精品电影院| eeuss鲁片一区二区三区在线观看| 黄一区二区三区| 韩国精品一区二区| 国产一区二区在线视频| 国内外精品视频| 国产一区视频导航| 国产在线播放一区三区四| 久久99国产精品久久| 国产精品资源网| 粉嫩在线一区二区三区视频| 丁香啪啪综合成人亚洲小说| 欧美一二三区精品| 欧美日韩一区高清| 制服丝袜一区二区三区| 欧美精品一区二区不卡| 国产精品午夜久久| 一个色在线综合| 五月开心婷婷久久| 裸体健美xxxx欧美裸体表演| 国产美女精品在线| av激情亚洲男人天堂| 欧美日韩在线精品一区二区三区激情 | 26uuu色噜噜精品一区二区| 久久九九久久九九| 亚洲精品老司机| 精品一区精品二区高清| 波多野结衣中文字幕一区二区三区| 欧美三级电影精品| 久久综合久久综合久久综合| 亚洲日韩欧美一区二区在线| 午夜视频一区在线观看| 成人永久aaa| 91精选在线观看| 亚洲欧洲精品一区二区三区不卡 | 国产精品资源站在线| 亚洲伊人伊色伊影伊综合网| 亚洲女女做受ⅹxx高潮| 国产一区二区视频在线播放| 欧美视频一区二区三区四区 | 天堂久久一区二区三区| 国产露脸91国语对白| 欧洲一区二区三区在线| 2020国产精品自拍| 一区二区久久久| 国产老妇另类xxxxx| 欧美日韩和欧美的一区二区| 欧美精品自拍偷拍动漫精品| 久久久久久久久久久久久久久99| 日韩国产欧美在线视频| 不卡高清视频专区| 制服丝袜亚洲播放| 亚洲午夜免费视频| 91久久精品一区二区| 中文字幕制服丝袜成人av| 日本不卡视频在线| 欧美男生操女生| 亚洲一区成人在线| 91久久久免费一区二区| 亚洲图片另类小说| 成人在线一区二区三区| 日本一区二区三区在线观看| 国产激情一区二区三区| 欧美一区二区三区在线| 午夜激情一区二区三区| 欧美午夜不卡在线观看免费| 亚洲一区二区三区四区五区中文| 99re热这里只有精品免费视频| 中文无字幕一区二区三区 | 久久婷婷久久一区二区三区| 秋霞影院一区二区| 欧美xxxx在线观看| 国产一区二区精品久久91| 国产拍欧美日韩视频二区| 国产91清纯白嫩初高中在线观看| 久久综合九色综合97_久久久| 国产一区不卡精品| 中文字幕第一页久久| 色狠狠色狠狠综合| 日韩在线观看一区二区| 国产亚洲欧美激情| heyzo一本久久综合| 亚洲成人一二三| 欧美成人aa大片| av在线播放不卡| 日韩国产精品久久| 欧美国产激情二区三区| 91福利国产精品| 国产精品综合一区二区三区| 亚洲视频免费观看| 欧美一区二区三区视频| 成人毛片视频在线观看| 午夜精品视频一区| 久久久久九九视频| 欧美无乱码久久久免费午夜一区| 国产乱码精品一区二区三区忘忧草| 亚洲另类色综合网站| 久久人人97超碰com| 欧美日韩免费电影| av在线不卡观看免费观看| 日韩国产在线观看一区| 中文字幕亚洲一区二区av在线 | 欧美不卡激情三级在线观看| 91免费国产在线| 福利电影一区二区| 久久国产夜色精品鲁鲁99| 日韩在线a电影| 视频在线观看91| 亚洲高清三级视频| 一区二区三区国产豹纹内裤在线| **网站欧美大片在线观看| 国产精品久久久久毛片软件| 国产精品剧情在线亚洲| 国产精品女同一区二区三区| 久久久av毛片精品| 国产精品入口麻豆原神| 国产精品传媒在线| 亚洲另类春色国产| 午夜视频在线观看一区二区三区| 亚洲一区免费在线观看| 亚洲成人免费视频| 秋霞电影一区二区| 国产一区不卡精品| 成人性生交大片免费看中文| zzijzzij亚洲日本少妇熟睡| 日本高清不卡在线观看| 欧美视频在线不卡| 久久中文字幕电影| 亚洲欧美日韩国产综合| 夜夜爽夜夜爽精品视频| 日本视频一区二区三区| 国产麻豆精品视频| 日本韩国一区二区| www日韩大片| 亚洲人妖av一区二区| 免费精品视频在线| 成人av在线电影| 91精品国产综合久久精品| 国产人成亚洲第一网站在线播放| 亚洲欧美电影一区二区| 狠狠色狠狠色合久久伊人| 91色porny在线视频| 欧美电影免费观看完整版| 亚洲免费色视频| 国产成人精品综合在线观看 | 欧美体内she精高潮| 在线成人av影院| 久久久久久99精品| 国产精品久久影院| 午夜精品爽啪视频| 国产精品中文欧美| 在线观看一区二区视频| 欧美成人a在线| 亚洲老司机在线| 奇米精品一区二区三区四区 | 一本久道中文字幕精品亚洲嫩| 欧美视频在线观看一区二区| 精品日韩在线一区| 亚洲人成在线播放网站岛国| 久久精品国产亚洲一区二区三区| 国产精品综合一区二区三区| 91福利在线播放|