Пример #1
0
 /// <summary>
 /// Trigger the event Data Received
 /// </summary>
 /// <param name="args"></param>
 public void onDataReceived(Valutech.IO.SerialDataReceivedEventArgs args)
 {
     if (DataReceived != null)
     {
         DataReceived(this, args);
     }
 }
Пример #2
0
        /// <summary>
        /// Take action based on the serial data received
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void serial_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            string indata = ReadExisting();

            bufferData += indata;
            if (bufferData.IndexOf(END_OF_LINE) >= 0)
            {
                string[] messages = bufferData.Split(END_OF_LINE);
                string   message;
                bufferData = (messages.Length > 1) ? messages[messages.Length - 1] : String.Empty;
                for (int i = 0; i < messages.Length - 1; i++)
                {
                    message = messages[i];
                    Valutech.IO.SerialDataReceivedEventArgs args = new Valutech.IO.SerialDataReceivedEventArgs();
                    args.Text = message;
                    onDataReceived(args);
                    //Debug.Print("Received: " + message);
                }
            }
            ;
        }