Read and write from a serial port using c#

  • Thread starter Thread starter =?iso-8859-1?Q?Daniel_=C5berg?=
  • Start date Start date
?

=?iso-8859-1?Q?Daniel_=C5berg?=

I can't find how I can, in c#, open a serial port and
read and write to it. Anyone that knows if there is any
namespace with methods or code example.
 
I don't believe there is any direct framework support for
this, so you are stuck using a third-party library (check
for serial classes on a site like codeguru.com) or
interfacing directly using Windows API calls (Createfile,
Readfile, Writefile, etc).

Darcy
 
Thanks for a quick reply. I still hope framework has
support for it because I realy need it. Anyone else that
are sure framework support it or not.
 
Hello Daniel,

Thanks for posting in the group.

Darcy and Patrik are right. There is no direct framework class to develop
serial port application. We need to use PInvoke to call Win32 APIs to
achieve it. Some developers even wrapper all the related APIs in a .NET
class library, just as what Patrik posted. You could refer to it for code
samples.

By the way, if you don't want to expose your real email address in the
group to avoid spam virus email, you could register a no spam alias at:
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Yet another gaping hole the size of the DeathStar in .NET.

Play the Spot The Gap doorstep challenge!!!
 
:)

You are welcome. Also thanks to Darcy and Patrik for their contribution in
the thread.

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top