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

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

?? ezusb_diag.c

?? WinDriver Cypress USB 偵錯程式 for Wince 5.0
?? C
字號:
/******************************************************************
 *
 * This is a diagnostics application for accessing the USB device.
 * The code accesses the hardware via WinDriver functions.
 *
 * Copyright (c) 2003 - 2006 Jungo Ltd.  http://www.jungo.com
 *
 ******************************************************************/

#include <stdlib.h>
#include <stdio.h>

#include "wdu_lib.h"
#include "status_strings.h"
#include "utils.h"
#include "ezusb_lib.h"  // +1, 2007/03/08 alan
#include "samples/shared/usb_diag_lib.h"

#if defined(USB_DIAG_SAMPLE)

/* TODO: change the following definitions to match your device. */
#define DEFAULT_VENDOR_ID 0x1234
#define DEFAULT_PRODUCT_ID 0x5678
#define DEFAULT_LICENSE_STRING "12345abcde1234.license"

#else

/* use in wizard's device-specific generated code */
#define DEFAULT_VENDOR_ID         0x13FA
#define DEFAULT_PRODUCT_ID        0x5276
#define DEFAULT_LICENSE_STRING    ""

#endif

#define USE_DEFAULT 0xffff
#define ATTACH_EVENT_TIMEOUT 30 /* in seconds */
#define TRANSFER_TIMEOUT 30000 /* in msecs */
#if !defined(TRACE)
#define TRACE printf
#endif
#if !defined(ERR)
#define ERR printf
#endif

typedef struct DEVICE_CONTEXT
{
    struct DEVICE_CONTEXT *pNext;
    WDU_DEVICE_HANDLE hDevice;
    DWORD dwVendorId;
    DWORD dwProductId;
    DWORD dwInterfaceNum;
    DWORD dwAlternateSetting;
} DEVICE_CONTEXT;

typedef struct DRIVER_CONTEXT
{
    HANDLE hEvent;
    HANDLE hMutex;
    DWORD dwDeviceCount;
    DEVICE_CONTEXT *deviceContextList;
    DEVICE_CONTEXT *pActiveDev;
    HANDLE hDeviceUnusedEvent;
} DRIVER_CONTEXT;

static char line[250];
static WDU_DRIVER_HANDLE hDriver = 0;

static BOOL DLLCALLCONV DeviceAttach(WDU_DEVICE_HANDLE hDevice,
    WDU_DEVICE *pDeviceInfo, PVOID pUserData)
{
    DRIVER_CONTEXT *pDrvCtx = (DRIVER_CONTEXT *)pUserData;
    DEVICE_CONTEXT *pDevCtx, **ppDevCtx;
    DWORD dwInterfaceNum = pDeviceInfo->pActiveInterface[0]->pActiveAltSetting->Descriptor.bInterfaceNumber;
    DWORD dwAlternateSetting = pDeviceInfo->pActiveInterface[0]->pActiveAltSetting->Descriptor.bAlternateSetting;

    /*
    // NOTE: To change the alternate setting, call WDU_SetInterface() here
    DWORD dwAttachError;

    // TODO: replace with the requested number:
    dwAlternateSetting = %alternate_setting_number%;

    dwAttachError = WDU_SetInterface(hDevice, dwInterfaceNum,
        dwAlternateSetting);
    if (dwAttachError)
    {
        ERR("DeviceAttach: WDU_SetInterface failed (num. %ld, alternate %ld) "
            "device 0x%p: error 0x%lx (\"%s\")\n",
            dwInterfaceNum, dwAlternateSetting, hDevice,
            dwAttachError, Stat2Str(dwAttachError));

        return FALSE;
    }
    */

    TRACE("\nDeviceAttach: received and accepted attach for vendor id 0x%x, "
        "product id 0x%x, interface %ld, device handle 0x%p\n",
        pDeviceInfo->Descriptor.idVendor, pDeviceInfo->Descriptor.idProduct,
        dwInterfaceNum, hDevice);

    /* Add our device to the device list */
    pDevCtx = (DEVICE_CONTEXT *)malloc(sizeof(DEVICE_CONTEXT));
    if (!pDevCtx)
    {
        ERR("DeviceAttach: failed allocating memory\n");
        return FALSE;
    }
    BZERO(*pDevCtx);
    pDevCtx->hDevice = hDevice;
    pDevCtx->dwInterfaceNum = dwInterfaceNum;
    pDevCtx->dwVendorId = pDeviceInfo->Descriptor.idVendor;
    pDevCtx->dwProductId = pDeviceInfo->Descriptor.idProduct;
    pDevCtx->dwAlternateSetting = dwAlternateSetting;

    OsMutexLock(pDrvCtx->hMutex);
    for (ppDevCtx = &pDrvCtx->deviceContextList; *ppDevCtx;
        ppDevCtx = &((*ppDevCtx)->pNext));
    *ppDevCtx = pDevCtx;
    pDrvCtx->dwDeviceCount++;
    OsMutexUnlock(pDrvCtx->hMutex);

    OsEventSignal(pDrvCtx->hEvent);
    /* Accept control over this device */
    return TRUE;
}

static VOID DLLCALLCONV DeviceDetach(WDU_DEVICE_HANDLE hDevice, PVOID pUserData)
{
    DRIVER_CONTEXT *pDrvCtx = (DRIVER_CONTEXT *)pUserData;
    DEVICE_CONTEXT **pCur;
    DEVICE_CONTEXT *pTmpDev;
    BOOL bDetachActiveDev = FALSE;

    TRACE("\nDeviceDetach: received detach for device handle 0x%p\n", hDevice);

    OsMutexLock(pDrvCtx->hMutex);
    for (pCur = &pDrvCtx->deviceContextList;
        *pCur && (*pCur)->hDevice != hDevice;
        pCur = &((*pCur)->pNext));

    if (*pCur == pDrvCtx->pActiveDev)
    {
        bDetachActiveDev = TRUE;
        pDrvCtx->pActiveDev = NULL;
    }

    pTmpDev = *pCur;
    *pCur = pTmpDev->pNext;
    free(pTmpDev);

    pDrvCtx->dwDeviceCount--;
    OsMutexUnlock(pDrvCtx->hMutex);

    if (bDetachActiveDev)
    {
        /* When hDeviceUnusedEvent is not signaled, hDevice is possibly in use,
         * and therefore the detach callback needs to wait on it until it is
         * certain that it cannot be used.
         * When it is signaled - hDevice is no longer used. */
        OsEventWait(pDrvCtx->hDeviceUnusedEvent, INFINITE);
    }
}

static void DeviceDiagMenu(DRIVER_CONTEXT *pDrvCtx)
{
    DWORD cmd;
    DWORD dwPipeNum;
    DWORD dwInterfaceNumber, dwAlternateSetting;
    DWORD dwError;
    CHAR sFileName[MAX_PATH];  // +1, 2007/03/08 alan
    PCHAR pcDefaultFile = "";  // +1, 2007/03/08 alan
    WDU_DEVICE_HANDLE hDevice;

    do {
        if (!pDrvCtx->dwDeviceCount)
        {
            printf("\n");
            printf("No Devices are currently connected.\n");
            printf("Press Enter to re check or enter EXIT to exit\n");
            fgets(line, sizeof(line), stdin);
            /* Removing the '\n' character from the end */
            line[strlen(line)-1] = '\0';

            if (!stricmp(line, "EXIT"))
                break;

            continue;
        }

        OsMutexLock(pDrvCtx->hMutex);
        if (!pDrvCtx->dwDeviceCount)
        {
            OsMutexUnlock(pDrvCtx->hMutex);
            continue;
        }

        if (!pDrvCtx->pActiveDev)
            pDrvCtx->pActiveDev = pDrvCtx->deviceContextList;

        printf("\n");
        printf("Main Menu (active Dev/Prod/Interface/Alt. Setting: "
            "0x%lx/0x%lx/%ld/%ld)\n",
            pDrvCtx->pActiveDev->dwVendorId, pDrvCtx->pActiveDev->dwProductId,
            pDrvCtx->pActiveDev->dwInterfaceNum,
            pDrvCtx->pActiveDev->dwAlternateSetting);
        printf("----------\n");
        printf("1. Display device configurations\n");
        printf("2. Change interface alternate setting\n");
        printf("3. Reset Pipe\n");
        printf("4. Read/Write from pipes\n");
        if (pDrvCtx->dwDeviceCount > 1)
            printf("5. Select device\n");
        printf("6. Refresh\n");
        printf("7. Download ufo.hex\n");  // +1, 2007/03/08 alan
        printf("   This firmware renumerates EZ-USB to usb OTDR.\n");  // +1, 2007/03/08 alan
        printf("99. Exit\n");
        printf("Enter option: ");
        cmd = 0;
        OsMutexUnlock(pDrvCtx->hMutex);

        fgets(line, sizeof(line), stdin);
        sscanf(line, "%ld", &cmd);

        if (!pDrvCtx->pActiveDev)
            continue;

        OsEventReset(pDrvCtx->hDeviceUnusedEvent);

        OsMutexLock(pDrvCtx->hMutex);
        hDevice = pDrvCtx->pActiveDev->hDevice;
        OsMutexUnlock(pDrvCtx->hMutex);

        switch (cmd)
        {
        case 1:
            PrintDeviceConfigurations(hDevice);
            break;
        case 2:
            printf("Please enter the interface number (dec): ");
            fgets(line, sizeof(line), stdin);
            sscanf(line, "%ld", &dwInterfaceNumber);
            printf("Please enter the alternate setting index (dec): ");
            fgets(line, sizeof(line), stdin);
            sscanf(line, "%ld", &dwAlternateSetting);
            dwError = WDU_SetInterface(hDevice, dwInterfaceNumber,
                dwAlternateSetting);
            if (dwError)
            {
                ERR("DeviceDiagMenu: WDU_SetInterface() failed: error 0x%lx "
                    "(\"%s\")\n", dwError, Stat2Str(dwError));
            }
            else
            {
                TRACE("DeviceDiagMenu: WDU_SetInterface() completed successfully\n");
                pDrvCtx->pActiveDev->dwInterfaceNum = dwInterfaceNumber;
                pDrvCtx->pActiveDev->dwAlternateSetting = dwAlternateSetting;
            }
            break;
        case 3:
            printf("Please enter the pipe number (hex): 0x");
            fgets(line, sizeof(line), stdin);
            sscanf(line, "%lx", &dwPipeNum);
            printf("\n");

            dwError = WDU_ResetPipe(hDevice, dwPipeNum);
            if (dwError)
            {
                ERR("DeviceDiagMenu: WDU_ResetPipe() failed: error 0x%lx "
                    "(\"%s\")\n", dwError, Stat2Str(dwError));
            }
            else
                TRACE("DeviceDiagMenu: WDU_ResetPipe() completed successfully\n");
            break;
        case 4:
            ReadWritePipesMenu(hDevice);
            break;
        case 5:
            OsMutexLock(pDrvCtx->hMutex);
            if (pDrvCtx->dwDeviceCount > 1)
            {
                DWORD dwDeviceNum, i;
                DEVICE_CONTEXT *pCur;

                for (i=1, pCur=pDrvCtx->deviceContextList; pCur;
                    pCur=pCur->pNext, i++)
                {
                    printf("  %ld. Vendor id: 0x%lx, Product id: 0x%lx, "
                        "Interface number: %ld, Alt. Setting: %ld\n", i,
                        pCur->dwVendorId, pCur->dwProductId,
                        pCur->dwInterfaceNum, pCur->dwAlternateSetting);
                }

                printf("Please enter the device number (1 - %ld, dec): ",
                    i - 1);
                fgets(line, sizeof(line), stdin);
                sscanf(line, "%ld", &dwDeviceNum);

                for (pCur=pDrvCtx->deviceContextList, i=1;
                    pCur && i < dwDeviceNum;
                    pCur=pCur->pNext, i++);

                pDrvCtx->pActiveDev = pCur;
            }
            OsMutexUnlock(pDrvCtx->hMutex);
            break;
        case 6:
            break;
        // -> +n, 2007/03/08 alan
        case 7:
            pcDefaultFile = "../Storage Card/ufo.hex";
            if (UtilGetFileName(sFileName, sizeof(sFileName), pcDefaultFile) != WD_STATUS_SUCCESS)
            {
                printf("Failed to get firmware file name ...\n");
                break;
            }

            if (DownloadFirmware(hDevice, sFileName, 0))
            {
                printf("\nDownload firmware succeeded.\n");
            }
            else
            {
                printf("%s", sInfoString);
                printf("Download firmware failed.\n");
            }
            break;  // <- +n, 2007/03/08 alan
        }
        /* finished using hDevice */
        OsEventSignal(pDrvCtx->hDeviceUnusedEvent);
    } while (cmd!=99);
}

DWORD DriverInit(WDU_MATCH_TABLE *pMatchTables, DWORD dwNumMatchTables,
    const PCHAR sLicense, DRIVER_CONTEXT *pDrvCtx)
{
    DWORD dwError;
    WDU_EVENT_TABLE eventTable;

    dwError = OsEventCreate(&pDrvCtx->hEvent);
    if (dwError)
    {
        ERR("DriverInit: OsEventCreate() failed on event 0x%p: error 0x%lx "
            "(\"%s\")\n", pDrvCtx->hEvent, dwError, Stat2Str(dwError));
        return dwError;
    }

    dwError = OsMutexCreate(&pDrvCtx->hMutex);
    if (dwError)
    {
        ERR("DriverInit: OsMutexCreate() failed on mutex 0x%p: error 0x%lx "
            "(\"%s\")\n", pDrvCtx->hMutex, dwError, Stat2Str(dwError));
        return dwError;
    }

    dwError = OsEventCreate(&pDrvCtx->hDeviceUnusedEvent);
    if (dwError)
    {
        ERR("DriverInit: OsEventCreate() failed on event 0x%p: error 0x%lx "
            "(\"%s\")\n", pDrvCtx->hDeviceUnusedEvent, dwError,
            Stat2Str(dwError));
        return dwError;
    }

    OsEventSignal(pDrvCtx->hDeviceUnusedEvent);
    BZERO(eventTable);
    eventTable.pfDeviceAttach = DeviceAttach;
    eventTable.pfDeviceDetach = DeviceDetach;
    eventTable.pUserData = pDrvCtx;

    dwError = WDU_Init(&hDriver, pMatchTables, dwNumMatchTables, &eventTable,
        sLicense, WD_ACKNOWLEDGE);
    if (dwError)
    {
        ERR("DriverInit: failed to initialize USB driver: error 0x%lx "
            "(\"%s\")\n", dwError, Stat2Str(dwError));
        return dwError;
    }

    return WD_STATUS_SUCCESS;
}

VOID DriverUninit(DRIVER_CONTEXT *pDrvCtx)
{
    DEVICE_CONTEXT *pCur, *pTmpDev;

    if (pDrvCtx->hEvent)
        OsEventClose(pDrvCtx->hEvent);
    if (pDrvCtx->hMutex)
        OsMutexClose(pDrvCtx->hMutex);
    if (pDrvCtx->hDeviceUnusedEvent)
        OsEventClose(pDrvCtx->hDeviceUnusedEvent);
    if (hDriver)
        WDU_Uninit(hDriver);

    /* Release any remaining devices */
    pCur = pDrvCtx->deviceContextList;
    while (pCur)
    {
        pTmpDev = pCur;
        pCur = pCur->pNext;
        free(pTmpDev);
    }
}

int main()
{
    DWORD dwError;
    WORD wVendorId = 0;
    WORD wProductId = 0;
    DRIVER_CONTEXT DrvCtx;
    WDU_MATCH_TABLE matchTable;

    BZERO(DrvCtx);

    wVendorId = USE_DEFAULT;
    wProductId = USE_DEFAULT;

#if defined(USB_DIAG_SAMPLE)
    printf("Enter device vendor id (hex) (=0x%x):\n", DEFAULT_VENDOR_ID);
    fgets(line, sizeof(line), stdin);
    sscanf(line, "%hx", &wVendorId);

    printf("Enter device product id (hex) (=0x%x):\n", DEFAULT_PRODUCT_ID);
    fgets(line, sizeof(line), stdin);
    sscanf(line, "%hx", &wProductId);
#endif

    /* use defaults */
    if (wVendorId == USE_DEFAULT)
        wVendorId = DEFAULT_VENDOR_ID;
    if (wProductId == USE_DEFAULT)
        wProductId = DEFAULT_PRODUCT_ID;
    BZERO(matchTable);
    matchTable.wVendorId = wVendorId;
    matchTable.wProductId = wProductId;

    dwError = DriverInit(&matchTable, 1, DEFAULT_LICENSE_STRING, &DrvCtx);
    if (dwError)
        goto Exit;

    printf("Please make sure the device is attached:\n");

    /* Wait for the device to be attached */
    dwError = OsEventWait(DrvCtx.hEvent, ATTACH_EVENT_TIMEOUT);
    if (dwError)
    {
        if (dwError==WD_TIME_OUT_EXPIRED)
        {
            ERR("Timeout expired for connection with the device.\n"
                "Check that the device is connected and try again.\n");
        }
        else
        {
            ERR("main: OsEventWait() failed on event 0x%p: error 0x%lx "
                "(\"%s\")\n", DrvCtx.hEvent, dwError, Stat2Str(dwError));
        }
        goto Exit;
    }

    DeviceDiagMenu(&DrvCtx);
Exit:
    DriverUninit(&DrvCtx);
    return dwError;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区999| 午夜电影网一区| 日韩亚洲欧美高清| 欧美精品一级二级| 欧美男男青年gay1069videost | 宅男噜噜噜66一区二区66| gogogo免费视频观看亚洲一| 国产精品亚洲а∨天堂免在线| 精品一区二区国语对白| 精品亚洲国产成人av制服丝袜 | 亚洲一区二区三区自拍| 一区二区在线看| 午夜日韩在线观看| 美女视频黄免费的久久| 久久精品国产99国产| 久久av老司机精品网站导航| 国产剧情一区在线| 91在线精品一区二区| 欧美日韩1区2区| 2024国产精品| 国产精品视频一区二区三区不卡| 成人免费小视频| 日韩精品一二三四| 国产美女一区二区| 91同城在线观看| 欧美精品一二三| 国产精品无人区| 天天操天天色综合| 国产宾馆实践打屁股91| 欧洲视频一区二区| 精品久久久三级丝袜| 亚洲欧美色图小说| 美腿丝袜一区二区三区| 99re热视频这里只精品| 51精品秘密在线观看| 国产精品全国免费观看高清| 三级精品在线观看| 成人精品视频一区二区三区| 欧美日韩国产经典色站一区二区三区| 久久综合色婷婷| 亚洲va在线va天堂| 99这里只有精品| 日韩午夜精品视频| 一区二区三区免费| 成人福利电影精品一区二区在线观看 | 91麻豆精品国产自产在线观看一区 | 极品尤物av久久免费看| 色偷偷久久一区二区三区| 日韩欧美国产三级| 亚洲激情五月婷婷| 国产白丝精品91爽爽久久| 欧美一卡二卡三卡| 一区二区三区波多野结衣在线观看 | 日韩欧美一二三四区| 亚洲黄色小视频| 不卡一区二区三区四区| 久久这里都是精品| 欧美aaa在线| 欧美日韩国产系列| 日韩美女啊v在线免费观看| 国产综合成人久久大片91| 欧美精品久久久久久久多人混战 | 精品国产91洋老外米糕| 婷婷国产在线综合| 欧美日韩国产片| 亚洲一区二区三区中文字幕在线| 99久久精品费精品国产一区二区| 久久久久久一二三区| 国产麻豆精品在线观看| 26uuu国产在线精品一区二区| 免费在线看成人av| 91精品蜜臀在线一区尤物| 亚洲高清免费观看高清完整版在线观看| www.视频一区| 欧美成人精品福利| 美女视频一区二区三区| 日韩精品专区在线影院观看| 日韩一区欧美二区| 精品国产免费一区二区三区四区 | 国产日韩欧美a| 国产电影一区在线| 国产精品色在线观看| 成人免费高清视频| 亚洲日本va午夜在线电影| 成人av在线电影| 夜夜精品视频一区二区| 欧美私模裸体表演在线观看| 亚洲成人免费视| 日韩一区二区在线观看视频| 免费看日韩a级影片| 精品国产sm最大网站免费看| 国产成人精品www牛牛影视| 国产精品萝li| 欧美在线观看你懂的| 日韩精品视频网| www激情久久| 91成人免费在线| 日本亚洲视频在线| 国产肉丝袜一区二区| 一本久道中文字幕精品亚洲嫩| 亚洲成人免费在线观看| 精品国内片67194| 99国产精品99久久久久久| 亚洲国产成人av网| 久久午夜电影网| 一本久久精品一区二区| 六月婷婷色综合| 亚洲人成亚洲人成在线观看图片| 欧美日韩一区二区三区视频| 黄色资源网久久资源365| 国产精品超碰97尤物18| 777奇米四色成人影色区| 懂色av一区二区在线播放| 午夜精品久久久久久久久久| 久久日韩粉嫩一区二区三区| 在线亚洲+欧美+日本专区| 久久99精品久久久久久久久久久久| 国产精品视频看| 日韩一区二区免费视频| 91视频国产资源| 国产原创一区二区三区| 亚洲国产一区二区在线播放| 欧美国产精品中文字幕| 这里只有精品视频在线观看| 99久久精品国产一区| 黄网站免费久久| 日韩av成人高清| 亚洲一区二区三区美女| 亚洲国产激情av| 精品国产伦一区二区三区免费| 欧美视频自拍偷拍| 色香色香欲天天天影视综合网| 国产在线播精品第三| 开心九九激情九九欧美日韩精美视频电影 | 欧美日韩精品一区视频| 波多野结衣精品在线| 国产毛片精品一区| 精品一区二区三区欧美| 青青国产91久久久久久| 亚洲一区二区三区四区的| 一区二区三区日韩| 亚洲另类春色国产| 国产女人水真多18毛片18精品视频| 日韩午夜在线观看| 日韩小视频在线观看专区| 欧美一级欧美一级在线播放| 欧美福利电影网| 6080日韩午夜伦伦午夜伦| 7777精品伊人久久久大香线蕉的 | 欧美日韩电影一区| 欧美午夜电影一区| 91豆麻精品91久久久久久| 91视频www| 91国偷自产一区二区三区成为亚洲经典| 风流少妇一区二区| 成人精品鲁一区一区二区| 成人综合婷婷国产精品久久免费| 国产成人亚洲综合a∨婷婷图片| 国产在线精品不卡| 大胆欧美人体老妇| 91在线观看地址| 色婷婷亚洲一区二区三区| 欧美精品国产精品| 日韩欧美综合一区| 国产亚洲一区二区在线观看| 国产精品毛片a∨一区二区三区| 中文一区二区完整视频在线观看| 国产精品国产三级国产专播品爱网 | 久久看人人爽人人| 国产精品午夜在线| 亚洲综合色自拍一区| 三级久久三级久久| 国产精品亚洲人在线观看| 97久久超碰国产精品| 欧美三级韩国三级日本三斤| 91精品国产手机| 欧美韩国日本不卡| 亚洲自拍与偷拍| 国产专区综合网| 99re在线精品| 日韩精品一区二区三区视频在线观看 | 日韩高清不卡一区| 国产一区激情在线| 日本久久一区二区三区| 日韩欧美亚洲另类制服综合在线| 国产欧美日韩在线| 亚洲国产综合人成综合网站| 国产一区二三区| 欧美又粗又大又爽| 久久精品一区二区三区不卡| 亚洲少妇屁股交4| 狠狠色丁香久久婷婷综| 色婷婷综合久久久中文字幕| 欧美xxxxxxxxx| 亚洲免费观看高清完整版在线观看| 蜜桃久久久久久久| 欧美色综合久久| 国产精品国产三级国产| 久久99精品久久久久婷婷| 欧美色图第一页|