Search code examples
uwpusbstm32f7

Connect to HidDevice with UsbDevice class in UWP app


I'm using the stm32f746g-discovery board with the Keil USB HID example. I can connect to the USB HID device with a UWP app using the HidDevice class. Is it also possible to use the UsbDevice class to connect to the board when using the Keil USB HID example? I want to try to use interruptOut to connect to the board and this is only possible with the UsbDevice class.

The UWP app I made with the UsbDevice class does not seem to connect to the USB of the discovery board (no problem with the HidDevice class UWP app).

Am I trying something that is impossible or am I doing something wrong with the connection?

I'm using the example code from Microsoft to connect:

private async void OpenDevice()
    {
        UInt32 vid = 0x045E;
        UInt32 pid = 0x0611;

        string aqs = UsbDevice.GetDeviceSelector(vid, pid);

        var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqs);

        try
        {
            usbDevice = await UsbDevice.FromIdAsync(myDevices[0].Id);
        }
        catch (Exception exception)
        {
            ShowStatus(exception.Message.ToString());
        }
        finally
        {
            ShowStatus("Opened device for communication.");
        }

    }

With the correct vid & pid (works with HidDevice class).

I'm new to USB implementation and trying to learn.

thx


Solution

  • Is it also possible to use the UsbDevice class to connect to the board when using the Keil USB HID example?

    HidDevice cannot be accessed using UsbDevice Class, this is by design.

    When UWP accesses HidDevices with HidDevice Class, the app must include specific DeviceCapability data(<DeviceCapability Name="humaninterfacedevice">) in the Capabilities node of its manifest.