I am trying to write to Arduino Uno device, but SerialDevice.FromIdAsync always returns null. Here is my code:
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync();
foreach (DeviceInformation deviceInfo in devices)
{
if (deviceInfo.Name.IndexOf("Arduino") >= 0) {
Debug.Log("Arduino found with id="+deviceInfo.Id);
serialDevice = await SerialDevice.FromIdAsync(deviceInfo.Id);
if (serialDevice == null) Debug.Log("it's null");
break;
}
}
Running this code gives me "Arduino found with id=\\?USB#VID_2341&PID_0001#55...." and then "it's null"
In my manfiest I have the following inside Capabilities:
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
Connect to Arduino with UWP
For getting SerialDevice
, we suggest use SerialDevice.GetDeviceSelector()
to get deviceSelector
and use the following to create SerialDevice watcher. And we have provided code sample that you could refer directly. I have tested, it works in my side that the app could list Arduino Uno device with USB\VID_2341&PID_0043\xxxxx device Id.
var deviceWatcher = DeviceInformation.CreateWatcher(deviceSelector);