Пример #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
 public string ReadSerialMessage() => serialThread.ReadSerialMessage();