private void Form1_Load(object sender, EventArgs e) { serialport = LLSerialPortFactory.CreateInstance("LLSerialImplement"); //create the instance serialport.OpenSerialPort("COM3"); //open the serial port serialport.DataUpdated += (s, data) => { //data come event richTextBox1.UISafeSet(() => { foreach (var item in data.SerialData) { richTextBox1.AppendText("0x" + item.ToString("X") + "\t");//hex display } richTextBox1.AppendText("\n"); }); }; }
/// <summary> /// the Serial implement name /// </summary> /// <param name="SerialName"></param> /// <returns></returns> public static LLSerialPort CreateInstance(string SerialName) { _llserial = (LLSerialPort)Assembly.Load("SerialPortEX").CreateInstance("SerialPortEX." + SerialName); return(_llserial); }