using
namespace
{
[StructLayout(LayoutKind.Sequential)]
}
[DllImport("kernel32.dll")]
(
);
DCB dcbCommPort =
COMMTIMEOUTS ctoCommPort =
hComm = CreateFile( "COM" + PortNum ,GENERIC_READ | GENERIC_WRITE,0, 0,CREATE_ALWAYS ,0,0 );
GetCommTimeouts(hComm,
ctoCommPort.ReadTotalTimeoutConstant = 0;
ctoCommPort.ReadTotalTimeoutMultiplier = 0;
ctoCommPort.WriteTotalTimeoutMultiplier = 0;
ctoCommPort.WriteTotalTimeoutConstant = 0;
SetCommTimeouts(hComm,
GetCommState(hComm,
dcbCommPort.BaudRate = BaudRate;
dcbCommPort.flags = 0;
dcbCommPort.flags = 2;
dcbCommPort.Parity = Parity;
dcbCommPort.ByteSize = ByteSize;
dcbCommPort.StopBits = StopBits;
Opened =
CloseHandle(hComm);
MemoryStream stream =
OVERLAPPED ovlCommPort =
stream.Read(BufBytes,0,BytesRead);
WriteFile(hComm, WriteBytes, WriteBytes.Length,
}This is my class 2
port CommPort =
CommPort.Open();
{/*call write function*/
/*call read function*/
Console.WriteLine( sBuffer.ToString() );