RS232 class

  • Thread starter Thread starter Przemo
  • Start date Start date
P

Przemo

Hi,

Do you know some good RS232C class? There is one in
VB.NET 101 Examples, but I think it is poor.

1.
I can't for e.g. read into my application all data
received. I must tell how many bytes I would like to
read. If I specify too many exception occures, if too
less there are still some data in buffer.

2.
I use a GPS receiver which send data by RS232. Every line
end with codes 10 and 13. I would like to read from RS232
Class one, or more such lines of data. But full lines! I
have noticed that this class gives me what it has -
sometime partial data.
Is it a spoecific thing about RS232 serial transmition or
only of this class?

Thanks.

Przemo
 
Do you know some good RS232C class? There is one in
VB.NET 101 Examples, but I think it is poor.



My Serial Port FAQ:

..NET 1.0/1.1 has no support for legacy ports (RS-232/COM/LPT).
It will be included in .NET 2.0 (2005)

.NET 2.0 Beta 1 Documentation:
http://lab.msdn.microsoft.com/library/en-us/cpref/html/N_System_IO_Ports.asp
Serial Support in Whidbey Demo:
http://www.gotdotnet.com/team/clr/bcl/demos/demos.aspx



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/...mpleGuid=9dde5cf3-4842-4d4b-baa7-73e09c4d5890
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialStream
http://www.gotdotnet.com/Community/...mpleGuid=5a96c071-e9e8-47c4-bb9e-5413384f0c25

or for VB.NET:
http://support.microsoft.com/?kbid=823179
http://msdn.microsoft.com/library/en-us/dnvssamp/html/vbcs_usingthecomportinvbnet.asp
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=rs232
http://www.mentalis.org/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

for the Compact Framework (Windows CE)
http://msdn.microsoft.com/library/en-us/dnnetcomp/html/PISAPICF.asp
http://www.microsoft.com/downloads/details.aspx?FamilyID=206645de-63ba-4e49-b9a3-2d3b9cef4aa5
http://ourworld.compuserve.com/homepages/richard_grier/CFSerial.htm

commercial:
http://www.sax.net/dotnet/communications/
(Community edition in : http://msdn.microsoft.com/vbasic/vbrkit/ )
http://www.winsoft.sk/ncomport.htm
http://www.charonsoftware.com/net/communications/
http://www.scientificcomponent.com/portcontroller_net.htm
http://www.aftek-software.com/CommControl.htm
http://www.componentscience.net/Elements/TransPort/
http://franson.biz/serialtools/

for Interop, use newsgroup:
microsoft.public.dotnet.framework.interop
 
Przemo,

Will you be so kind not to multipost. Now you have three very good answers
one in the newsgroup dotnet.general and two in the newsgroup languages.vb.

However readers of those newsgroup see only one or two.

Use instead of this crossposting, than everybody sees three answers and can
use those. (crossposting sending one message to more newsgroup in one time).

Thanks in advance.

Cor
 
Really nioce, and I have now like 10 RS232 sample applications, some seem to
work fine, other doesn't really do anything.
Which one is THE RS232-software?

thanks, Pieter
 
Really nioce, and I have now like 10 RS232 sample applications, some seem to
work fine, other doesn't really do anything.

yes I know, some even have critical bugs in threading,
buffer handling, timeout handling, overlapped-IO...


Which one is THE RS232-software?


My recommendation:
- understand the basic working of the Win32 COMM APIs.
- learn the basic rules of .NET PInvoke.

For selecting a solution:
it depends on the kind of communication you have to implement.
Sometimes simple code for opening the port and
synchronous ReadFile/WriteFile is all you need.
Or do you want to use COMM-events?
working with threads? asynchronous-IO?
special timeout handling?

There is no single, optimal sample for all this
different requirements.
 
Which one is THE RS232-software?
My recommendation:
- understand the basic working of the Win32 COMM APIs.
- learn the basic rules of .NET PInvoke.

For selecting a solution:
it depends on the kind of communication you have to implement.
Sometimes simple code for opening the port and
synchronous ReadFile/WriteFile is all you need.
Or do you want to use COMM-events?
working with threads? asynchronous-IO?
special timeout handling?

There is no single, optimal sample for all this
different requirements.

I have to do some communications with an SMS-Modem (AT-commands): So jsut
simple Opening, and Read and Write. Events aren't really necessary...

Any tips would be great :-)
 
Back
Top