How to call to MAIN
-
Hi all!i am using microsoft visual studio.net 2003.i have create a class for communication with serial port via RS-232.It contains read and write function.i run this in the console application.Class 1 is all the function and class 2 is my MAIN.i use Main to call the read and write function.Can someone please please help me how i can read unlimited bytes?How to call the Public MemoryStream Read(int bufSize) to my MAIN?I try it so many time but still fail to do it..Please please help me..Thanks a lot! This is my Class 1 using System; using System.Runtime.InteropServices; using System.IO; using System.Text; using System.Globalization; using System.Threading; namespace yong { public class port { /*-- Definition of variables by Programmer --*/ /*-- Setting win32 API constants --*/ private const uint GENERIC_READ = 0x80000000; private const uint GENERIC_WRITE = 0x40000000; private const int CREATE_ALWAYS = 2; private const int INVALID_HANDLE_VALUE = -1; /*-- End ofSetting win32 API constants --*/ public int PortNum = 1; //-------------Delaring of Port number to 1 public int BaudRate = 9600; //---------Set BaudRate to 9600 public byte ByteSize = 8; //-----------Set ByteSize to 8 public byte Parity = 0; //-------------0-4 = no,odd,even,mark,space public byte StopBits = 0; //-----------0,1,2 = 1, 1.5, 2 public int ReadTimeout = 1500; //------Set TimeOut to 1500 private int hComm = -1; //-------------Declaring of comm port win32 file handle public bool Opened = false; //---------Declaring of Opened and set to false /*-- End of Definition of variables by Programmer --*/ [StructLayout(LayoutKind.Sequential)] public struct DCB { /*-- taken from c struct in platform sdk --*/ public int DCBlength; //-----------Sizeof(DCB) public int BaudRate; //------------Current baud rate public uint flags; //--------------Flags public ushort wReserved; //--------Not currently used public ushort XonLim; //-----------Transmit XON threshold public ushort XoffLim; //----------Transmit XOFF threshold public byte ByteSize; //-----------Number of bits/byte, 4-8 public byte Parity; //-------------0-4 = no,odd,even,mark,space public byte StopBits; //-----------0,1,2 = 1, 1.5, 2 public char XonChar; //------------Tx and Rx XON character public char XoffChar; //-----------Tx and Rx XOFF character public char ErrorChar; //----------Error replacement character public char EofChar; //------------End o