Пример #1
0
        void _spManager_NewSerialDataRecieved(object sender, SerialDataEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new EventHandler <SerialDataEventArgs>(_spManager_NewSerialDataRecieved), new object[] { sender, e });
                return;
            }
            int maxTextLength = 1000; // maximum text length in text box

            if (tbData.TextLength > maxTextLength)
            {
                tbData.Text = tbData.Text.Remove(0, tbData.TextLength - maxTextLength);
            }
            string readData = Encoding.ASCII.GetString(e.Data);

            tbData.AppendText("Read on " + inPortNameComboBox.Text + " : " + readData + "\r\n");
            tbData.AppendText(_spManager.Check(readData) + "\r\n");
            tbData.ScrollToCaret();
        }