I am communicating (or attempting to) with an ESP 301 motor controller via USB. See here for documentation if needed (PDF)
In order to do this, I am working in C# and have the following function:
private async void connectDevice()
{
string aqs = UsbDevice.GetDeviceSelector(Constants.ESPVENDORID,Constants.ESPPRODUCTID);
Console.WriteLine(aqs);
var myDevices = await DeviceInformation.FindAllAsync(aqs);
Console.WriteLine(myDevices.Count);
try
{
esp301 = await UsbDevice.FromIdAsync(myDevices[0].Id);
Console.WriteLine("SUCCESSFULLY OPENED DEVICE FOR COMMUNICATION");
initialized = true;
}
catch (Exception exception)
{
Console.WriteLine("ERROR:");
Console.WriteLine(exception.Message.ToString());
}
}
However, the DeviceInformation.FindAllAsync(aqs)
call returns an empty container.
I have modified the app manifest to contain the following:
<Capabilities>
<DeviceCapability Name="usb">
<Device Id="vidpid:104D3001">
</Device>
</DeviceCapability>
</Capabilities>
This is the bit that I am most uncertain of, and I am struggling to find much information about this.
In a separate constants class, I have the following defined:
public static Guid ESPGUID { get { return new Guid("{4d36e978-e325-11ce-bfc1-08002be10318}"); } }
public static uint ESPVENDORID { get { return 0x104D; } }
public static uint ESPPRODUCTID { get { return 0x3001; } }
which all seems correct, and I have verified the vendor and product ids using the USB View application distributed by Microsoft:
Adjusting the UsbDevice.GetDeviceSelector
call to use the GUID defined in the constants file like so:
string aqs = UsbDevice.GetDeviceSelector(Constants.ESPGUID);
does not seem to change anything either.
I know that the container is empty because the count that I am printing out to the console is 0, and also I get an out of range exception.
The aqs string that I am printing looks like so:
System.Devices.InterfaceClassGuid:="{DEE824EF-729B-4A0E-9C14-B7117D33A817}" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True AND System.DeviceInterface.WinUsb.DeviceInterfaceClasses:~="{4D36E978-E325-11CE-BFC1-08002BE10318}"
I have tried to provide as much information as possible, any help that you can provide will be appreciated. Thank you.