void Connect() { spList.Connect(); var st = spList.Port; //st.FrameSize = 8; if (st == null) { return; } // 需要考虑UI线程 st.Disconnected += (s, e) => this.Invoke(Disconnect); // 发现USB2401端口,自动发送设置命令 if (st.Description.Contains("USB2401") || st.Description.Contains("USBSER")) { var cmd = "AT+SET=00070000000000"; st.Send(cmd.GetBytes()); //XTrace.WriteLine(cmd); TextControlLog.WriteLog(txtReceive, cmd); } "连接串口{0}".F(st.PortName).SpeechTip(); btnConnect.Text = "关闭"; BizLog = TextFileLog.Create("SerialLog"); var cfg = XConfig.Current; cfg.ColorLog = cbColor.Checked; cfg.Save(); }
void OnReceived(Object sender, StringEventArgs e) { var line = e.Value; //XTrace.UseWinFormWriteLog(txtReceive, line, 100000); TextControlLog.WriteLog(txtReceive, line); if (BizLog != null) { BizLog.Info(line); } }
void Connect() { spList.Connect(); var st = spList.Port; //st.FrameSize = 8; // 需要考虑UI线程 st.Disconnected += (s, e) => this.Invoke(Disconnect); // 发现USB2401端口,自动发送设置命令 if (st.Description.Contains("USB2401") || st.Description.Contains("USBSER")) { var cmd = "AT+SET=00070000000000"; st.Send(cmd.GetBytes()); //XTrace.WriteLine(cmd); TextControlLog.WriteLog(txtReceive, cmd); } btnConnect.Text = "关闭"; BizLog = TextFileLog.Create("SerialLog"); }