Answered by:
SerialDevice.FromIdAsync() always returns null - unless the serial adapter is plugged in after boot

Question
-
As the title says, I've discovered that the SerialDevice.FromIdAsync() method always returns null if the USB to Serial Adapter is plugged in while the RPi2 is booting.
But, If I unplug the Serial Adapter and plug it back in AFTER the RPi is completely booted the SerialDevice.FromIdAsync() method will return the SerialDevice Object for the Serial Adapter.
Basically, the only way to get the SerialDevice.FromIdAsync() method to return a SerialDevice object is by plugging the adapter in AFTER the RPi is done booting up.
The USB to Serial Adapter: "Silicon Labs CP2102 USB to UART Bridge".OS version on the RPi2: 10.0.10240.16384.
Answers
-
I found the solution - simply add these lines to Package.appxmanifest in the <Capabilities> section.
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
All replies
-
I am having a similar issue.
When i boot my RPi2 and run either my own application or the SerialDevice sample from github, SerialDevice.FromIdAsync(...) keeps returning null. If I plug, unplug, replug, boot the Pi with it plugged in or unplugged, nothing seems to make a difference. One day it eventually started working after a few hours of trying various things like forcing a clean deploy, commenting and uncommenting the devicecapability in the app manifest, reformatting my SD card and reflashing the image. The day after that I could not get it to work at all.
I have three of these devices and they all work when plugged into my pc/laptop. I also tried reflashing my SD card with the IoT image but that did not help either. The device shows up in the device manager through the web console, so i am not sure what the problem is. This is super frustrating and I am disappointed that nobody from Microsoft support has commented on this issue even though there are at least two or three threads devoted to it.
-
-
-
-
Hi Josiah,
Trying a shot at this here as something was reported for Minnowboard at http://ms-iot.github.io/content/en-US/win10/ReleaseNotes.htm
Quote
"A NULL value may be returned by SerialDevice::FromIdAsync() when devices are connected to the top USB port on MinnowBoardMax (2175837) WORKAROUND: Use the bottom USB port."
This might not be identical to what is happening on the Pi2, but worth a short trying out.
Regards,
Chun Siong- Edited by tanchunsiongMicrosoft employee Sunday, August 23, 2015 6:48 AM typo for "her" to "here"
-
hmm...
I've been using the 2 USB ports farthest from the Ethernet connector and it doesn't matter which one of those I try. I'm always getting the same result.
But now you have me thinking... I've yet to try the 2 that are closest to the Ethernet connector...
-
hmm...
I've been using the 2 USB ports farthest from the Ethernet connector and it doesn't matter which one of those I try. I'm always getting the same result.
But now you have me thinking... I've yet to try the 2 that are closest to the Ethernet connector...
-
I have plugged my device into each of the USB ports with no success. With my latest round of attempts I was never able to get a non-null device, regardless of USB port, rebooting,, plugged/unplugged status at boot, etc.
When I plugged my Silicon Labs device into a powered USB hub, the SerialDevice.FromidAsync() now consistently returns a non-null value if i unplug/replug it into the hub after boot. Before I could not get it to work at all, but at least now I have consistent but still broken behavior.
Is someone from Microsoft going to address this thread at some point? I was super excited about Windows 10 IoT at first, but the support here is so poor that I am thinking about going back to a small full x86 pc solution like VIA epia. Even though those things are like 10 years old, at least I know I can deploy a working operating system like Windows 7 compact/embedded/whatever.
-
I made a temporary solution for this bug. Hope microsoft fix this bug quickly.
1、Find a USB cable to connect USB Serial module. (not directly plug USB Serial module to RPI2)
2、Cut USB cable and find +5V line.
3、Use 5V Relay module to control USB Cable +5V line switch.
4、Use GPIO to control 5V Relay module switch.
5、Write a program on app start open GPIO port power ups USB Serial module.
6、Problem solved.
USB Cable like this:http://www.ebay.com/itm/EF-USB-2-0-A-Male-to-A-Female-Extension-Cable-/252055674552?hash=item3aafb05eb8
5V Relay Module like this: http://www.ebay.com/itm/10PCS-1-Channel-5V-Relay-Module-Shield-for-Arduino-uno-1280-2560-ARM-PIC-AVR-DSP-/281394349242?hash=item41846904ba
-
This won't solve our problems but the answer/problem might lie here. MS outsourced the USB stack to MCCI:
Because every ARM SOC implementation has its own set of peripherals (read as: unique to each vendor such as Broadcomm), the drivers are different. This is also why video is not ready.
Gerrit
-
Lion-1981,
I agree with Gerrit. While your proposed solution may work to get the API working, it's not something that we should have to do. And it doesn't actually solve the problem, its more of a work-around.
Thanks for trying to help though.- Edited by Josiah_B Wednesday, September 2, 2015 12:56 AM
-
hmm...
I've been using the 2 USB ports farthest from the Ethernet connector and it doesn't matter which one of those I try. I'm always getting the same result.
But now you have me thinking... I've yet to try the 2 that are closest to the Ethernet connector...
Well, I finally had a chance to try it. No luck. I'm getting the same behavior no matter which port its plugged into. -
when app started use this code:
GpioPinValue: low or high, you can tryit to see effect, and wire follow this picture.private GpioController gpio; private GpioPin gpioPin; public MainPage() { this.InitializeComponent(); this.gpio = GpioController.GetDefault(); if (this.gpio == null) { Debug.WriteLine("GPIO is null."); return; } this.gpioPin = this.gpio.OpenPin(18); this.gpioPin.Write(GpioPinValue.Low); this.gpioPin.SetDriveMode(GpioPinDriveMode.Output);
// make a loop here wait usb serial power up.
// you can use serial device now.
}
-
-
-
So glad I just found this thread, I've been futzing around with this for days thinking I was doing something wrong. I get exactly the same behaviour as Hellthorne. Frustrating that they'd release an OS version that has regressed on their own example projects. I've also noted that my USBSerial device only shows up in the device manager when another USB device is connected to the Raspberry Pi. Buggy as hell, Microsoft are you going to fix this?
-
-
Hello everyone!
We've identified the cause and a resolution for the issue in which SerialDevice.FromIdAsync() returns a null value in Windows 10 IoT Core. This behavior is due to a conflict with a process running by default on the IoT Core device. To resolve this issue, please follow the steps below:
Raspberry Pi 2 and Dragonboard 410c
Windows 10 IoT Core launches a Z-Wave background application at startup and by default. The Z-Wave application will claim a Silicon Labs CP210x device and block other applications from using it. If the Z-Wave application is not being used by your Windows 10 IoT Core applications, it should be removed from the startup list, making the Silicon Labs CP210x devices available as an interface for other applications.
Follow the steps below to resolve this issue:
- Connect to the Windows 10 IoT Core device through SSHor PowerShell
- Run the commandiotstartupremove headless ZWave
- Reboot the device
Minnowboard Max
Windows 10 IoT Core returns an error (Error Code 31) when attempting to access the Silicon Labs serial driver interface because no COM port is defined.
Follow the steps below to resolve this issue:
- Connect to the Windows 10 IoT Core device through SSHor PowerShell
- Ensure the serial device is connected to the Windows 10 IoT Core device
- Run the commandegadd "HKEY_LOCAL_MACHINE\system\controlset001\enum\usb\VID_10C4&PID_EA60\0001\Device Parameters" /v PortName/t REG_SZ /d COM3
- Reboot the device
Calls to SerialDevice.FromIdAsync() will succeed and and retrieve expected results.
- Proposed as answer by Marcus Russell [MSFT]Moderator Thursday, November 12, 2015 10:25 PM
- Edited by Marcus Russell [MSFT]Moderator Thursday, November 19, 2015 10:17 PM
- Marked as answer by Marcus Russell [MSFT]Moderator Monday, November 23, 2015 3:54 PM
- Unmarked as answer by Josiah_B Tuesday, June 20, 2017 6:38 PM
-
Hi
I have a problem with the cp2102.
in the before days i was using the iot v.10.0.2xx(Don't remember the exact reference) and with it i was using the cp2102 fine(Just with the problem of reconnect it after the device boots). but i'm using the iot v.10.0.10556 and the cp2102 is not working, it just work when i run the OS for the first time. after i reboot the cp2102 never turn's on again, i don't know why.I need some help.
Regards.
Oscar.
-
I have a similar problem but it only occurs when I run my app headless on my rpi. I have two versions of my app. The headless version derives from IBackgroundTask, and the headed is derived from Page. When running the headless app case, FromIdAsync() returns null always. Whereas if I run that app headed, FromIdAsync works correctly and I am returned a valid serial port. In both cases the ID string passed to FromIdAsync is the same:
"\\\\?\\FTDIBUS#VID_0403+PID_6015+DA00V7Q8A#0000#{86e0d1e0-8089-11d0-9ce4-08003e301f73}"
Is there something else that I need to set or run in the headless case to get the USB to work correctly? I have tried the work arounds to remove ZWave and plug into different USB ports, but it just doesn't work headless.
Jim
-
I found the solution - simply add these lines to Package.appxmanifest in the <Capabilities> section.
<DeviceCapability Name="serialcommunication">
<Device Id="any">
<Function Type="name:serialPort" />
</Device>
</DeviceCapability>
-
-
THANK YOU Jim198!
This should be in the UsbDevice.FindIdAsync docs. I just wasted about an hour trying to figure out why I was getting null. ...Some exception should also be thrown IMHO.
Anyways, thanks to you I figured out how to make mine work. I'm using my own USB device (a NETMF board) so WinUSB and just the generic interface. I had to add this code...
<DeviceCapability Name="usb">
<Device Id="vidpid:dead 0110">
<Function Type="name:vendorSpecific"/>
</Device>
</DeviceCapability>
It's also frustrating that this wasn't available in the UI. Because I had looked in my App's Package for a USB related setting. There wasn't one.
ALSO, I had to switch to Chrome to make this comment happen. Edge wouldn't work. Pressing backspace from within the textbox the page navigated away. And when I pasted my text was a mess. Of course, it worked perfectly with Chrome.
Seriously Microsoft, get it together!
- Edited by Untitled86 Tuesday, April 26, 2016 7:38 PM wanted to give Jim credit
-
-
You are the men! Jim198
I would like to add to your input, that if I add the DeviceCapability to the uper section of the Capabilities, it have fail.
but if I place it to the end, like this:
<Capabilities> <Capability Name="internetClient" /> <Capability Name="internetClientServer" /> <Capability Name="privateNetworkClientServer" /> <DeviceCapability Name="location" /> <DeviceCapability Name="serialcommunication"> <Device Id="any"> <Function Type="name:serialPort" /> </Device> </DeviceCapability> </Capabilities>
All go fine!
-
-
This [Jim198's answer] fixed my problem.
As an aside, I've been a programmer for 15 years and have never once upvoted anything on this forum.. until just now. So, can anyone tell me why this particular answer, with more than twice the upvotes of any of the others (as far as I can tell), is buried under so many 0-votes and generally unhelpful posts?
- Edited by Scott Garner Tuesday, June 20, 2017 6:33 PM
-
-