cezanne / usbip-win

USB/IP for Windows
GNU General Public License v3.0
1.94k stars 349 forks source link

I can't connect the webcam #250

Closed myjimmy closed 2 years ago

myjimmy commented 3 years ago

Hi, @cezanne

I can't connect the webcam with this project.

My environment is as follows:

I installed the vhci-ude driver on Windows Server 2019. When connecting the webcam from Windows 10 to Windows Server 2019, I can't see the webcam on Windows Server 2019. Instead, I got the following error:

I compressed the following log files to a zip file and attached it: vm-webcam.zip

Please help. Any suggestion and advice will be helpful.

Regards.

myjimmy commented 3 years ago

I used the real computer instead of the virtual machine (Windows Server 2019). Windows 10 64bit (Version 20H2, OS Build 19042.985) is running on that computer. I installed the vhci-ude driver and repeated the above test case. But I got the same error. I attached the log files. local-webcam.zip

cezanne commented 3 years ago

@myjimmy : Your both vhci logs said in common that remote usbip-win servers did not respond. Could you share a usbip-win stub log?

myjimmy commented 3 years ago

@cezanne Thanks for your reply. Could you let me know how to capture the log of the usbip-win stub driver?

cezanne commented 3 years ago

@myjimmy :

Could you let me know how to capture the log of the usbip-win stub driver?

Same as vhci(wdm).

myjimmy commented 3 years ago

I attached the stub log. webcam-stub-log-usb3.1.zip

myjimmy commented 3 years ago

@cezanne And could you let me know how to capture a specific USB device with USBPcap? Please refer to this link.

cezanne commented 3 years ago

@cezanne And could you let me know how to capture a specific USB device with USBPcap? Please refer to this link.

I had no idea that USBPcap could capture a specific device. In my case, I used to exploit wireshark filter to view specific device logs from all captures.

cezanne commented 3 years ago

@myjimmy :

I attached the stub log. webcam-stub-log-usb3.1.zip

Thanks for log. But the stub log does not help. It just says that several USB interrupt transfers were cancelled by the vhci. What's your device? My webcam(Logitech webcam c170, USB2.0) is working good with vhci(ude) and stub.

myjimmy commented 3 years ago

My webcam is as follows:

My webcam isn't a famous brand. It seems that it's a product made in China.

cezanne commented 3 years ago

@myjimmy : I had compared your vhci log with mine. Your log has several warnings and repetitive unlink packets, which don't appear in mine. I suspect that there was an additional driver installed in your environment. Could you share your driver stack information of a webcam device ? And please retry with the recent v0.3.5.

myjimmy commented 3 years ago

@cezanne Thanks for your reply. How can I get the driver stack information of my webcam device? And I have the same problem with the recent v0.3.5.

cezanne commented 3 years ago

How can I get the driver stack information of my webcam device?

You can browse it in device manager. See below attached image.

And I have the same problem with the recent v0.3.5.

Do you have the same problem with other USB devices?

devicestack

myjimmy commented 3 years ago

The driver stack information of my webcam device is as follows: pc-camera-2 0-driver-stack

When using the Arduino device, I can't see this problem.

cezanne commented 3 years ago

@myjimmy : Can you see the same device stack for the USB composite device(not camera device) which is virtually created by usbip-win? Please refer my screen. screenshot

WuXian2021 commented 3 years ago

I met the same error with the above. Besides, I can't find the GUID string in Registry. could you possibly check this issue? image Thank you.

WuXian2021 commented 3 years ago

I got a some errors as following: 00001501 355.73892212 usbip_stub: control_transfer: seq:175, csp:in,BMREQUEST_CLASS,BMREQUEST_TO_INTERFACE,Unknown request code: 86,wIndex:512,wLength:1,wValue:1792

that's why I updated some codes such as. image Then I can take the camera in Device manager, but I can't get the camera list on Chrome or Zoom. image I attached the stub side's log.

dbgview.log

could you possibly check this issue? Thank you in advance.

cezanne commented 3 years ago

@WuXian2021 : Do you mean that your device was detected after your patch had been applied to a stub ? If so, what's the code for validate_cspkt_request?

WuXian2021 commented 3 years ago

Yeah. right. My code is working to avoid the out action to the device when the stub got an unknown class request.

WuXian2021 commented 3 years ago

I captured the URB and got messages such as: 2021-07-28_00h49_55 Thank you.

WuXian2021 commented 3 years ago

And stub side's capture log and device stack are like as:

image image

There are no errors on the stub side, it seems. As you can see from the above screens, the stub side driver is located on the USB root hub, but the vhci_udi driver is located on the USB 3.0 root hub.

image

Could you possibly check the issue? Thank you.

cezanne commented 3 years ago

@WuXian2021 : Please share your code for validate_cspkt_request(). And can you test with a linux usbip server? It can help to understand that a usbip-win stub server is a problem or not.

WuXian2021 commented 3 years ago

Both BMREQUEST_CLASS and BMREQUEST_VENDOR are processed by using process_class_vendor_request. In my case reqType is: BMREQUEST_CLASS reqCode is: 0x86h

I don't know this command is what, and the device is entered the un-succeeded status after run this command, so I added this code to avoid the device panic. After using this code, the device is added to the device manager list, but can't see on the camera list.

And ths usbip-vstus is supporting the camera device? https://github.com/cezanne/usbip-vstub

static void
process_control_transfer(usbip_stub_dev_t *devstub, struct usbip_header *hdr)
{
    usb_cspkt_t *csp;
    UCHAR       reqType;

    csp = (usb_cspkt_t *)hdr->u.cmd_submit.setup;

    DBGI(DBG_READWRITE, "control_transfer: seq:%u, csp:%s\n", hdr->base.seqnum, dbg_ctlsetup_packet(csp));

    reqType = CSPKT_REQUEST_TYPE(csp);

    if (BMREQUEST_CLASS == reqType && validate_cspkt_request(CSPKT_REQUEST(csp)) != 0)
    {
        DBGI(DBG_READWRITE, "validate_cspkt_request: seq:%u, csp:%s\n", hdr->base.seqnum, dbg_ctlsetup_packet(csp));
        return;
    }

    switch (reqType) {
    case BMREQUEST_STANDARD:
        process_standard_request(devstub, hdr->base.seqnum, csp);
        break;
    case BMREQUEST_CLASS:
        process_class_vendor_request(devstub, csp, hdr, FALSE);
        break;
    case BMREQUEST_VENDOR:
        process_class_vendor_request(devstub, csp, hdr, TRUE);
        break;
    default:
        DBGE(DBG_READWRITE, "invalid request type:", dbg_cspkt_reqtype(reqType));
        break;
    }
}
int
validate_cspkt_request(UCHAR req)
{
    return dbg_namecode_validate(namecodes_cspkt_request, req);
}

int
dbg_namecode_validate(namecode_t* namecodes, unsigned int code)
{
    int retVal = -1;

    /* assume: duplicated codes may exist */
    for (int i = 0; namecodes[i].name; i++) {
        if (code == namecodes[i].code) {
            retVal = 0;
            break;
        }
    }

    return retVal;
}

static namecode_t   namecodes_cspkt_request[] = {
    K_V(USB_REQUEST_GET_STATUS)
    K_V(USB_REQUEST_CLEAR_FEATURE)
    K_V(USB_REQUEST_SET_FEATURE)
    K_V(USB_REQUEST_SET_ADDRESS)
    K_V(USB_REQUEST_GET_DESCRIPTOR)
    K_V(USB_REQUEST_SET_DESCRIPTOR)
    K_V(USB_REQUEST_GET_CONFIGURATION)
    K_V(USB_REQUEST_SET_CONFIGURATION)
    K_V(USB_REQUEST_GET_INTERFACE)
    K_V(USB_REQUEST_SET_INTERFACE)
    K_V(USB_REQUEST_SYNC_FRAME)
    {0,0}
};

Thank you.

cezanne commented 3 years ago

@WuXian2021 :

And ths usbip-vstus is supporting the camera device? https://github.com/cezanne/usbip-vstub

I had tried but postponed.

cezanne commented 3 years ago

@WuXian2021 : Your patch would prevent a stub from replying usbip command. Maybe your issue is related to the problem of stub STALL. Please refer 397b75dcd2a732167972a17565d439d35ab10e2d.

WuXian2021 commented 3 years ago

yeah. I removed the patch because the request is from the PDO. finally, I got this message when I try to open the camera in VLC.exe and chrome.exe. image Thank you.

WuXian2021 commented 3 years ago

How are you! I met a new error, I attached the message screenshot. The pipe is aborted before the starting of the isotransfer, it seems. Could you possibly check the message?

this is the screenshot of the client-side. image

this is the screenshot of the stub-side. image

Thank you.

cezanne commented 3 years ago

@WuXian2021 : Thanks.

Your error case is directly related to stub STALL handling problem as described in the upper comment. I'll try to make a new stub to resolve your issue.

cezanne commented 3 years ago

@WuXian2021 : Could you test with the stub driver(binary) which handles stall while getting status ? This is a patch from 3af795da20bc1e5b80d16bdc650de4893fde29fa.

WuXian2021 commented 3 years ago

Thank you for your supports. Unfortunately, I got to fail and attached the message. Both sides(stub and client) USB are configured to USB 2.0. image

Thank you.

cezanne commented 2 years ago

@WuXian2021 : Sorry for too late response. Is your capture about stub or client?

cezanne commented 2 years ago

@WuXian2021 @myjimmy : Close this issue. Please reopen if you need.