示例#1
0
 private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
 {
     try
     {
         System.Diagnostics.Debug.WriteLine(e.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
         System.Diagnostics.Debug.WriteLine(ex.ToString());
     }
 }
        //serial port receive in its own thread
        private void sp_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            if (sp.IsOpen)
            {
                try
                {
                    //give it a sec to spit it out
                    System.Threading.Thread.Sleep(50);

                    //read whatever is in port
                    string sentence = sp.ReadExisting();
                    this.BeginInvoke(new LineReceivedEventHandler(SerialLineReceived), sentence);
                }
                catch (Exception ex)
                {
                    WriteErrorLog("GPS Data Recv" + e.ToString());

                    MessageBox.Show(ex.Message + "\n\r" + "\n\r" + "Go to Settings -> COM Ports to Fix", "ComPort Failure!");
                }

            }

        }
示例#3
0
        public void Roomba_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            //m_bRCV_Err = false;

                //Read existing here when not polling
                string m_sReturn = e.ToString() + DateTime.Now.ToString();
                //m_iBytesToRead = Program.UI.CurrentRoomba.IO.BytesToRead;
                //m_sReturn = Program.UI.CurrentRoomba.IO.ReadExisting();

                //MessageBox.Show(m_sReturn);

                //this.UpdateForm();

                //this.pSensorRCV.BackColor = Color.Green;
                //if (this.chkFlashStatus.Checked)
                //{
                //    this.m_bTextRecieved = true;
                //    this.SetCommStatus();
                //}; //Feedback to Roomba to show that we have communication

                //g_sRCV  = this.CurrentRoomba.IO.ReadExisting();
                ////int iBytesToRead = this.CurrentRoomba.IO.BytesToRead;

                //this.SetText();

                //Application.DoEvents();
        }