当前位置: 首页>>代码示例>>C#>>正文


C# Ports.SerialDataReceivedEventArgs类代码示例

本文整理汇总了C#中System.IO.Ports.SerialDataReceivedEventArgs的典型用法代码示例。如果您正苦于以下问题:C# SerialDataReceivedEventArgs类的具体用法?C# SerialDataReceivedEventArgs怎么用?C# SerialDataReceivedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SerialDataReceivedEventArgs类属于System.IO.Ports命名空间,在下文中一共展示了SerialDataReceivedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: port_DataReceived

 public static void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     if (e.EventType == SerialData.Chars)
     {
         receiveNow.Set();
     }
 }
开发者ID:mangmaytinh,项目名称:doanD2T,代码行数:7,代码来源:sms.cs

示例2: ReceivedComData

 private void ReceivedComData(object sender, SerialDataReceivedEventArgs e)
 {
     try
     {
         while (true)
         {
             int nCount = 1;
             byte[] preamble = new byte[nCount];
             iSerialPort.Read(preamble, 0, nCount);
             if (preamble[0] == '!')
             {
                 nCount = 6;
                 byte[] header = new byte[nCount];
                 int nBytes = iSerialPort.Read(header, 0, nCount);
                 if (nBytes != nCount)
                 {
                     iSerialPort.Read(header, nBytes, nCount-nBytes);
                 }
                 if (callback != null)
                 {
                     callback(header);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         string msg = ex.Message;
     }
 }
开发者ID:niceukulele,项目名称:ProjectForZou,代码行数:30,代码来源:infrared.cs

示例3: Port_DataReceived

        public static void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            while(Port.IsOpen && Port.BytesToRead > 0)
            {
                int i = Port.ReadByte();
                if (i != '\r')
                {
                    if (i != '\n')
                    {
                        Line[Index++] = (char)i;
                    }
                }
                else
                {
                    string line = new string(Line, 0, Index);

                    foreach (GRBL.LineReceivedHandler d in OnLineReceived.GetInvocationList())
                    {
                        d.Invoke(line);
                    }

                    Index = 0;
                }

            }
        }
开发者ID:devendrash,项目名称:GrblHeightProbe2,代码行数:26,代码来源:GRBL.cs

示例4: DataReceivedHandler

 private static void DataReceivedHandler(
             object sender,
             SerialDataReceivedEventArgs e)
 {
     SerialPort sp = (SerialPort)sender;
     string indata = sp.ReadExisting();
 }
开发者ID:Letech-Anamono,项目名称:LightSwitch,代码行数:7,代码来源:Form1.cs

示例5: comport_DataReceived

        void comport_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            // This method will be called when there is data waiting in the port's buffer

            // Determain which mode (string or binary) the user is in
            // Read all the data waiting in the buffer
            try
            {
                string data = "";
                data = comport.ReadLine();//.ReadExisting();
                string s = "";
                // Display the text to the user in the terminal
                if (bUseHexDecode)
                    s = Utility.HexEncoding.ToMixedString(data);
                else
                    s = data;
                txtReceive.Invoke(new EventHandler(delegate { txtReceive.Text += "<" + s + "\r\n"; })); //added < to mark incoming data
            }
            catch (Exception ex)
            {
                txtReceive.Invoke(new EventHandler(delegate { txtReceive.Text += ex.Message + "\r\n"; }));
                //MessageBox.Show(ex.Message);
            }
            //label2.Invoke(new EventHandler(delegate{label2.Text  = data;}));

            //Log(LogMsgType.Incoming, data);
        }
开发者ID:andrejpanic,项目名称:win-mobile-code,代码行数:27,代码来源:Form1.cs

示例6: port_DataReceived

        void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort port = (SerialPort)sender;
            int layer = 0;
            if (port.PortName == ports["1st"].PortName) layer = 0;
            if (port.PortName == ports["2nd"].PortName) layer = 1;
            if (port.PortName == ports["3rd"].PortName) layer = 2;

            string code = port.ReadLine();

            var result = from box in packs[layer]
                         where !box.HasBarcode
                         select box;
            if (result.Count() > 0)
            { result.First().Barcode = code; }
            else
            {
                if (layer > 0)
                    MessageBox.Show(string.Format("尚不存在需要赋码的{0}级包装,不准提前赋码!", layer + 1));
                else
                    packs.Add(layer, new DrugBox(code, layer));
            }

            this.BeginInvoke(new MethodInvoker(
                delegate
                {
                    ShowPacks();
                }));
        }
开发者ID:renpan,项目名称:DrugSupervision,代码行数:29,代码来源:TerminalForm.cs

示例7: serialPort_DataReceived

 private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     RxString = serialPort.ReadExisting();
     if (!serialIntercept)
     {
         if (oldEntry != RxString)
         {
             this.Invoke(new EventHandler(serialRecived));
             oldEntry = RxString;
         }
     }
     else
     {
         switch (FromIntecepted)
         {
             case "Add":
                 AddCard.TagAdd(RxString);
                 break;
             case "Remove":
                 RemoveCard.TagAdd(RxString);
                 break;
             default:
                 serialIntercept = false;
                 break;
         }
     }
 }
开发者ID:LFSousa,项目名称:RFIDTagReader,代码行数:27,代码来源:Main.cs

示例8: Arduino_DataReceived

        private void Arduino_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                rx_data = new byte[arduino.BytesToRead];

                // read the data
                read_count = arduino.Read(rx_data, 0, rx_data.Length);

                lastMessage += Encoding.ASCII.GetString(rx_data, 0, read_count);

                if (lastMessage.IndexOf("*") > -1)
                {

                    message = lastMessage;
                    lastMessage = "";
                    this.Invoke(new EventHandler(WriteData));

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:contractorwolf,项目名称:ArduinoRadar,代码行数:26,代码来源:ArduinoRadarForm.cs

示例9: arduino_DataReceived

 void arduino_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     this.Invoke(new MethodInvoker(delegate
     {
         ReadCode(sender, e);
     }));
 }
开发者ID:ModernSteward,项目名称:plugins,代码行数:7,代码来源:RecordCodes.cs

示例10: DataReceived

        private static void DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            var port = (SerialPort) sender;
            while (port.BytesToRead > 0)
            {
                int b = port.ReadByte();
                if (b == -1)
                    continue;

                Command command = ToCommand(b);
                if (command == Command.Unknown)
                {
                    Debug.Print(b.ToString("X2"));
                    continue;
                }

                var led = (OutputPort) Led[command];
                bool newValue = !led.Read();
                led.Write(newValue);

                string response = (char) b + "=" + (newValue ? "on" : "off") + "\r\n";
                byte[] buffer = Encoding.UTF8.GetBytes(response);
                port.Write(buffer, 0, buffer.Length);
            }
        }
开发者ID:dario-l,项目名称:kodfilemon.blogspot.com,代码行数:25,代码来源:Program.cs

示例11: serialPort_DataReceived

        void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort sp = (SerialPort)sender;
            string indata = sp.ReadExisting();
            //output.Text += "Data Received:\r\n";
            output.Text += indata; // +"\r\n";

            output.SelectionStart = output.Text.Length;
            output.SelectionLength = 0;
            output.ScrollToCaret();

            //if (IsLoadingLua)
            //{
            //    output.SelectionStart = StartingLinePosition;
            //    output.SelectionLength = output.TextLength - StartingLinePosition;
            //    //output.Copy();
            //    //LuaCodeTextbox.Clear();
            //    //LuaCodeTextbox.Paste();
            //    Clipboard.Clear();
            //    Clipboard.SetText(output.SelectedText);
            //    LuaCodeTextbox.Clear();
            //    LuaCodeTextbox.Text = Clipboard.GetText();
            //    IsLoadingLua = false;
            //}
            lastSerialActivity = DateTime.Now;
        }
开发者ID:pridesys,项目名称:g33k,代码行数:26,代码来源:Form1.cs

示例12: DataRecievedHandler

        private void DataRecievedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            // returns the ID read from tag, provides easteregg.

                        var serp = (SerialPort) sender;
                        //	var dbm = new DatabaseManager();
                        var DiagnosticID = "4510720867";
                        var BlueOysterID = "4519992145";

                        rfid = serp.ReadExisting().Trim();
                        Engine.QueueOfRfids.Enqueue(rfid);

                        //Console.WriteLine(rfid);
                        if (rfid == DiagnosticID)
                            {

                                // Play blue oyster soundtrack.
                                //Console.WriteLine("Dun duu du du duuu duu duuu");
                                //Diagnostic = true;
                                //if (Diagnostic)
                                //	{

                                ////	PrintDiagnosticData(DiagnosticID);
                                //	}
                                //}
                                if (rfid == BlueOysterID)
                                    {

                                        //	AudioPlayer ap = new AudioPlayer("Blue Oyster Bar.wav");
                                        //	ap.Play();
                                    }

                            }
        }
开发者ID:TommyAGK,项目名称:Flex3,代码行数:34,代码来源:TagScanner.cs

示例13: DataReceivedHandler

        private void DataReceivedHandler(object sender,SerialDataReceivedEventArgs e)
        {
            SerialPort reader = (SerialPort)sender;
            int buff=0;
            List<byte> list = new List<byte>();
            byte[] buffer_rd = new byte[reader.BytesToRead];
            do
            {
                try
                {
                    buff = reader.ReadByte();

                }
                catch (System.IO.IOException E)
                {
                    //TODO: Handle
                }
                list.Add((byte)buff);
            } while (reader.BytesToRead > 0);
            //await reader.BaseStream.ReadAsync(buffer_rd, 0, buffer_rd.Length, System.Threading.CancellationToken.None);
            //Debug.WriteLine("{0} Bytes recieved", list.Count);
            list.AddRange(buffer_rd); 
            foreach (byte to_push in list)
            {
                parser.push_byte(to_push);
            }
            buff=0;
        }
开发者ID:MChehadeh,项目名称:userTerminal,代码行数:28,代码来源:serial_driver.cs

示例14: sp_DataReceived

 public void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     data = _serialPort.ReadExisting();
     globald = data;
     data = "";
     this.BeginInvoke(new SetTextDeleg(si_DataReceived));
 }
开发者ID:santhotech,项目名称:SerialPortReader,代码行数:7,代码来源:Form1.cs

示例15: DataReceivedHandler

 private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
 {
     SerialPort sp = (SerialPort)sender;
     string indata = sp.ReadExisting();
     Console.Write("Data Received:");
     Console.WriteLine(indata);
 }
开发者ID:esayers,项目名称:iSOBOT,代码行数:7,代码来源:Isobot.cs


注:本文中的System.IO.Ports.SerialDataReceivedEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。