1

I'm developing a consumer USB device that will be configured via a web interface.

The first interface is a HID Gamepad. The second is a vendor interface where configuration will be handled.

Running this WebUSB code, I get the following error:

async () => {
  try {
    let device = await navigator.usb.requestDevice();

    await device.open();
    await device.selectConfiguration(1);
    await device.claimInterface(1);
    await device.controlTransferOut({ // ERROR OCCURS AT THIS LINE!
      requestType: "vendor",
      recipient: "interface",
      request: 0x01,
      value: 0x01,
      index: 0x01,
    });
    const dataToSend = new ArrayBuffer(8);
    dataToSend[0] = 2;
    let result = await device.transferOut(4, dataToSend);

    const decoder = new TextDecoder();
    console.log("Received: " + decoder.decode(result.data));
  } catch (error) {
    console.error(error);
  }

Which outputs DOMException: A transfer error has occurred.

Checking the Chrome device logs, I see this in chrome://device-log/:

[22:21:07] Transfer failed: A device attached to the system is not functioning. (0x1F)

A side note: I'm almost certain this code was working 6 months ago and I recall vaguely that it may have had to do with this next part (specifically the "driver":)

[22:15:57] USB device added: path=\\?\usb#vid_0f0d&pid_00cc#a&33dbaa40&1&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed} vendor=3853 "keyboard.gg", product=204 "Edgeguard", serial="", driver="usbccgp", guid=c240342b-ed28-41aa-a8c9-bc505467059e

Chrome Device Log

First red flag to me is that the device is using driver="usbccgp" - I was expecting to see WinUsb. Using a tool called Zadig, I can see that the first interface is not WCID, but the second is (please note: I did not manually change either of these, this is what they are detected as by Windows.)

Zadig showing a non-WCID first interface Zadig showing a non-WCID second interface

My memory is fuzzy, but I think that this transfer may be failing because Chrome is adding the device with a usbccgp driver. Any advice would be appreciated.

NessDan
  • 1,137
  • 1
  • 16
  • 34
  • I apologize, I realize the device itself was not sending anything back to the host after it attempted a `controlTransferOut`. Fixing that led to me reaching the `device.transferOut` line , where it fails with `webusb-config-transfer.js:29 DOMException: A transfer error has occurred.` Will update soon. Also after updating the firmware while Chrome was open, it now outputs `[23:37:42] USB device function updated: guid=86de0209-e434-4052-a1d1-b1fbfc779e89, interface_number=1, path="\\?\usb#vid_0f0d&pid_00cc&mi_01#b&2446dd5d&0&0001#{dee824ef-729b-4a0e-9c14-b7117d33a817}", driver="WINUSB"` – NessDan Apr 08 '22 at 03:42
  • Thanks for letting us know! If the problem is solved now, you might want to delete the question. – Bergi Apr 08 '22 at 15:26
  • 1
    @Bergi I'm still working on it but I plan on deleting / answering the post if I learn anything new in the meantime (I couldn't find the error via a Google search so if I can leave something helpful to a future developer, I'd like to do that!) – NessDan Apr 08 '22 at 22:42
  • 1
    It seems like you figured this out but a detail I would add here is that it's expected that Windows will be using the usbccgp driver for a composite device like this. When Chrome sees this driver it looks at the device's children to see if any of those use the WinUSB driver and keeps track of which interfaces those represent so it knows which one to open when you call claimInterface(). It is possible to replace the usbccgp driver with WinUSB so none of that is necessary but then Chrome wouldn't be able to share the device and let the standard gamepad driver claim the HID interface. – Reilly Grant Apr 09 '22 at 00:40
  • That's super helpful to know @ReillyGrant! That explains the output I mentioned in my comment above and what was going on in the background! – NessDan Apr 09 '22 at 05:29

1 Answers1

0

This was due to a misconfiguration of my device's firmware code (didn't initialize or do any setup for the endpoints!)

That's been fixed and I'm able to send data over properly.

NessDan
  • 1,137
  • 1
  • 16
  • 34