UWP app for a USB device

The Windows.Devices.Usb namespace provides a way for a Windows app to communicate with an external USB device that uses WinUSB (Winusb.sys) as the device driver.

In this section

Topic Description

Talking to USB devices, start to finish (UWP app)

Use the Windows Runtime APIs, introduced in Windows 8.1, to write UWP apps that gives users access to their peripheral USB device. Such apps can connect to a device based on user-specified criteria, get information about the device, send data to the device and conversely get data steams from the device, and poll the device for interrupt data.

How to add USB device capabilities to the app manifest

This topic describes the device capabilities that are required for a Windows app that uses the Windows.Devices.Usb namespace.

How to connect to a USB device (UWP app)

In Windows 8.1, you can write a UWP app that interacts with a USB device. The app can send control commands, get device information, and read and write data to/from bulk and interrupt endpoints. Before you can do all that, you must find the device and establish connection.

In this part, you will learn how to use the DeviceWatcher object to find the device and then open it to start communicating from your app. You will also learn how to close the device when you are finished using it.

How to send a USB control transfer (UWP app)

An app that communicates with a USB device usually sends several control transfers requests. Those requests get information about the device and send control commands defined by the hardware vendor. In this topic you'll learn about control transfers and how to format and send them in your UWP app.

How to send a USB interrupt transfer request (UWP app)

A USB device can support interrupt endpoints so that it can send or receive data at regular intervals. To accomplish that, the host polls the device at regular intervals and data is transmitted each time the host polls the device. Interrupt transfers are mostly used for getting interrupt data from the device. This topic describes how a UWP app can get continuous interrupt data from the device.

How to send a USB bulk transfer request (UWP app)

In this topic, you'll learn about a USB bulk transfer and how to initiate a transfer request from your UWP app that communicates with a USB device.

How to get USB descriptors (UWP app)

One of the main tasks of interacting with a USB device is to get information about it. All USB devices provide information in the form of several data structures called descriptors. This topic describes how a UWP app can get descriptors from the device at the endpoint, interface, configuration, and device level.

How to select a USB interface setting (UWP app)

In this topic, you'll learn about changing a setting within a USB interface. You'll use the UsbInterfaceSetting object to get the current setting and set a setting in the interface.

USB samples

What are the limitations of the namespace?

You cannot use Windows.Devices.Usb in these cases:

  • If the device driver is not Winusb.sys.

  • You want to communicate with USB isochronous endpoints of the device.

  • You want to communicate streams of a SuperSpeed bulk endpoint. For those endpoints, the USB Windows Runtime classes for bulk transfers can only send or receive data from the first stream of the endpoint.

  • You allow multiple apps to concurrently access the device.

  • Your USB device is an internal device. Note   The APIs are primarily designed for accessing peripheral devices. The API can also access PC internal USB devices. However access to PC internal USB devices from a UWP app is limited to a privileged app that is explicitly declared by the OEM for that PC.

  • The kernel-mode device stack has a filter driver above Winusb.sys. Note  This scenario is available to privileged apps only.

  • Your device has multiple USB configurations, and you want to select a configuration, other than the first. Windows.Devices.Usb selects the first configuration by default.