runtime icon indicating copy to clipboard operation
runtime copied to clipboard

SerialPort Support on Windows

Open shaggygi opened this issue 11 years ago • 205 comments

Just wondering if SerialPort namespace will be included at some point?


Execution plan

  • [x] 1. @JeremyKuhne to seed the sources in CoreFX (from full .NET Framework) - add source code (sanitized, with licenses), the source won't build
  • [x] 2. Make the code build
    • CC: @JeremyKuhne @karelz on PRs
    • Note: We will not take any functional changes to the implementation, architecture, or API surface at this point unless they are absolutely necessary to make the code compile on .NET Core. Please give heads up on this issue as soon as you discover cases like that.
  • [x] 3. Add tests - tracking progress in dotnet/corefx#15752
    • [x] @JeremyKuhne to find out if we can leverage full .NET Framework tests
    • We need to design the test environment - we need ability to test the code in CI (ideally without heavy modification of CI machines)
    • We need to set goal for code coverage

If anyone is working on any step, please mention it & coordinate here to avoid duplicated effort. @karelz will co-assign the issue to you as well.

shaggygi avatar Feb 22 '15 14:02 shaggygi

:+1: for supporting communication over serial line in corefx. It could be existing SerialPort class however I'd prefer new more reliable api based directly on Stream.

Maxwe11 avatar Feb 22 '15 14:02 Maxwe11

There are a few nuget packages that already provide this capability as there are such a small number of downloads it makes you wonder what the demand is.

sawilde avatar Feb 22 '15 23:02 sawilde

@sawilde could you provide a link for those? I would like to try them out. Thx

shaggygi avatar Feb 23 '15 01:02 shaggygi

http://www.nuget.org/packages?q=serial

sawilde avatar Feb 23 '15 05:02 sawilde

Thx

shaggygi avatar Feb 23 '15 11:02 shaggygi

My general feeling is that Serial Port is not a good long term fit when you think about foundational libraries of .NET Core, and hence we wouldn't include it in the CoreFX project. The current SerialPort class source is MIT licensed now, as part of the .NET Reference Source project, so folks are free to take it an run with it.

In general, I think we'd like CoreFX to be a set of libraries that are useful across the entire .NET ecosystem. That includes devices like Phones, Severs, Tablets where a serial port library is unlikely to be useful.

ellismg avatar Feb 27 '15 07:02 ellismg

Serial Port is not a good long term fit when you think about foundational libraries of .NET Core

.NET ecosystem. That includes devices like Phones, Severs, Tablets where a serial port library is unlikely to be useful.

What the problems to use SerialPort on server? It's a powerful "tool" like pipes or sockets. .NET ecosystem now includes Linux and Mac, but Win32.Registry presented in corefx.

Maxwe11 avatar Feb 27 '15 08:02 Maxwe11

@Maxwe11, I'm interested in understanding more about how serial pots would be used in server scenarios. I can see how both pipes and sockets are useful in general for IPC, what sorts of uses does serial port have?

You're right about CoreFX containing some Win32isms, However, we are doing our best to minimize the set of types that pull in Win32 concepts. The desire to be able to run stacks like ASP.NET vNext requires that we bring in some components that are windows centric and will be hard to support on Linux and Mac, but when possible we are trying to be explicit in the surface area we add to the core, to make sure it's suited for a wide range of platforms and devices.

ellismg avatar Feb 27 '15 11:02 ellismg

@ellismg I can see your point of view on this topic as there were several discussions why serial port capability was not provided out-of-box for WinRT. However, this feature is needed all the time in some industries like building automation. In addition, if corefx is expected to be used with embedded devices, those type of applications use uarts quite a bit.

I would agree it might not need to be included as long as there is a package we can include and hopefully be cross plat as well. Thx

shaggygi avatar Feb 27 '15 11:02 shaggygi

One other note... I've also seen cases where data cables were needed to connect between pc/tablet/phone via USB to devices for serial communications (232, 485). Having this feature would support these types of apps.

shaggygi avatar Feb 27 '15 11:02 shaggygi

I'm interested in understanding more about how serial pots would be used in server scenarios. I can see how both pipes and sockets are useful in general for IPC, what sorts of uses does serial port have?

As mentioned by @shaggygi: for communicating with embedded devices.

Maxwe11 avatar Feb 27 '15 11:02 Maxwe11

I don't recall adding anything about using with servers. If so, it must have been a typo.

shaggygi avatar Feb 27 '15 11:02 shaggygi

+1 for SerialPort, it is still widely used in industrial/embedded systems.

I'm not sure whether we need it in corefx though, having a separate package should be fine too (after all, better modularization is one of the benefits of the new model). Maybe it's time for dotnet/extendedfx :smile:

akoeplinger avatar Feb 27 '15 13:02 akoeplinger

I don't really care if it's from corefx or any other repository as long as it's coming from Microsoft. In the past, that always meant a certain level of quality.

Tragetaschen avatar Feb 27 '15 13:02 Tragetaschen

I agree with @ellismg, this isn't a corefx problem. This is a problem, that begs for a community contribution of a fantastic nuget package!

kangaroo avatar Feb 27 '15 15:02 kangaroo

I don't really care if it's from corefx or any other repository as long as it's coming from Microsoft. In the past, that always meant a certain level of quality.

Agree with it, but for now SerialPort not supported even in PCL

Maxwe11 avatar Feb 27 '15 15:02 Maxwe11

@shaggygi

And not a third-rate quality package

did you check out the nuget packages that are currently available? If not suitable - why not? Could you improve on them?

To create a 'quality' serial port library requires a certain level of knowledge I suspect - who has that knowledge... well those that need a serial port library. There are not many of you out there so rather than wait for someone to build a library, whilst making all the mistakes you would expect from someone learning the domain, perhaps it is something the 'serial port user' community should do - create a github repo and share your knowledge to create the .NET serial port package.

sawilde avatar Feb 27 '15 20:02 sawilde

@sawilde I believe my post was out of context, so I removed it. I'm really content with the API provided in .NET and I'm sure the other packages will probably work. I was just hoping what is provided to work with corefx will be easy to use similar to what I've always used in the past.

shaggygi avatar Feb 27 '15 21:02 shaggygi

As @ellismg said above, the source is available. I've marked this as up-for-grabs. If anybody wants to take a stab, let us know!

terrajobst avatar Sep 15 '15 18:09 terrajobst

I was hoping that .NET on Linux would potentially give me a solution to the problem I'm having with the rather poor implementation of System.IO.SerialPort in Mono. I would note to Sawilde that all of those NuGet packages related to serial communications are either something else or built on top of the SerialPort class. I know of no comprehensive replacement.
My +1 on this, either as part of the core or as an add-on. Whomever works on this, please do not repeat the poor error handling job done by Mono on their implementation. See this bug report for example.

n8allan avatar Oct 25 '15 01:10 n8allan