Discussion:
Serial Communication in C#
(too old to reply)
Guy Dillen
2003-07-11 20:47:31 UTC
Permalink
Anyone has examples of urls to (good) examples of serial communication in C#

Thanks.

Guy
Thomas Scheidegger [MVP]
2003-07-11 21:03:32 UTC
Permalink
My Serial Port FAQ:

.NET 1.0/1.1 has no support for legacy ports (COM/LPT).

There are plans to add support for serial ports in a future version:
http://groups.google.com/groups?&selm=O%23vQLn9bCHA.392%40tkmsftngp09
"this sample is very similar to what we will be adding" :
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialPort
(note, project built with beta VS.NET, read gotdotnet comment)

Future Directions for Visual C#
http://msdn.microsoft.com/chats/vstudio/vstudio_032103.asp
"We will add support for Serial ports to the framework..."


With 1.0/1.1 you have to use PInvoke or Interop :

First understand the Win32 API as described here (C++):
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp

MSDN article for .NET (mostly C#):
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/

PInvoke samples for C#:
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialPort
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialStream

or for VB.NET:
http://msdn.microsoft.com/library/en-us/dnvssamp/html/vbcs_usingthecomportinvbnet.asp
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=rs232
http://www.allapi.net/classlib/class.php?id=15
http://www.corradocavalli.cjb.net/

or you can use the "Managed Extensions for C++" and write wrappers.
http://msdn.microsoft.com/library/en-us/vcmex/html/vcconMCOverview.asp
http://www.gotdotnet.com/team/cplusplus/
http://msdn.microsoft.com/library/en-us/dncscol/html/csharp12192002.asp
on your VS.NET path:
...\VC7\managedextensionsspec.doc
...\VC7\migration_guide.doc
MC++ Sample:
http://www.codeproject.com/managedcpp/howtocomport.asp

or reusing the VB6 MSComm ActiveX is easy, but it has some 'problems' (license)
http://support.microsoft.com/?kbid=318597
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320
http://ourworld.compuserve.com/homepages/richard_grier/NETCommOCX.htm

commercial:
http://www.sax.net/dotnet/communications/
http://www.winsoft.sk/ncomport.htm

for Compact Framework (Windows CE)
http://ourworld.compuserve.com/homepages/richard_grier/CFSerial.htm

for Interop, use newsgroup:
microsoft.public.dotnet.framework.interop
--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_dotnet.html - http://dnetmaster.net/
Guy Dillen
2003-07-11 21:15:36 UTC
Permalink
Thx for the info.

Sorry i forgot to mention that i'm aware that i must implement it with using
the Win32 API. But where can i find some examples (especially about
marshalling pointer types).

Guy
Post by Thomas Scheidegger [MVP]
.NET 1.0/1.1 has no support for legacy ports (COM/LPT).
http://groups.google.com/groups?&selm=O%23vQLn9bCHA.392%40tkmsftngp09
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialPort
Post by Thomas Scheidegger [MVP]
(note, project built with beta VS.NET, read gotdotnet comment)
Future Directions for Visual C#
http://msdn.microsoft.com/chats/vstudio/vstudio_032103.asp
"We will add support for Serial ports to the framework..."
http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialPort
Post by Thomas Scheidegger [MVP]
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialStream
http://msdn.microsoft.com/library/en-us/dnvssamp/html/vbcs_usingthecomportinvbnet.asp
Post by Thomas Scheidegger [MVP]
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=rs232
http://www.allapi.net/classlib/class.php?id=15
http://www.corradocavalli.cjb.net/
or you can use the "Managed Extensions for C++" and write wrappers.
http://msdn.microsoft.com/library/en-us/vcmex/html/vcconMCOverview.asp
http://www.gotdotnet.com/team/cplusplus/
http://msdn.microsoft.com/library/en-us/dncscol/html/csharp12192002.asp
Post by Thomas Scheidegger [MVP]
...\VC7\managedextensionsspec.doc
...\VC7\migration_guide.doc
http://www.codeproject.com/managedcpp/howtocomport.asp
or reusing the VB6 MSComm ActiveX is easy, but it has some 'problems' (license)
http://support.microsoft.com/?kbid=318597
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=320
http://ourworld.compuserve.com/homepages/richard_grier/NETCommOCX.htm
http://www.sax.net/dotnet/communications/
http://www.winsoft.sk/ncomport.htm
for Compact Framework (Windows CE)
http://ourworld.compuserve.com/homepages/richard_grier/CFSerial.htm
microsoft.public.dotnet.framework.interop
--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_dotnet.html - http://dnetmaster.net/
Continue reading on narkive:
Loading...