Exemplo n.º 1
0
        public void ConnectToMicrocontroller()
        {
            HidDeviceLoader device_loader = new HidDeviceLoader();
            HidDevice       device        = device_loader.GetDeviceOrDefault(VendorID, ProductID);

            if (device != null)
            {
                bool success = device.TryOpen(out MicrocontrollerStream);
                if (!success)
                {
                    MMazeMessaging.GetInstance().AddMessage("Unable to connect to microcontroller!");
                }
                else
                {
                    //Disable the read and write timeouts
                    //MicrocontrollerStream.ReadTimeout = System.Threading.Timeout.Infinite;
                    //MicrocontrollerStream.WriteTimeout = System.Threading.Timeout.Infinite;
                    MicrocontrollerStream.ReadTimeout  = 30;
                    MicrocontrollerStream.WriteTimeout = 30;
                }
            }
            else
            {
                MMazeMessaging.GetInstance().AddMessage("Unable to find microcontroller device!");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the singleton instance of the messaging system.
        /// </summary>
        /// <returns>The singleton instance of this class.</returns>
        public static MMazeMessaging GetInstance()
        {
            if (_instance == null)
            {
                lock (_instance_lock)
                {
                    if (_instance == null)
                    {
                        _instance = new MMazeMessaging();
                    }
                }
            }

            return(_instance);
        }