• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Ports.SerialDataReceivedEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: port_DataReceived

        void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort spL = (SerialPort)sender;
            byte[] buf = new byte[spL.BytesToRead];
            spL.Read(buf, 0, buf.Length);
            var result = Encoding.ASCII.GetString(buf);
            Regex _lineSplitter = new Regex("\\+CUSD: \\d,\"(.*)\",15", RegexOptions.Singleline);
            if (!_lineSplitter.IsMatch(result))
            {
                return;
            }

            var f = _lineSplitter.Match(result);
            var hexString = f.Groups[1].ToString().Trim();
            result = Encoding.ASCII.GetString(PduBitPacker.UnpackBytes(PduBitPacker.ConvertHexToBytes(hexString)));
            Log.Write(result);
            foreach (var amountRegExItem in Settings.Default.AmountRegExList)
            {
                _lineSplitter = new Regex(amountRegExItem, RegexOptions.Singleline);
                if (!_lineSplitter.IsMatch(result))
                {
                    continue;
                }
                f = _lineSplitter.Match(result);
                result = f.Groups[1].ToString().Trim();
                var amount = float.Parse(result.Replace('.',','));
                if (null != OnReceiveAmount)
                {
                    OnReceiveAmount.Invoke(amount);
                }
                spL.Close();
            }
        }
开发者ID:atefsaeed2010,项目名称:balancechecker,代码行数:33,代码来源:Receiver.cs


示例17: serial_DataReceived

 static void serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     //            throw new NotImplementedException();
     byte[] bytes = new byte[serial.BytesToRead];
     serial.Read(bytes, 0, bytes.Length);
     //
     //  "a" received, move the servo and start
     //  recording
     //
     if (bytes[0] == 97)
     {
         red.Write(false);
         green.Write(false);
         Thread.Sleep(waitTime);
         red.Write(true);
         flex.Duration = relPos;
         collectData();
         green.Write(true);
         red.Write(false);
         flex.Duration = armPos;
     }
     //
     //  "b" received, write the data to the port
     //
     else if (bytes[0] == 98)
     {
         for (int i = 0; i < nSamples; i++)
         {
             byte[] send = System.Text.Encoding.UTF8.GetBytes(readTime[i].ToString() + " " + reading[i].ToString() + "\n");
             serial.Write(send, 0, send.Length);
             red.Write(true);
             green.Write(true);
         }
     }
 }
开发者ID:RiekertLeibbrandt,项目名称:marencoCode,代码行数:35,代码来源:Program.cs


示例18: OnReceive

        private void OnReceive(Object sender, SerialDataReceivedEventArgs e)
        {
            List<byte> buffer = new List<byte>();

            while (PortHasData()) buffer.Add((byte)Read());
            socket.Send(buffer.ToArray());
        }
开发者ID:kaviththiranga,项目名称:GPSTracking,代码行数:7,代码来源:SerialPortManager.cs


示例19: serialPort_DataReceived

        void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            string data = serialPort.ReadExisting();

            DataReceived(data);
            //센서 데이터 수신부
        }
开发者ID:kimyongyeon,项目名称:autoboot,代码行数:7,代码来源:Sensor.cs


示例20: _serialPort_DataReceived

 private void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e){
     if (!_serialPort.IsOpen)
         return;
     LastReadLines = _serialPort.ReadExisting();
     AnswerReceived = true;
     FireOnAnswerReceived();
 }
开发者ID:satr,项目名称:rvslite,代码行数:7,代码来源:SerialConnectionBase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ports.SerialErrorReceivedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Pipes.PipeSecurity类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap