Open shaggygi opened 7 years ago
@los93sol can you explain the hacks that you needed to do in System.IO.Ports? UWP serial ports should work except for port enumeration, but you mention that you are trying to do it from .NET core, could you explain a bit of the scenario?
That’s correct, UWP does work but I’m running an ASP.NET core site on my iot device. I’ve done a lot of hacking around, I modified System.IO.Ports and would manually copy that DLL over to eliminate the check that the name starts with COM. I also hacked up MVC and leveraged the new Razor SDK to be able to host an ASP.NET core site in a UWP app but developing that way is terrible. If I could just use SerialPort from .net core’s API life would be good.
Thanks @los93sol that makes more sense to me now. We have some PRs to bring IO.Ports to Unix, however, it seems that in your case a more general solution will be the ability to use UWP APIs, in general, from .NET Core.
[EDIT: remove incorrect statement about .NET Core IO.Ports, change it to refer to PRs]
@pjanotti this is great news to hear regarding bringing "IO.Ports to .NET Core"!. Understanding there are priorities and such, do you know of an ETA to do so? There is something I was just looking at over the weekend that needs SerialPort for Linux and right now I'm limited to use with Windows based on the earlier work from dotnet/runtime#14275. Thx
I second that
There are two related PRs https://github.com/dotnet/corefx/pull/29033 and https://github.com/dotnet/corefx/pull/28415 to bring it to Unifx - @wfurt can better indicate the status of these 2.
@pjanotti To clarify, I am running Windows IOT core on my iot device. I’m a bit confused because system.io.ports is already available in .net core. Are you referring to bringing the UWP API’s to .net core?
I stated it wrongly: it is on .NET Core but only works on Windows, PNSE on others - that's what I meant (editing the previous statement to avoid confusion).
Are you referring to bringing the UWP API’s to .net core?
Not "bringing" them to .NET Core, but, making you able to call them from any .NET Core app - a kind of interop to UWP. To be fair I haven't looked into it and I am not sure if it can be done and what may be required.
Okay, that makes sense. If you can point me to how Windows iot core is detected in source somewhere I will submit a PR with the changes so that the current System.IO.Ports will work there. I can’t submit what I have working currently as it will break other scenarios.
I'm also interested in using System.IO.Ports on Windows IoT (on RPI) using .NET Core. It was very confusing for me that Microsoft creates nuget that is in .NET Standard but is not working on its own windows (IoT). Is this platform is still in interest of company or it is going to be shut down and Linux will be the only system on RPI because now I have impression that MS is pushing in other directions and this part will share Windows Phone. @los93sol Can you share your code for handling UART on RPI?
Sort of off topic ... But I gave up on Windows IoT. The serial port support was one of the main reasons (but not the only reason). I am now using .NET Core on Raspbian. There is a great "clone" library for System.IO.SerialPort that works great.
cc @richlander
Looks like (we?) dropped the ball here and never fixed this. I am setting up an official Windows IoT run(*) and this test is failing there dotnet/corefx#35722.
(*) we have still not declared formal support but the test results otherwise look good.
So I got a proof of concept working, and the short of it is that QueryDosDevice does pick up the ports (with the naming scheme seen in UWP). After relaxing SerialStream's requirement for a "COM*" port name, it seemed to communicate normally as well.
I'd like to share more of what I've found and eventually make a pull request, but before really getting into it, I'd like to confirm whether here or a new issue would be a better for this.
Hi , Did you end up submitting PR for your test? As I cant find it so far?
@PRIMETSS did your commit make it to an official PR?
Ping: do I understand correctly that this issue remains unresolved as of today? Thanks already for your hard work 💛
I had (from memory) a near complete PR in the corefx repo, before the repos got up-shifted to the new 'runtime' repos that addressed the issue with SerialPort names on Win10IoT that I believe was working. We were trying to complete it but ran out of time as the deadline expired & also something else happened like new version announced or something like that. Apologies! Never got back to it.
Just tried it with Pi with dotnetcore v5.0.0403 (latest) on Linux (Raspbian) [Works as expected], and Win10IoTCore [Broken] Calling SerialPort.GetPortNames() returns garbage characters from un-initialised RegistryKey.
# of Ports: 1 Ports: 줄膉敖苭ၔ裓藀↑☺쀀器苭竁腽﨔苭陉腽☻က蔀뤂诅ꂀ膉☺뤂诅煮苭虵腶媗㼡媗㼡難苭螿腶♥槐쀢☺變苭璛腴敖苭쭐膉倀㼡☺ဈ裓槔쀢ৈজজঀজঀ觖♦"뀴謣■&苭疃謣觖♦
Is that what your experiencing @danineuss ?
Basically it's doing an Interop call to Interop.Kernel32.QueryDosDeviceW()
@PRIMETSS
Yes exactly, this is what I could observe as well. First we tried using a specific class of FTDX_NET
, but that caused other issues. I reverted to using SerialPort.GetPortNames()
and indeed, using the libftdi-dev
drivers, I managed to run it on a Raspbian installation. Win10IoTCore seems broken for me as well.
This issue was created to continue the discussion on further support of SerialPort related APIs for other platforms/devices. You can see related issues below:
Serial Port support on Windows Serial Port support on Unix/OSX
I actually don't know what the ultimate expectation is for this topic as I hope others would chime in with better scenarios. This will hopefully help contributors understand requirements when improving the APIs to support said features.
For example, what does "support on RPi" really mean? If it runs under Windows IoT, does that mean support for UWP? If support comes for Unix/OSx, does that mean the APIs will work running on Alpine/Ubuntu? And how about Docker support?
There were also discussions on using the on-board UART or using USB (e.g. FTDI, etc.) dongles.
Community, please add thoughts to get SerialPort APIs working in other areas in addition to Windows.
Thanks in advance.
FYI... @willdean @JeremyKuhne @karelz @danmosemsft