I have null in the serial port after I open the SerialDevice in C# on Windows IoT Core 10 running on Raspberry Pi 3.
Here is the code:
string aqs = SerialDevice.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(aqs);
List<DeviceInformation> list = devices.ToList();
DeviceInformation di = list.First();
serialPort = await SerialDevice.FromIdAsync(di.Id);
serialPort
is null
.
di.Id
equals: Id "\\\\?\\ACPI#BCM2836#0#{86e0d1e0-8089-11d0-9ce4-08003e301f73}" string
list.Count
equal 1
Here are two records from /api/devicemanager/devices
GET
request related to UART
:
{
"Class": "Ports",
"Description": "BCM283x Mini UART Serial Device",
"ID": "ACPI\\BCM2836\\0",
"Manufacturer": "Microsoft",
"ParentID": "ACPI_HAL\\PNP0C08\\0",
"ProblemCode": 0,
"StatusCode": 25182218
},
{
"Class": "System",
"Description": "ARM PL011 UART Device Driver",
"ID": "ACPI\\BCM2837\\4",
"Manufacturer": "Microsoft",
"ParentID": "ACPI_HAL\\PNP0C08\\0",
"ProblemCode": 0,
"StatusCode": 25165834
},
I tried both to short circuit Rx and Tx and to not shortly circuit it, it doesn't works...
UPDATE
If I split the given ID, I have Invalid data
exception.
string aqs = SerialDevice.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(aqs);
List<DeviceInformation> list = devices.ToList();
DeviceInformation di = list.First();
string id = "{86e0d1e0-8089-11d0-9ce4-08003e301f73}";
try { serialPort = await SerialDevice.FromIdAsync(id); } catch(Exception e) { Debug.WriteLine(e.Message); }
id = "\\\\?\\ACPI#BCM2836#0#";
try { serialPort = await SerialDevice.FromIdAsync(id); } catch(Exception e) { Debug.WriteLine(e.Message); }
id = di.Id;
try { serialPort = await SerialDevice.FromIdAsync(id); } catch(Exception e) { Debug.WriteLine(e.Message); }
if (serialPort == null) { Debug.WriteLine("No device"); return; }
The output:
Exception thrown: 'System.Exception' in mscorlib.ni.dll
The data is invalid. (Exception from HRESULT: 0x8007000D)
The data is invalid. (Exception from HRESULT: 0x8007000D)
No device
As Grim said, the solution is here: SerialDevice.FromIdAsync() yields a null serial port
It is necessary to add:
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
in the <Capabilities>
tag in Package.appxmanifest
file.
User contributions licensed under CC BY-SA 3.0