SerialPort mySerialPort = new SerialPort();
mySerialPort.RtsEnable = true;
mySerialPort.PortName = "COM2";
mySerialPort.BaudRate = 9600;
mySerialPort.Parity = 0;
mySerialPort.DtrEnable = true;
mySerialPort.ReceivedBytesThreshold = 1;
//if (mySerialPort != null)
// {
// if (mySerialPort.IsOpen)
// {
// mySerialPort.Close();
// }
// }
mySerialPort.Open();
mySerialPort.WriteLine("hello");
// this.View.GetControl("F_XFF_SerialPortCtrl").InvokeControlMethod("open");
this.View.GetControl("F_XFF_SerialPortCtrl").InvokeControlMethod("Init", mySerialPort);
mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
推荐阅读