473,320 Members | 1,572 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,320 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 5497
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.