C#通信串口类
以前做过一段时间短信研究,找到一牛人写串口类,调试链接COM接口是成功的。 代码 1 using System; 2 using System.Runtime.InteropServices; 3 4 namespace OPE 5 { 6 public class JustinIO 7 { 8 public class CommPort 9 { 10 11 public string PortNum; 12 public int BaudRate; 13 public byte ByteSize; 14 public byte Parity; // 0-4=no,odd,even,mark,space 15 public byte StopBits; // 0,1,2 = 1, 1.5, 2 16 public int ReadTimeout; 17 public string CenterNumber; 18 19 // comm port win32 file handle 20 private int hComm = - 1 ; 21 22 public bool Opened = false ; 23 24 // win32 api constants 25 private const uint GENERIC_READ = 0x80000000 ; 26 private