Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (serial.IsOpen)
     {
         byte[] data = serial.Read();
         if (data != null)
         {
             for (int i = 0; i < data.Length; i++)
             {
                 Debug.Log(data[i]);
             }
         }
     }
 }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (codeStarComm.IsOpen)
     {
         byte[] data = codeStarComm.Read();
         if (data != null)
         {
             for (int i = 0; i < data.Length; i++)
             {
                 byte cmd   = (byte)((data[i] & 0xf0) >> 4);
                 byte param = (byte)(data[i] & 0x0f);
                 if (cmd == (byte)STATUS.Pass || cmd == (byte)STATUS.Stop)
                 {
                     EndAction();
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (_serial.IsOpen)
        {
            byte[] data = _serial.Read();
            if (data != null)
            {
                for (int i = 0; i < data.Length; i++)
                {
                    string text = "";

                    if (input.text.Length > 0)
                    {
                        text += "\n";
                    }

                    text += string.Format("{0:d} (0x{1:X}) (b", data[i], data[i]);
                    if ((data[i] & 128) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 64) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 32) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 16) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 8) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 4) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 2) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    if ((data[i] & 1) != 0)
                    {
                        text += "1";
                    }
                    else
                    {
                        text += "0";
                    }

                    text       += ")";
                    input.text += text;
                }

                scrollRect.verticalNormalizedPosition = 0;
            }
        }
    }