コード例 #1
0
        private void Update()
        {
            // Read the next message from the queue
            var message = serialThread?.ReadSerialMessage();

            if (message == null)
            {
                return;
            }

            // Check if the message is plain data or a connect/disconnect event.
            if (string.Equals(message, SERIAL_DEVICE_CONNECTED))
            {
                IsConnected = true;
                OnSerialConnected?.Invoke();
            }
            else if (string.Equals(message, SERIAL_DEVICE_DISCONNECTED))
            {
                IsConnected = false;
                OnSerialDisconnected?.Invoke();
            }
            else
            {
                if (!IsConnected)
                {
                    return;
                }

                OnSerialMessageReceived?.Invoke(message);
            }
        }
コード例 #2
0
        private void Update()
        {
//#if UNITY_EDITOR
//            if (testPitacoConnection && stopReceivePicatoValues == false)
//            {
//                OnSerialMessageReceived?.Invoke(testPitacoValue.ToString(CultureInfo.InvariantCulture));
//                return;
//            }
//#endif
            // Read the next message from the queue
            var message = serialThread?.ReadSerialMessage();

            if (message == null)
            {
                return;
            }

            // Check if the message is plain data or a connect/disconnect event.
            if (string.Equals(message, SERIAL_DEVICE_CONNECTED))
            {
                IsConnected = true;
                OnSerialConnected?.Invoke();
            }
            else if (string.Equals(message, SERIAL_DEVICE_DISCONNECTED))
            {
                IsConnected = false;
                OnSerialDisconnected?.Invoke();
            }
            else
            {
                if (!IsConnected)
                {
                    return;
                }

                OnSerialMessageReceived?.Invoke(message);
            }
        }