Example #1
0
 /// <summary>
 /// Checks the devices that are present at the moment and checks if one of those
 /// is the device you defined by filling in the product id and vendor id.
 /// </summary>
 public void CheckDevicePresent()
 {
     try
     {
         //Mind if the specified device existed before.
         bool history = false;
         if (specified_device != null)
         {
             history = true;
         }
         // Note, this has been modified by Nordic Semiconductor
         specified_device = SpecifiedDevice.FindSpecifiedDevice(this.vendor_id, this.product_id, this.pref_interface); // look for the device on the USB bus
         if (specified_device != null)                                                                                 // did we find it?
         {
             if (OnSpecifiedDeviceArrived != null)
             {
                 this.OnSpecifiedDeviceArrived(this, new EventArgs());
                 specified_device.DataRecieved += new DataRecievedEventHandler(OnDataRecieved);
                 specified_device.DataSend     += new DataSendEventHandler(OnDataSent);
             }
         }
         else
         {
             if (OnSpecifiedDeviceRemoved != null && history)
             {
                 this.OnSpecifiedDeviceRemoved(this, new EventArgs());
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Example #2
0
 /// <summary>
 /// 
 /// </summary>
 public UsbHidPort()
 {
     //initializing in initial state
     product_id = 0;
     vendor_id = 0;
     // Note, this has been modified by Nordic Semiconductor
     pref_interface = 0x100;
     specified_device = null;
     device_class = Win32Usb.HIDGuid;
 }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 public UsbHidPort()
 {
     //initializing in initial state
     product_id = 0;
     vendor_id  = 0;
     // Note, this has been modified by Nordic Semiconductor
     pref_interface   = 0x100;
     specified_device = null;
     device_class     = Win32Usb.HIDGuid;
 }
Example #4
0
 /// <summary>
 /// Checks the devices that are present at the moment and checks if one of those
 /// is the device you defined by filling in the product id and vendor id.
 /// </summary>
 public void CheckDevicePresent()
 {
     try
     {
         //Mind if the specified device existed before.
         bool history = false;
         if(specified_device != null ){
             history = true;
         }
         // Note, this has been modified by Nordic Semiconductor
         specified_device = SpecifiedDevice.FindSpecifiedDevice(this.vendor_id, this.product_id, this.pref_interface);	// look for the device on the USB bus
         if (specified_device != null)	// did we find it?
         {
             if (OnSpecifiedDeviceArrived != null)
             {
                 this.OnSpecifiedDeviceArrived(this, new EventArgs());
                 specified_device.DataRecieved += new DataRecievedEventHandler(OnDataRecieved);
                 specified_device.DataSend += new DataSendEventHandler(OnDataSent);
             }
         }
         else
         {
             if (OnSpecifiedDeviceRemoved != null && history)
             {
                 this.OnSpecifiedDeviceRemoved(this, new EventArgs());
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }