Exemple #1
0
        public async Task EnumerateDevice()
        {
            _deviceIsEnumerated = false;

            if (!DeviceIsEnumerated() && DeviceIsPresent())
            {
                try
                {
                    var deviceInfo = await DeviceInformation.FindAllAsync(USBSelector.GetSelector());

                    _device = await HidDevice.FromIdAsync(deviceInfo.ElementAt(0).Id,
                                                          Windows.Storage.FileAccessMode.ReadWrite);
                }
                catch (Exception e0)
                {
                    LogMessage(e0.Message + e0.StackTrace);
                }

                if (_device != null)
                {
                    _deviceIsEnumerated          = true;
                    _device.InputReportReceived += new TypedEventHandler <HidDevice,
                                                                          HidInputReportReceivedEventArgs>(USBInterruptTransferHandler);
                    LogMessage("Motus-1 enumeration success!");
                }
                else
                {
                    LogMessage("Motus-1 enumeration failure.");
                }
            }
        }
Exemple #2
0
        public async Task PollDevice()
        {
            try
            {
                var deviceInfo = await DeviceInformation.FindAllAsync(USBSelector.GetSelector());

                if (deviceInfo.Count == 0)
                {
                    _deviceIsPresent = false;
                    LogMessage("Motus-1 has been disconnected");
                }
            }
            catch (Exception e0)
            {
                LogMessage(e0.Message + e0.StackTrace);
            }
        }
Exemple #3
0
        public async Task FindDevice()
        {
            _deviceIsPresent = false;

            try
            {
                var deviceInfo = await DeviceInformation.FindAllAsync(USBSelector.GetSelector());

                if (deviceInfo.Count > 0)
                {
                    _deviceIsPresent = true;
                    LogMessage("Motus-1 is present!");
                }
            }
            catch (Exception e0)
            {
                LogMessage(e0.Message + e0.StackTrace);
            }
        }