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

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

?? usb_diag_lib.c

?? WinDriver Cypress USB 偵錯程式 for Wince 5.0
?? C
字號:
////////////////////////////////////////////////////////////////
// File - USB_DIAG_LIB.C
//
// Utility functions for communication with USB devices 
// using WinDriver's API.
// 
// Copyright (c) 2003 - 2006 Jungo Ltd.  http://www.jungo.com
// 
////////////////////////////////////////////////////////////////

#include "windrvr.h"
#include "wdu_lib.h"
#include "status_strings.h"
#include "utils.h"
#ifdef _USE_SPECIFIC_KERNEL_DRIVER_
    #undef WD_Open
    #define WD_Open WD_OpenKernelHandle
    #if defined(UNIX)
        #undef WD_FUNCTION
        #define WD_FUNCTION(wFuncNum,h,pParam,dwSize,fWait) ((ULONG) ioctl((int)(h), wFuncNum, pParam))
    #endif
#endif
#include "usb_diag_lib.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>

#if !defined(ERR)
#define ERR printf
#endif

#define TRANSFER_TIMEOUT 30000 // in msecs

typedef struct  
{
    HANDLE hDevice;
    WDU_PIPE_INFO *pPipe;
    PVOID pContext;
    BOOL fStopped;
    HANDLE hThread;
    DWORD dwError;
} USB_LISTEN_PIPE;

// Function: CloseListening()
//   Stop listening to USB device pipe
void CloseListening(USB_LISTEN_PIPE *pListenPipe);

// Function: ListenToPipe()
//   Start listening to a USB device pipe
void ListenToPipe(USB_LISTEN_PIPE *pListenPipe);

// Function: pipeType2Str()
//   Returns a string identifying the pipe type
// Parameters:
//   pipeType [in] pipe type
// Return Value:
//   String containing the description of the pipe
char *pipeType2Str(ULONG pipeType)
{
    char *res = "unknown";
    switch (pipeType)
    {
        case PIPE_TYPE_CONTROL: 
            res = "Control";
            break;
        case PIPE_TYPE_ISOCHRONOUS:
            res = "Isochronous";
            break;          
        case PIPE_TYPE_BULK:
            res = "Bulk";
            break;
        case PIPE_TYPE_INTERRUPT:
            res = "Interrupt";
            break;
    }
    return res;
}

// input of command from user
static char line[256];

// Function: CloseListening()
//   Stop listening to USB device pipe
// Parameters:
//   pListenPipe [in] pointer to USB device pipe
// Return Value:
//   None
void CloseListening(USB_LISTEN_PIPE* pListenPipe)
{
    if (!pListenPipe->hThread)
        return;

    printf("Stop listening to pipe\n");
    pListenPipe->fStopped = TRUE;

    WDU_HaltTransfer(pListenPipe->hDevice, pListenPipe->pPipe->dwNumber);

    ThreadWait(pListenPipe->hThread);
    pListenPipe->hThread = NULL;
}

// Function: PipeListenHandler()
//   Callback function, which listens to a pipe continuously when there is data 
//   available in the pipe
// Parameters:
//   pParam [in] contains the relevant pipe information
// Return Value:
//   None
void DLLCALLCONV PipeListenHandler(void * pParam)
{
    DWORD dwError;
    USB_LISTEN_PIPE *pListenPipe = (USB_LISTEN_PIPE*) pParam;
    DWORD dwBufsize = pListenPipe->pPipe->dwMaximumPacketSize;
    PVOID buf;
    DWORD dwOptions = 0;

    if (pListenPipe->pPipe->type == PIPE_TYPE_ISOCHRONOUS) 
    { 
        dwBufsize *= 8; // suit 8 minimum packets for high speed transfers 
        dwOptions |= USB_ISOCH_FULL_PACKETS_ONLY; 
    } 

    buf = malloc(dwBufsize);

    for (;;)
    {
        DWORD dwBytesTransferred;

        dwError = WDU_Transfer(pListenPipe->hDevice, pListenPipe->pPipe->dwNumber,
            TRUE, dwOptions, buf, dwBufsize,
            &dwBytesTransferred, NULL, TRANSFER_TIMEOUT);
        if (pListenPipe->fStopped)
            break;
        if (dwError)
        {
            pListenPipe->dwError = dwError;
            break;
        }
        DIAG_PrintHexBuffer(buf, dwBytesTransferred, TRUE);
    }
    free(buf);
}

// Function: ListenToPipe()
//   Start listening to a USB device pipe
// Parameters:
//   pListenPipe [in] pipe to listen to
// Return Value:
//   None
void ListenToPipe(USB_LISTEN_PIPE *pListenPipe)
{
    // start the running thread
    pListenPipe->fStopped = FALSE;
    printf("Start listening to pipe\n");

    pListenPipe->dwError = ThreadStart(&pListenPipe->hThread, 
        PipeListenHandler, (PVOID) pListenPipe);
}

// Function: PrintPipe()
//   Prints the pipe information (helper function)
// Parameters:
//   pPipe [in] pointer to the pipe information
// Return Value:
//   None
static void PrintPipe(const WDU_PIPE_INFO *pPipe)
{
    printf("  pipe num. 0x%lx: packet size %ld, type %s, dir %s, interval %ld (ms)\n",
        pPipe->dwNumber,
        pPipe->dwMaximumPacketSize,
        pipeType2Str(pPipe->type),
        pPipe->direction==WDU_DIR_IN ? "In" : pPipe->direction==WDU_DIR_OUT ? "Out" : "In & Out",
        pPipe->dwInterval);
}

// Function: PrintPipe0Info()
//   Prints the pipe0 (control pipe) information
void PrintPipe0Info(WDU_DEVICE *pDevice)
{
    printf("Control pipe:\n");
    PrintPipe(&pDevice->Pipe0);
}

// Function: PrintPipesInfo()
//   Prints the pipes information for the specified alternate setting
// Parameters:
//   pAltSet [in] pointer to the alternate setting information
// Return Value:
//   None
void PrintPipesInfo(WDU_ALTERNATE_SETTING *pAltSet)
{
    BYTE p;
    WDU_PIPE_INFO *pPipe;

    if (!pAltSet->Descriptor.bNumEndpoints)
    {
        printf("  no pipes are defined for this device other than the default pipe (number 0).\n");
        return;
    }

    printf("Alternate Setting: %d\n", pAltSet->Descriptor.bAlternateSetting);
    for (p=0, pPipe = pAltSet->pPipes; p<pAltSet->Descriptor.bNumEndpoints; p++, pPipe++)
        PrintPipe(pPipe);
}

// Function: PrintEndpoints()
//   Prints the endpoints (pipes) information for the specified alternate setting
//   (helper function for PrintDeviceConfigurations)
// Parameters:
//   pAltSet [in] pointer to the alternate setting information
// Return Value:
//   None
static void PrintEndpoints(const WDU_ALTERNATE_SETTING *pAltSet)
{
    BYTE endp;
    WDU_ENDPOINT_DESCRIPTOR *pEndp;

    for (endp=0; endp<pAltSet->Descriptor.bNumEndpoints; endp++)
    {
        pEndp = &pAltSet->pEndpointDescriptors[endp];
        printf("    end-point address: 0x%02x, attributes: 0x%x, max packet %d, Interval: %d\n",
            pEndp->bEndpointAddress,
            pEndp->bmAttributes,
            pEndp->wMaxPacketSize,
            pEndp->bInterval);
    }
}

// Function: PrintDeviceConfigurations()
//   Prints the device's configurations information
// Parameters:
//   hDevice [in] handle to the USB device
// Return Value:
//   None
void PrintDeviceConfigurations(HANDLE hDevice)
{
    DWORD dwError;
    WDU_DEVICE *pDevice = NULL;
    DWORD ifc, alt;
    UINT32 iConf;

    WDU_CONFIGURATION *pConf;
    WDU_INTERFACE *pInterface;
    WDU_ALTERNATE_SETTING *pAltSet;

    dwError = WDU_GetDeviceInfo(hDevice, &pDevice);
    if (dwError)
    {
        ERR("PrintDeviceConfigurations: WDU_GetDeviceInfo failed: error 0x%lx (\"%s\")\n",
            dwError, Stat2Str(dwError));
        goto Exit;
    }

    printf("This device has %d configurations:\n", pDevice->Descriptor.bNumConfigurations);
    for (iConf=0; iConf<pDevice->Descriptor.bNumConfigurations; iConf++)
    {
        printf("  %d. configuration value %d (has %ld interfaces)\n", 
            iConf, pDevice->pConfigs[iConf].Descriptor.bConfigurationValue,
            pDevice->pConfigs[iConf].dwNumInterfaces);
    }
    iConf = 0;
    if (pDevice->Descriptor.bNumConfigurations>1)
    {
        printf("Please enter the configuration index to display (dec - zero based): ");
        fgets(line, sizeof(line), stdin);
        sscanf(line, "%d", &iConf);
        if (iConf >= pDevice->Descriptor.bNumConfigurations)
        {
            printf("ERROR: invalid configuration index, valid values are 0-%d\n",
                pDevice->Descriptor.bNumConfigurations);
            goto Exit;
        }
    }
    pConf = &pDevice->pConfigs[iConf];

    printf("The configuration indexed %d has %ld interface(s):\n",
        iConf, pConf->dwNumInterfaces);

    for (ifc=0; ifc<pConf->dwNumInterfaces; ifc++)
    {
        pInterface = &pConf->pInterfaces[ifc];
        printf("interface no. %d has %ld alternate settings:\n", 
            pInterface->pAlternateSettings[0].Descriptor.bInterfaceNumber,
            pInterface->dwNumAltSettings);
        for (alt=0; alt<pInterface->dwNumAltSettings; alt++)
        {
            pAltSet = &pInterface->pAlternateSettings[alt];

            printf("  alternate: %d, endpoints: %d, class: 0x%x, subclass: 0x%x, protocol: 0x%x\n",
                pAltSet->Descriptor.bAlternateSetting,
                pAltSet->Descriptor.bNumEndpoints,
                pAltSet->Descriptor.bInterfaceClass,
                pAltSet->Descriptor.bInterfaceSubClass,
                pAltSet->Descriptor.bInterfaceProtocol);

            PrintEndpoints(pAltSet);
        }
        printf("\n");
    }
    printf("\n");

Exit:
    if (pDevice)
        WDU_PutDeviceInfo(pDevice);
}

// Function: ReadWritePipesMenu()
//   Displays menu to read/write from the device's pipes
// Parameters:
//   hDevice [in] handle to the USB device
// Return Value:
//   None
void ReadWritePipesMenu(HANDLE hDevice)
{
    DWORD dwError;
    WDU_DEVICE *pDevice;
    WDU_ALTERNATE_SETTING *pAltSet;
    WDU_PIPE_INFO *pPipes;
    BYTE  SetupPacket[8];
    DWORD cmd, dwPipeNum, dwSize, dwBytesTransferred;
    BYTE i=0;
    VOID *pBuffer = NULL;
    USB_LISTEN_PIPE listenPipe;
    int c;

    dwError = WDU_GetDeviceInfo(hDevice, &pDevice);
    if (dwError)
    {
        ERR("ReadWritePipesMenu: WDU_GetDeviceInfo() failed: error 0x%lx (\"%s\")\n",
            dwError, Stat2Str(dwError));
        return;
    }

    pAltSet = pDevice->pActiveInterface[0]->pActiveAltSetting;
    pPipes = pAltSet->pPipes;

    PrintPipe0Info(pDevice);
    PrintPipesInfo(pAltSet);

    do {
        printf("\n");
        printf("Read/Write from/to device's pipes\n");
        printf("---------------------\n");
        printf("1.  Read from pipe\n");
        printf("2.  Write to pipe\n");
        printf("3.  Listen to pipe (continuous read)\n");
        printf("99. Main menu\n");
        printf("Enter option: ");
        cmd = 0;
        fgets(line, sizeof(line), stdin);
        sscanf(line, "%ld", &cmd);

        if (cmd==99)
            break;
        if (cmd<1 || cmd>3)
            continue;

        printf("Please enter the pipe number (hex): 0x");
        fgets(line, sizeof(line), stdin);
        dwPipeNum=0;
        sscanf(line, "%lx", &dwPipeNum);

        // search for the pipe
        if (dwPipeNum)
        {
            for (i=0; i<pAltSet->Descriptor.bNumEndpoints; i++)
                if (pPipes[i].dwNumber==dwPipeNum)
                    break;
            if (i >= pAltSet->Descriptor.bNumEndpoints)
            {
                printf("The pipe number 0x%lx does not exist, please try again.\n", dwPipeNum);
                continue;
            }
        }

        switch (cmd)
        {
        case 1:
        case 2:
            if (!dwPipeNum || pPipes[i].type==PIPE_TYPE_CONTROL)
            {
                printf("Please enter setup packet (hex - 8 bytes): ");
                DIAG_GetHexBuffer((PVOID) SetupPacket, 8);
            }
            printf("Please enter the size of the buffer (dec):  ");
            fgets(line, sizeof(line), stdin);
            sscanf(line, "%ld", &dwSize);
            if (dwSize)
            {
                pBuffer = malloc(dwSize);
                if (!pBuffer)
                {
                    ERR("cannot alloc memory\n");
                    break;
                }
                if (cmd==2)
                {
                    printf("Please enter the input buffer (hex): ");
                    DIAG_GetHexBuffer(pBuffer, dwSize);
                }
            }
            dwError = WDU_Transfer(hDevice, dwPipeNum? pPipes[i].dwNumber : 0, cmd==1, 0, pBuffer, 
                dwSize, &dwBytesTransferred, SetupPacket, TRANSFER_TIMEOUT);
            if (dwError)
                ERR("ReadWritePipesMenu: WDU_Transfer() failed: error 0x%lx (\"%s\")\n",
                    dwError, Stat2Str(dwError));
            else
            {
                printf("Transferred %ld bytes\n", dwBytesTransferred);
                if (cmd==1 && pBuffer)
                    DIAG_PrintHexBuffer(pBuffer, dwBytesTransferred, TRUE);
            }
            if (pBuffer)
                free(pBuffer);
            break;

        case 3:
            if (!dwPipeNum || pPipes[i].type==PIPE_TYPE_CONTROL)
            {
                printf("Cannot listen to control pipes.\n");
                break;
            }
            BZERO(listenPipe);
            listenPipe.hDevice = hDevice;
            listenPipe.pPipe = &pPipes[i];

            printf("Press <Enter> to start listening. While listening, press <Enter> to stop\n\n");
            getchar();
            ListenToPipe(&listenPipe);
            if (listenPipe.dwError)
            {
                ERR("ReadWritePipesMenu: error listening to pipe 0x%lx: error 0x%lx (\"%s\")\n",
                    dwPipeNum, listenPipe.dwError, Stat2Str(listenPipe.dwError));
                break;
            }

            while ((c=getchar())!=10) {}   // ESC code
            CloseListening(&listenPipe);
            if (listenPipe.dwError)
                ERR("ReadWritePipesMenu: WDU_Transfer failed: error 0x%lx (\"%s\")\n",
                    listenPipe.dwError, Stat2Str(listenPipe.dwError));
            break;
        }
    } while (1);

    if (pDevice)
        WDU_PutDeviceInfo(pDevice);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品亚洲porn| 2023国产一二三区日本精品2022| 欧美一区二区网站| 中文字幕精品在线不卡| 日韩av不卡在线观看| 99精品久久99久久久久| 久久久777精品电影网影网 | 美洲天堂一区二卡三卡四卡视频| 成人午夜免费电影| 欧美精品一区二区久久婷婷| 亚洲国产精品久久久男人的天堂| 成人福利视频网站| 久久久久久毛片| 精品亚洲porn| 精品欧美久久久| 麻豆成人免费电影| 欧美一级艳片视频免费观看| 亚洲综合网站在线观看| 色美美综合视频| 亚洲欧美偷拍三级| 色香色香欲天天天影视综合网| 国产精品色在线| 丁香另类激情小说| 国产精品色呦呦| 成人免费黄色在线| 欧美激情在线一区二区三区| 国产福利一区在线| 日本一区二区动态图| 国产乱人伦偷精品视频免下载 | 国产精品1区2区| 久久综合一区二区| 国产呦萝稀缺另类资源| 久久午夜老司机| 国产成人精品1024| 中文字幕在线一区| 97超碰欧美中文字幕| 亚洲图片另类小说| 欧美在线小视频| 日韩精品乱码免费| 欧美一级免费观看| 国产真实乱对白精彩久久| 精品福利二区三区| 国产成人在线电影| 国产精品久久久一区麻豆最新章节| 99精品国产99久久久久久白柏| 亚洲理论在线观看| 在线不卡中文字幕| 国产一区二区三区四| 中文久久乱码一区二区| 91久久香蕉国产日韩欧美9色| 亚州成人在线电影| 26uuu国产日韩综合| 不卡一二三区首页| 亚洲电影在线播放| 久久综合狠狠综合久久激情| 成人国产视频在线观看| 亚洲美女在线一区| 日韩精品一区二区三区老鸭窝| 国产成人精品aa毛片| 亚洲一区二区av在线| 日韩午夜中文字幕| 波多野结衣91| 秋霞午夜鲁丝一区二区老狼| 欧美国产综合一区二区| 欧美日韩一区三区| 粉嫩嫩av羞羞动漫久久久| 一区二区三区四区不卡视频 | 欧美欧美欧美欧美| 国产另类ts人妖一区二区| 亚洲欧美日韩中文字幕一区二区三区| 欧美午夜精品久久久| 精品一二三四在线| 一区二区三区四区蜜桃| 国产三级一区二区| 欧美高清视频在线高清观看mv色露露十八 | 久久99精品国产.久久久久久| 国产精品国产三级国产aⅴ中文 | 成人欧美一区二区三区白人 | 7777精品伊人久久久大香线蕉完整版| 久久福利资源站| 一卡二卡欧美日韩| 欧美国产成人在线| 宅男在线国产精品| 91蝌蚪porny成人天涯| 国产一区免费电影| 日韩电影免费在线看| 一区二区三区波多野结衣在线观看| 精品sm捆绑视频| 欧美日韩aaa| 97国产一区二区| 成人app在线| 韩国精品主播一区二区在线观看| 亚洲mv在线观看| 亚洲一区二区av在线| 亚洲日本青草视频在线怡红院| 久久综合九色综合久久久精品综合| 欧美美女喷水视频| 在线日韩国产精品| 91亚洲男人天堂| 成人免费视频播放| 成人一级黄色片| 高清不卡一区二区| 国产激情一区二区三区四区| 国产在线一区观看| 国产一区二区三区久久久| 久久精品国产澳门| 久久99国产精品成人| 免费观看91视频大全| 天堂va蜜桃一区二区三区漫画版| 一区二区三区产品免费精品久久75| 国产精品丝袜一区| 国产精品欧美综合在线| 欧美国产激情二区三区| 国产精品欧美一级免费| 亚洲欧洲成人自拍| 亚洲欧美色综合| 亚洲丰满少妇videoshd| 日韩1区2区日韩1区2区| 日韩 欧美一区二区三区| 日本欧美一区二区三区乱码| 日本不卡123| 激情伊人五月天久久综合| 精品亚洲免费视频| 国产91丝袜在线18| 不卡免费追剧大全电视剧网站| 成人app软件下载大全免费| 色丁香久综合在线久综合在线观看| 91精品福利在线| 91精品国产黑色紧身裤美女| 日韩午夜精品电影| 久久久综合九色合综国产精品| 久久久99久久| 亚洲视频一区二区免费在线观看| 亚洲综合色在线| 久久国产精品99久久人人澡| 国产麻豆视频一区二区| 色噜噜夜夜夜综合网| 7777精品伊人久久久大香线蕉的 | 香蕉影视欧美成人| 久久精品国产99| 91亚洲精品一区二区乱码| 色综合久久综合网欧美综合网| 欧美日韩1区2区| 精品国产乱码久久久久久牛牛| 中文字幕欧美激情| 亚洲高清免费一级二级三级| 老司机精品视频线观看86 | 久久疯狂做爰流白浆xx| 99久久国产综合精品女不卡| 欧美三区在线视频| 日本一区二区三区久久久久久久久不| 亚洲精品国产一区二区精华液| 日本在线观看不卡视频| 国产成人av自拍| 精品视频一区 二区 三区| 久久老女人爱爱| 亚洲一区免费在线观看| 国产91对白在线观看九色| 欧美日韩中字一区| 国产精品人人做人人爽人人添| 亚洲777理论| 成人免费福利片| 欧美mv日韩mv国产| 亚洲国产综合91精品麻豆| 国产一区二区三区在线观看免费| 欧美色老头old∨ideo| 国产视频一区二区在线观看| 日韩中文字幕1| 91久久人澡人人添人人爽欧美| 精品粉嫩超白一线天av| 午夜视频在线观看一区二区三区| 成人激情黄色小说| 精品嫩草影院久久| 日本va欧美va精品| 欧美午夜精品理论片a级按摩| 国产精品免费丝袜| 国产精品18久久久久久久久| 欧美理论在线播放| 亚洲黄色片在线观看| 国产成人精品影院| 精品剧情在线观看| 日韩电影在线免费看| 欧美蜜桃一区二区三区| 亚洲综合成人网| 色婷婷久久久亚洲一区二区三区| 国产精品五月天| 成人福利视频网站| 国产精品无圣光一区二区| 国产传媒日韩欧美成人| 久久久高清一区二区三区| 激情图片小说一区| 日韩欧美国产精品一区| 青青草国产成人av片免费| 欧美一二三区精品| 日本vs亚洲vs韩国一区三区| 欧美一二三在线| 精品一区中文字幕| 26uuu成人网一区二区三区| 国产一区二区主播在线| 久久蜜桃一区二区|