Skip to content

DeviceManager.Current.GetDevicesAsync() does not enumerate non HID USB devices  #161

Closed

Description

@flyingoverclouds

When you try to enumerate USB device after registering WindowsUsbDeviceFactory, you get an empty list.

The GetClassGuid implementation in WindowsUsbDeviceFactory class must return WindowsDeviceConstants.GUID_DEVINTERFACE_USB_DEVICE instead of WindowsDeviceConstants.WinUSBGuid

With this correction, you are able to enumerate non HID USB device.

Activity

  1. MelbourneDeveloper commented on Oct 15, 2020

    @MelbourneDeveloper
    Owner

    @flyingoverclouds thanks for pointing this out.

    Currently, the code does enumerate non-HID devices. I know this because if you register WindowsUsbDeviceFactory without WindowsHidDeviceFactory, it picks up USB devices that WindowsHidDeviceFactory doesn't pick up. These devices don't work with Hid. This line is where Hid.Net picks the Guid up from. This guid is different from WinUSBGuid.

    Do you think it should enumerate on both constants? Or, does GUID_DEVINTERFACE_USB_DEVICE contain WinUSBGuid as a subset of devices? I don't want to stop enumerating devices that it already handles. Also, can you please give me some examples of some devices that might show up as a GUID_DEVINTERFACE_USB_DEVICE so I can build some tests around this?

    Perhaps if you could elaborate about your scenario, I can try to make sure that the issue is fixed permanently. What device are you trying to connect to?

  2. flyingoverclouds commented on Oct 16, 2020

    @flyingoverclouds
    Author

    I am currently adding some USB feature on hid & non hid usb device (control transfer for example), and i understood that WindowsUsbDeviceFactory should enumerate UsbDevice :)

  3. MelbourneDeveloper commented on Oct 16, 2020

    @MelbourneDeveloper
    Owner

    @flyingoverclouds firstly, it sounds like you should talk to the nanoFramework people. There is already a pull request for control transfer here. I strongly recommend joining the discord channel so you can chat with us about that. The reason this PR is stalled is that I haven't been able to figure out how to test it with a real device yet.

    i understood that WindowsUsbDeviceFactory should enumerate UsbDevice

    Yes. of course. My question:

    Do you think it should enumerate on both constants? Or, does GUID_DEVINTERFACE_USB_DEVICE contain WinUSBGuid as a subset of devices?

  4. MelbourneDeveloper commented on Nov 6, 2020

    @MelbourneDeveloper
    Owner

    @flyingoverclouds have you made any progress with control transfer?

    What is the device that you are using? I need to get a device that I can test control transfer with. Did you join discord by any chance?

  5. MelbourneDeveloper commented on Nov 6, 2020

    @MelbourneDeveloper
    Owner

    @flyingoverclouds I got a DFU mode device to connect. Please have a look at the latest code in the develop branch. You can see how to use WindowsDeviceConstants.GUID_DEVINTERFACE_USB_DEVICE to get a list of connected devices.

    public async Task TestFindSTMDFUModeWithFactory()

    image

    Can this issue be closed?

  6. MelbourneDeveloper commented on Nov 21, 2020

    @MelbourneDeveloper
    Owner

    This has been fixed. You have to specify the class guid when listing devices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions