UWP app cannot find/connect to USB device
I am trying to make a UWP app which connects to a USB device and then executes a series of commands, like retrieving data from the internal sensor (think of an accelerometer). I started of with following these guidelines:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn303343(v=vs.85).aspx
So, I also tried making a blank app, and adjusted the manifest accordingly:
<Capabilities>
<DeviceCapability Name="usb">
<Device Id="vidpid:1CBE 0003">
<Function Type="classId:ff 00 00" />
</Device>
</DeviceCapability>
</Capabilities>
To be sure, this is how the device identifies itself in the device manager:
and then used
string aqs = UsbDevice.GetDeviceSelector(vid, pid);
var finder = await DeviceInformation.FindAllAsync(aqs);
However, without success. The problem is simple, the app cannot find any device. I then went on to modify this sample app (which uses a DeviceWatcher instead of above way of finding a connected device USB):
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomUsbDeviceAccess
which also did not find a USB device. Of course I tried a different PC to see if it is related to my configuration, but as you expected, no success. This led me to think that it might be related to the USB device, but what could be wrong? Or did I really make some mistake in these five lines? Is there another way I could try to connect to the USB device? Any hint is appreciated!
Related Questions:
UWP/C# - Issue with AQS and USB Devices
https://social.msdn.microsoft.com/Forums/en-US/e9b85e2a-27c0-489e-9bf5-d990f0e83a61/uwpissue-with-usbdevicegetdeviceselector-not-finding-attached-bulk-usb-device?forum=wpdevelop
usb uwp
add a comment |
I am trying to make a UWP app which connects to a USB device and then executes a series of commands, like retrieving data from the internal sensor (think of an accelerometer). I started of with following these guidelines:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn303343(v=vs.85).aspx
So, I also tried making a blank app, and adjusted the manifest accordingly:
<Capabilities>
<DeviceCapability Name="usb">
<Device Id="vidpid:1CBE 0003">
<Function Type="classId:ff 00 00" />
</Device>
</DeviceCapability>
</Capabilities>
To be sure, this is how the device identifies itself in the device manager:
and then used
string aqs = UsbDevice.GetDeviceSelector(vid, pid);
var finder = await DeviceInformation.FindAllAsync(aqs);
However, without success. The problem is simple, the app cannot find any device. I then went on to modify this sample app (which uses a DeviceWatcher instead of above way of finding a connected device USB):
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomUsbDeviceAccess
which also did not find a USB device. Of course I tried a different PC to see if it is related to my configuration, but as you expected, no success. This led me to think that it might be related to the USB device, but what could be wrong? Or did I really make some mistake in these five lines? Is there another way I could try to connect to the USB device? Any hint is appreciated!
Related Questions:
UWP/C# - Issue with AQS and USB Devices
https://social.msdn.microsoft.com/Forums/en-US/e9b85e2a-27c0-489e-9bf5-d990f0e83a61/uwpissue-with-usbdevicegetdeviceselector-not-finding-attached-bulk-usb-device?forum=wpdevelop
usb uwp
add a comment |
I am trying to make a UWP app which connects to a USB device and then executes a series of commands, like retrieving data from the internal sensor (think of an accelerometer). I started of with following these guidelines:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn303343(v=vs.85).aspx
So, I also tried making a blank app, and adjusted the manifest accordingly:
<Capabilities>
<DeviceCapability Name="usb">
<Device Id="vidpid:1CBE 0003">
<Function Type="classId:ff 00 00" />
</Device>
</DeviceCapability>
</Capabilities>
To be sure, this is how the device identifies itself in the device manager:
and then used
string aqs = UsbDevice.GetDeviceSelector(vid, pid);
var finder = await DeviceInformation.FindAllAsync(aqs);
However, without success. The problem is simple, the app cannot find any device. I then went on to modify this sample app (which uses a DeviceWatcher instead of above way of finding a connected device USB):
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomUsbDeviceAccess
which also did not find a USB device. Of course I tried a different PC to see if it is related to my configuration, but as you expected, no success. This led me to think that it might be related to the USB device, but what could be wrong? Or did I really make some mistake in these five lines? Is there another way I could try to connect to the USB device? Any hint is appreciated!
Related Questions:
UWP/C# - Issue with AQS and USB Devices
https://social.msdn.microsoft.com/Forums/en-US/e9b85e2a-27c0-489e-9bf5-d990f0e83a61/uwpissue-with-usbdevicegetdeviceselector-not-finding-attached-bulk-usb-device?forum=wpdevelop
usb uwp
I am trying to make a UWP app which connects to a USB device and then executes a series of commands, like retrieving data from the internal sensor (think of an accelerometer). I started of with following these guidelines:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn303343(v=vs.85).aspx
So, I also tried making a blank app, and adjusted the manifest accordingly:
<Capabilities>
<DeviceCapability Name="usb">
<Device Id="vidpid:1CBE 0003">
<Function Type="classId:ff 00 00" />
</Device>
</DeviceCapability>
</Capabilities>
To be sure, this is how the device identifies itself in the device manager:
and then used
string aqs = UsbDevice.GetDeviceSelector(vid, pid);
var finder = await DeviceInformation.FindAllAsync(aqs);
However, without success. The problem is simple, the app cannot find any device. I then went on to modify this sample app (which uses a DeviceWatcher instead of above way of finding a connected device USB):
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CustomUsbDeviceAccess
which also did not find a USB device. Of course I tried a different PC to see if it is related to my configuration, but as you expected, no success. This led me to think that it might be related to the USB device, but what could be wrong? Or did I really make some mistake in these five lines? Is there another way I could try to connect to the USB device? Any hint is appreciated!
Related Questions:
UWP/C# - Issue with AQS and USB Devices
https://social.msdn.microsoft.com/Forums/en-US/e9b85e2a-27c0-489e-9bf5-d990f0e83a61/uwpissue-with-usbdevicegetdeviceselector-not-finding-attached-bulk-usb-device?forum=wpdevelop
usb uwp
usb uwp
edited May 23 '17 at 12:34
Community♦
11
11
asked Dec 12 '16 at 8:34
Dr.JDr.J
888
888
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
It seems that I found one way to resolve this, which is a bit stupid, but hey, who asks me anyway...
I came across this one here on stackoverflow:
Cannot create UsbDevice from DeviceInformation.Id
And it seems that my issue is indeed resolved when I use a .inf to refer to winusb as the driver. I have no idea why, so if any of you have an explanation, please let me know.
As above answer is referring to a blogpost that does exist anymore (I used the wayback machine to get to it), I'm posting the inf here, in case it helps anyone (but it's an ordinary inf)
;
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer=12/12/2016,13.54.20.543
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% =USB_Install, USBVID_1267&PID_0000
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%system32setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include =winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"
; [DestinationDirs]
; If your INF needs to copy files, you must not use the DefaultDestDir directive here.
; You must explicitly reference all file-list-section names in this section.
; =================== Strings ===================
[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DeviceName="OWI-535 Robotic Arm"
REG_MULTI_SZ = 0x00010000
Note that I left an arbitrary VID and PID in the driver, but I still have to connect with the VID and PID that the device tells me.
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
add a comment |
This is how to connect to a WinUSB device on UWP.
public async Task<IEnumerable<DeviceDefinition>> GetConnectedDeviceDefinitions(uint? vendorId, uint? productId)
{
var aqsFilter = "System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND " + $" System.DeviceInterface.WinUsb.UsbVendorId:={vendorId.Value} AND System.DeviceInterface.WinUsb.UsbProductId:={productId.Value}";
var deviceInformationCollection = await wde.DeviceInformation.FindAllAsync(aqsFilter).AsTask();
//TODO: return the vid/pid if we can get it from the properties. Also read/write buffer size
var deviceIds = deviceInformationCollection.Select(d => new DeviceDefinition { DeviceId = d.Id, DeviceType = DeviceType.Usb }).ToList();
return deviceIds;
}
Here is a more complete answer: https://stackoverflow.com/a/53954352/1878141
And, here is a class from the repo: https://github.com/MelbourneDeveloper/Device.Net/blob/master/src/Usb.Net.UWP/UWPUsbDeviceFactory.cs
add a comment |
In my case, the DeviceInterfaceGUID
registry entry for the device was missing, which seems to be required so that the WinUSB device can be found and instantiated.
I added the entry HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice ParametersDeviceInterfaceGUID
with a random GUID like {86529001-c433-4530-a578-9a67adf1ffa9}
(in my case 16D0
is the vendor ID, 0BD7
the product ID and None
the instance). This can be done from the command line for example, by calling reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice Paramet
.
ers" /v "DeviceInterfaceGUID" /t REG_SZ /d "{86529001-c433-4530-a578-9a67adf1ffa9}" /f
I am absolutely no expert in USB and have no idea why this is needed or why it was missing; but at least in my case adding a GUID helped, both on my Windows 10 Professional and my Windows 10 IoT Core (Raspberry PI 3B). Maybe see https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-device-specific-registry-settings for more details.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41096871%2fuwp-app-cannot-find-connect-to-usb-device%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems that I found one way to resolve this, which is a bit stupid, but hey, who asks me anyway...
I came across this one here on stackoverflow:
Cannot create UsbDevice from DeviceInformation.Id
And it seems that my issue is indeed resolved when I use a .inf to refer to winusb as the driver. I have no idea why, so if any of you have an explanation, please let me know.
As above answer is referring to a blogpost that does exist anymore (I used the wayback machine to get to it), I'm posting the inf here, in case it helps anyone (but it's an ordinary inf)
;
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer=12/12/2016,13.54.20.543
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% =USB_Install, USBVID_1267&PID_0000
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%system32setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include =winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"
; [DestinationDirs]
; If your INF needs to copy files, you must not use the DefaultDestDir directive here.
; You must explicitly reference all file-list-section names in this section.
; =================== Strings ===================
[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DeviceName="OWI-535 Robotic Arm"
REG_MULTI_SZ = 0x00010000
Note that I left an arbitrary VID and PID in the driver, but I still have to connect with the VID and PID that the device tells me.
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
add a comment |
It seems that I found one way to resolve this, which is a bit stupid, but hey, who asks me anyway...
I came across this one here on stackoverflow:
Cannot create UsbDevice from DeviceInformation.Id
And it seems that my issue is indeed resolved when I use a .inf to refer to winusb as the driver. I have no idea why, so if any of you have an explanation, please let me know.
As above answer is referring to a blogpost that does exist anymore (I used the wayback machine to get to it), I'm posting the inf here, in case it helps anyone (but it's an ordinary inf)
;
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer=12/12/2016,13.54.20.543
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% =USB_Install, USBVID_1267&PID_0000
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%system32setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include =winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"
; [DestinationDirs]
; If your INF needs to copy files, you must not use the DefaultDestDir directive here.
; You must explicitly reference all file-list-section names in this section.
; =================== Strings ===================
[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DeviceName="OWI-535 Robotic Arm"
REG_MULTI_SZ = 0x00010000
Note that I left an arbitrary VID and PID in the driver, but I still have to connect with the VID and PID that the device tells me.
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
add a comment |
It seems that I found one way to resolve this, which is a bit stupid, but hey, who asks me anyway...
I came across this one here on stackoverflow:
Cannot create UsbDevice from DeviceInformation.Id
And it seems that my issue is indeed resolved when I use a .inf to refer to winusb as the driver. I have no idea why, so if any of you have an explanation, please let me know.
As above answer is referring to a blogpost that does exist anymore (I used the wayback machine to get to it), I'm posting the inf here, in case it helps anyone (but it's an ordinary inf)
;
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer=12/12/2016,13.54.20.543
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% =USB_Install, USBVID_1267&PID_0000
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%system32setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include =winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"
; [DestinationDirs]
; If your INF needs to copy files, you must not use the DefaultDestDir directive here.
; You must explicitly reference all file-list-section names in this section.
; =================== Strings ===================
[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DeviceName="OWI-535 Robotic Arm"
REG_MULTI_SZ = 0x00010000
Note that I left an arbitrary VID and PID in the driver, but I still have to connect with the VID and PID that the device tells me.
It seems that I found one way to resolve this, which is a bit stupid, but hey, who asks me anyway...
I came across this one here on stackoverflow:
Cannot create UsbDevice from DeviceInformation.Id
And it seems that my issue is indeed resolved when I use a .inf to refer to winusb as the driver. I have no idea why, so if any of you have an explanation, please let me know.
As above answer is referring to a blogpost that does exist anymore (I used the wayback machine to get to it), I'm posting the inf here, in case it helps anyone (but it's an ordinary inf)
;
;
; Installs WinUsb
;
[Version]
Signature = "$Windows NT$"
Class = USBDevice
ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6}
Provider = %ManufacturerName%
CatalogFile = WinUSBInstallation.cat
DriverVer=12/12/2016,13.54.20.543
; ========== Manufacturer/Models sections ===========
[Manufacturer]
%ManufacturerName% = Standard,NTamd64
[Standard.NTamd64]
%DeviceName% =USB_Install, USBVID_1267&PID_0000
; ========== Class definition ===========
[ClassInstall32]
AddReg = ClassInstall_AddReg
[ClassInstall_AddReg]
HKR,,,,%ClassName%
HKR,,NoInstallClass,,1
HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%system32setupapi.dll,-20"
HKR,,LowerLogoVersion,,5.2
; =================== Installation ===================
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include =winusb.inf
Needs = WINUSB.NT.Services
[USB_Install.HW]
AddReg=Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{9f543223-cede-4fa3-b376-a25ce9a30e74}"
; [DestinationDirs]
; If your INF needs to copy files, you must not use the DefaultDestDir directive here.
; You must explicitly reference all file-list-section names in this section.
; =================== Strings ===================
[Strings]
ManufacturerName=""
ClassName="Universal Serial Bus devices"
DeviceName="OWI-535 Robotic Arm"
REG_MULTI_SZ = 0x00010000
Note that I left an arbitrary VID and PID in the driver, but I still have to connect with the VID and PID that the device tells me.
edited May 23 '17 at 12:02
Community♦
11
11
answered Dec 12 '16 at 10:23
Dr.JDr.J
888
888
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
add a comment |
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
msdn.microsoft.com/en-us/library/windows/hardware/… Seems like a relevant reference
– Carlo Mendoza
Jun 21 '17 at 23:51
add a comment |
This is how to connect to a WinUSB device on UWP.
public async Task<IEnumerable<DeviceDefinition>> GetConnectedDeviceDefinitions(uint? vendorId, uint? productId)
{
var aqsFilter = "System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND " + $" System.DeviceInterface.WinUsb.UsbVendorId:={vendorId.Value} AND System.DeviceInterface.WinUsb.UsbProductId:={productId.Value}";
var deviceInformationCollection = await wde.DeviceInformation.FindAllAsync(aqsFilter).AsTask();
//TODO: return the vid/pid if we can get it from the properties. Also read/write buffer size
var deviceIds = deviceInformationCollection.Select(d => new DeviceDefinition { DeviceId = d.Id, DeviceType = DeviceType.Usb }).ToList();
return deviceIds;
}
Here is a more complete answer: https://stackoverflow.com/a/53954352/1878141
And, here is a class from the repo: https://github.com/MelbourneDeveloper/Device.Net/blob/master/src/Usb.Net.UWP/UWPUsbDeviceFactory.cs
add a comment |
This is how to connect to a WinUSB device on UWP.
public async Task<IEnumerable<DeviceDefinition>> GetConnectedDeviceDefinitions(uint? vendorId, uint? productId)
{
var aqsFilter = "System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND " + $" System.DeviceInterface.WinUsb.UsbVendorId:={vendorId.Value} AND System.DeviceInterface.WinUsb.UsbProductId:={productId.Value}";
var deviceInformationCollection = await wde.DeviceInformation.FindAllAsync(aqsFilter).AsTask();
//TODO: return the vid/pid if we can get it from the properties. Also read/write buffer size
var deviceIds = deviceInformationCollection.Select(d => new DeviceDefinition { DeviceId = d.Id, DeviceType = DeviceType.Usb }).ToList();
return deviceIds;
}
Here is a more complete answer: https://stackoverflow.com/a/53954352/1878141
And, here is a class from the repo: https://github.com/MelbourneDeveloper/Device.Net/blob/master/src/Usb.Net.UWP/UWPUsbDeviceFactory.cs
add a comment |
This is how to connect to a WinUSB device on UWP.
public async Task<IEnumerable<DeviceDefinition>> GetConnectedDeviceDefinitions(uint? vendorId, uint? productId)
{
var aqsFilter = "System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND " + $" System.DeviceInterface.WinUsb.UsbVendorId:={vendorId.Value} AND System.DeviceInterface.WinUsb.UsbProductId:={productId.Value}";
var deviceInformationCollection = await wde.DeviceInformation.FindAllAsync(aqsFilter).AsTask();
//TODO: return the vid/pid if we can get it from the properties. Also read/write buffer size
var deviceIds = deviceInformationCollection.Select(d => new DeviceDefinition { DeviceId = d.Id, DeviceType = DeviceType.Usb }).ToList();
return deviceIds;
}
Here is a more complete answer: https://stackoverflow.com/a/53954352/1878141
And, here is a class from the repo: https://github.com/MelbourneDeveloper/Device.Net/blob/master/src/Usb.Net.UWP/UWPUsbDeviceFactory.cs
This is how to connect to a WinUSB device on UWP.
public async Task<IEnumerable<DeviceDefinition>> GetConnectedDeviceDefinitions(uint? vendorId, uint? productId)
{
var aqsFilter = "System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND " + $" System.DeviceInterface.WinUsb.UsbVendorId:={vendorId.Value} AND System.DeviceInterface.WinUsb.UsbProductId:={productId.Value}";
var deviceInformationCollection = await wde.DeviceInformation.FindAllAsync(aqsFilter).AsTask();
//TODO: return the vid/pid if we can get it from the properties. Also read/write buffer size
var deviceIds = deviceInformationCollection.Select(d => new DeviceDefinition { DeviceId = d.Id, DeviceType = DeviceType.Usb }).ToList();
return deviceIds;
}
Here is a more complete answer: https://stackoverflow.com/a/53954352/1878141
And, here is a class from the repo: https://github.com/MelbourneDeveloper/Device.Net/blob/master/src/Usb.Net.UWP/UWPUsbDeviceFactory.cs
answered Dec 28 '18 at 6:09


Melbourne DeveloperMelbourne Developer
1,7941239
1,7941239
add a comment |
add a comment |
In my case, the DeviceInterfaceGUID
registry entry for the device was missing, which seems to be required so that the WinUSB device can be found and instantiated.
I added the entry HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice ParametersDeviceInterfaceGUID
with a random GUID like {86529001-c433-4530-a578-9a67adf1ffa9}
(in my case 16D0
is the vendor ID, 0BD7
the product ID and None
the instance). This can be done from the command line for example, by calling reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice Paramet
.
ers" /v "DeviceInterfaceGUID" /t REG_SZ /d "{86529001-c433-4530-a578-9a67adf1ffa9}" /f
I am absolutely no expert in USB and have no idea why this is needed or why it was missing; but at least in my case adding a GUID helped, both on my Windows 10 Professional and my Windows 10 IoT Core (Raspberry PI 3B). Maybe see https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-device-specific-registry-settings for more details.
add a comment |
In my case, the DeviceInterfaceGUID
registry entry for the device was missing, which seems to be required so that the WinUSB device can be found and instantiated.
I added the entry HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice ParametersDeviceInterfaceGUID
with a random GUID like {86529001-c433-4530-a578-9a67adf1ffa9}
(in my case 16D0
is the vendor ID, 0BD7
the product ID and None
the instance). This can be done from the command line for example, by calling reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice Paramet
.
ers" /v "DeviceInterfaceGUID" /t REG_SZ /d "{86529001-c433-4530-a578-9a67adf1ffa9}" /f
I am absolutely no expert in USB and have no idea why this is needed or why it was missing; but at least in my case adding a GUID helped, both on my Windows 10 Professional and my Windows 10 IoT Core (Raspberry PI 3B). Maybe see https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-device-specific-registry-settings for more details.
add a comment |
In my case, the DeviceInterfaceGUID
registry entry for the device was missing, which seems to be required so that the WinUSB device can be found and instantiated.
I added the entry HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice ParametersDeviceInterfaceGUID
with a random GUID like {86529001-c433-4530-a578-9a67adf1ffa9}
(in my case 16D0
is the vendor ID, 0BD7
the product ID and None
the instance). This can be done from the command line for example, by calling reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice Paramet
.
ers" /v "DeviceInterfaceGUID" /t REG_SZ /d "{86529001-c433-4530-a578-9a67adf1ffa9}" /f
I am absolutely no expert in USB and have no idea why this is needed or why it was missing; but at least in my case adding a GUID helped, both on my Windows 10 Professional and my Windows 10 IoT Core (Raspberry PI 3B). Maybe see https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-device-specific-registry-settings for more details.
In my case, the DeviceInterfaceGUID
registry entry for the device was missing, which seems to be required so that the WinUSB device can be found and instantiated.
I added the entry HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice ParametersDeviceInterfaceGUID
with a random GUID like {86529001-c433-4530-a578-9a67adf1ffa9}
(in my case 16D0
is the vendor ID, 0BD7
the product ID and None
the instance). This can be done from the command line for example, by calling reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumUSBVID_16D0&PID_0BD7NoneDevice Paramet
.
ers" /v "DeviceInterfaceGUID" /t REG_SZ /d "{86529001-c433-4530-a578-9a67adf1ffa9}" /f
I am absolutely no expert in USB and have no idea why this is needed or why it was missing; but at least in my case adding a GUID helped, both on my Windows 10 Professional and my Windows 10 IoT Core (Raspberry PI 3B). Maybe see https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/usb-device-specific-registry-settings for more details.
edited Jan 2 at 10:07
answered Jan 1 at 19:42


AndiAndi
1,41321419
1,41321419
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41096871%2fuwp-app-cannot-find-connect-to-usb-device%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown