Example #1
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     foreach (string x in HIDDeviceInterface.Scan())
     {
         VM.USBDevices.Add(x);
     }
 }
Example #2
0
 private void ScanButton_Clicked(object sender, System.EventArgs e)
 {
     VM.USBDevices.Clear();
     foreach (string x in HIDDeviceInterface.Scan())
     {
         VM.USBDevices.Add(x);
     }
 }
Example #3
0
 internal void SetDevice(string DeviceID)
 {
     HIDDeviceInterface.Load(DeviceID);
     Task.Run(() =>
     {
         try
         {
             while (!OnPage)
             {
                 Thread.Sleep(50);// wait till we navigate back to page
             }
             Main.Post(delegate { DisplayLabel.Text = "Connected Attempting First Read"; }, null);
             Task.Run(() =>
             {
                 Thread.Sleep(1000);
                 Main.Post(delegate
                 {
                     if (DisplayLabel.Text == "Connected Attempting First Read")
                     {
                         DisplayLabel.Text = "Could not read from device.";
                     }
                 }, null);
             });
             byte[] Buffer = HIDDeviceInterface.Read();
             Main.Post(delegate
             {
                 DisplayLabel.Text  = "Connected and Streaming";
                 ReceivedLabel.Text = ASCIIEncoding.ASCII.GetString(Buffer);
             }, null);
             while (OnPage)// only while we are still on the page.
             {
                 Buffer = HIDDeviceInterface.Read();
                 Main.Post(delegate { ReceivedLabel.Text = ASCIIEncoding.ASCII.GetString(Buffer); }, null);
                 Thread.Sleep(100);
             }
         }
         catch
         {
             Main.Post(delegate { DisplayLabel.Text = "Permission Denied For USB Device."; }, null);
         }
     });
 }