Click to See Complete Forum and Search --> : Is serial communication possible in .NET


mahvk
January 3rd, 2003, 10:35 AM
Hello All,

I was just searching for classes for communicating with
the COM port. But I can't find any such classes/methods in the
.NET framework other than the API functions.

And also I am not sure how to make use of these API functions
in my .NET application.
For example one of the API function, CreateFile has
LPSECURITY_ATTRIBUTES structure as one of the parameter, how
I can declare/use this particular method in my .NET application.

Can you please help me out !!!

Regards,

Andreas Masur
January 3rd, 2003, 10:51 AM
I am not sure whether the regular API functions are not any longer available or you just did not find them...

Depending on what you are trying to do take a look at the functions

BuildCommDCB()
ClearCommError()
CreateFile()
EscapeCommFunction()
GetCommModemStatus()
GetCommState()
GetCommTimeouts()
GetOverlappedResult()
ReadFile()
SetCommMask()
SetCommTimeouts()
WaitCommEvent()
WriteFile()

Additionally, the MSDN (http://msdn.microsoft.com) provides a detailed article about serial communication in Windows. Open MSDN, choose Index and type "Serial Communications". There are several subitems, choose 'Win32'... (it's also online available at http://msdn.microsoft.com/ library/d...s/dnwbgen/html/ msdn_serial.asp).

You probably might wanna take a look at http://msdn.microsoft.com/library/d...tm/serial_7.asp...

Andreas Masur
January 3rd, 2003, 11:52 AM
Originally posted by mahvk
And also I am not sure how to make use of these API functions
in my .NET application.
For example one of the API function, CreateFile has
LPSECURITY_ATTRIBUTES structure as one of the parameter, how
I can declare/use this particular method in my .NET application.

Well...if you include the appropriate header file and the libraries which are stated within the MSDN there should not be any problems...

MartinL
January 9th, 2003, 06:24 AM
I afraid, there is no class to manipulate COM port in .net framework.

You have two choices:
1.) Import all function you need to work with COM port to the .net application. (DllImport()...)

2.) Write COM object in C++ that will allow you to use COM port and use that COM object from you .net application

mahvk
January 9th, 2003, 10:44 AM
Hello All,

I am able to make use of APIs to communicate with the serial port.
It works pretty fine.

Thanks a ton to everyone.

Regards,

albusorin
January 10th, 2006, 03:09 AM
Hello!
You said that u make that API work perfect. Can u tell us what API, and how do u use it!

Thanks

Shuja Ali
January 10th, 2006, 04:25 AM
Hello!
You said that u make that API work perfect. Can u tell us what API, and how do u use it!

Thanks
There is a nice sample present on MSDN on how to communicate with COM Ports. Take a look at Using the COM Port in VB.NET (http://www.microsoft.com/downloads/details.aspx?FamilyID=075318ca-e4f1-4846-912c-b4ed37a1578b&displaylang=en).

Download this sample and it contains all the APIs and their implementation in .NET.

K Nemelka
January 10th, 2006, 01:15 PM
Hi

I got my C# app running in 10 minutes with the following serial communications approach:


http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320

Ken Nemelka