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."); } } }
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); } }
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); } }