473,769 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5532
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*******@disc ussions.microso ft.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******** ******@cpmsftng xa06.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
5055
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', '\0', '\1', 'Z', '0', '0',
4
11792
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 you open a serial port. This is not what I want to do. I need to change the timeout each time I do a "read" on the serial port, depending on which part of the protocol I've got to. Sometimes a return character is expected within half a second,...
0
4566
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. public partial class SMS : Form { //create an Serial Port object SerialPort sp = new SerialPort(); public SMS() {
1
3648
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 System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO.Ports; using System.Threading;
1
4296
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 axes output) from the output. I use hyperterminal with the below settings and it works fine: baudrate=115200 databits=8
0
9420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9851
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.