Esempio n. 1
0
        void Serial_SerialDataReceivedCompleteEventHandler(object obj, SerialPort.SerialDataReceivedCompleteEventArgs arg)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var item in arg.Data)
            {
                sb.Append(item.ToString("X") + " ");
            }
            log.Write("接收到数据:" + sb.ToString());

            communication_RecevieResultEvent(arg.Data);
        }
Esempio n. 2
0
        void serial_SerialDataReceivedCompleteEventHandler(object arg1, SerialDataReceivedCompleteEventArgs arg2)
        {
            StringBuilder str  = new StringBuilder();
            MySerialPort  prot = (MySerialPort)arg1;

            if (radioButton1.Checked)
            {
                arg2.Data.Any <byte>(by => { str.Append(by.ToString("X2") + " "); return(false); });
            }
            else if (radioButton2.Checked)
            {
                arg2.Data.Any <byte>(by => { str.Append(by.ToString() + " "); return(false); });
            }
            else
            {
                str = new StringBuilder(encodingInfo.GetEncoding().GetString(arg2.Data));
            }

            this.Invoke(new Action(() => this.textBox1.Text = prot.PortName + "接收到数据--------->\r\n" + str.ToString() + "\r\n"));
        }
Esempio n. 3
0
 private void Serial_SerialDataReceivedCompleteEventHandler(object obj, SerialPort.SerialDataReceivedCompleteEventArgs arg)
 {
     Analysis(arg.Data);
 }