473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Read and write from a serial port using c#

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.
Nov 22 '05 #1
8 5504
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
-----Original Message-----
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.
.

Nov 22 '05 #2
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.
-----Original Message-----
I don't believe there is any direct framework support forthis, so you are stuck using a third-party library (checkfor serial classes on a site like codeguru.com) or
interfacing directly using Windows API calls (Createfile,Readfile, Writefile, etc).

Darcy
-----Original Message-----
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.
.

.

Nov 22 '05 #3
Here is a link to an MSDN Mag article that discusses some
techniques to access the serial port. Unfortunately it
seems to confirm the lack of direct support in the
framework.
http://msdn.microsoft.com/msdnmag/is...0/NETSerialCom
m/

A search in Google will also yield a lot of commercially
available classes if you are developing this for a
business need.

HTH,
Darcy
-----Original Message-----
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.
-----Original Message-----
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
-----Original Message-----
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.
.

.

.

Nov 22 '05 #4
There's a sample class that works with COM interop to achive the serial port
functionality on gotdotnet.com [1]

--
Patrik Löwendahl
cshrp.net - " Elegant code by witty programmers "
cornerstone.se - " IT Training for professionals "

Mind line wraps

[1]
http://www.gotdotnet.com/Community/U...f-0045b0c79ec7

<an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
Here is a link to an MSDN Mag article that discusses some
techniques to access the serial port. Unfortunately it
seems to confirm the lack of direct support in the
framework.
http://msdn.microsoft.com/msdnmag/is...0/NETSerialCom
m/

A search in Google will also yield a lot of commercially
available classes if you are developing this for a
business need.

HTH,
Darcy
-----Original Message-----
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.
-----Original Message-----
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

-----Original Message-----
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.
.

.

.

Nov 22 '05 #5
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...sdn/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.

Nov 22 '05 #6
Yet another gaping hole the size of the DeathStar in .NET.

Play the Spot The Gap doorstep challenge!!!

"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message
news:Y0**************@cpmsftngxa06.phx.gbl...
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...sdn/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.

Nov 22 '05 #7
Thanks a lot. I have now a couple of suggestions that I
will start to test.

/Daniel
-----Original Message-----
Hello Daniel,

Thanks for posting in the group.

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

By the way, if you don't want to expose your real email address in thegroup 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.
.

Nov 22 '05 #8
:)

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.

Nov 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0',...
4
by: rowan | last post by:
I'm writing a driver in Python for an old fashioned piece of serial equipment. Currently I'm using the USPP serial module. From what I can see all the serial modules seem to set the timeout when...
0
by: ghjk | last post by:
I want to read sms from GSM modem using C# in serial communication. I wrote the code. But i want to do it automatically. I put my code here and please tell me how can i do it automatically. ...
1
by: ghjk | last post by:
I'm write code to read data from GSM modem. but it couldn't read modem response. Could you please help me? I'll post my code. using System; using System.Collections.Generic; using...
1
by: rfarley | last post by:
Hi, I am using the pyserial module and am trying to read the serial port from an accelerometer (LIS302DL). It has an option in which you write "*debug\r\n" and then you read the data (three...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.