串口控件使用 错误
金蝶云社区-tangpan
tangpan
1人赞赏了该文章 1,390次浏览 未经作者许可,禁止转载编辑于2015年07月15日 17:43:31

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);