How to import the Windows serial communication structure into Visual C#.NET

  • Thread starter Thread starter Vidya Bhagwath
  • Start date Start date
V

Vidya Bhagwath

Hello Experts,
I am porting the C++ code into the Visual C#.NET. My C++ code is
mainly based on the serial communication. So I am using the windows
structure such as DCB.. etc and the windows functions frequently in my
C++ code. I came to know how to import the windows functions into
Visual C#.NET. But what is the method to import windows structure into
Visual C#.NET?

It will be very helpful for me if anybody can give me the WebID that
has information regarding importing the windows functions and the
structure into the Visual C#.NET

Thanks in advance for any help.

Regards,
Vidya Bhagwath
 
Hi,

Take a look at an article from MSDN magazine that explain how to interact
with the serial port.

cheers,
 
Hi..

Also, the "general" answer to this is to see DllImport documentation. The
doc explains how you need to "reconstruct" C/C++ structures in C# to
manipulate them correctly. The Marshal class (under the covers) takes care
of passing the data correctly between unmanaged (C/C++) and managed (C#)
code.

John Puopolo
 
Vidaya, Could U please send me the class for the same...

Dear expert,

I am tring to communicate with a serial port. and I am using C# with .NET 1.1
and machine is XP. I have HSM(Host security module by THALES) to connect
with the following settings...

m_CommPort_obj.BaudRate = 9600;
m_CommPort_obj.ByteSize = 8;
m_CommPort_obj.Parity = 2;
m_CommPort_obj.PortNum = 1;
m_CommPort_obj.ReadTimeout = 100;
m_CommPort_obj.StopBits = 1;

I am using http://www.aciss.com/justin/JustinIO.zip, a class for the comm
and I am able to open, write on the port But unable to read the data from it.
Could anybody suggest, whats wrong with the code or settings ? and on which
bemt I should read.?

I do not want to use MSCOmm.ocx. Actually i am looking for the " running
code" in .NET(vb or C#) having method sends and receive data from the serial
port. On google, I have gone through almost all the link and get a lots of
code..... but not running, if running ... its with a lots of error. So if U
have tested code please give me the calss at least so that I can work with.

Thanks in ur anticipation
Reply me on "(e-mail address removed)" and (e-mail address removed)
Rakesh.
 
Back
Top