/// <summary> /// Method used to determine whether a specific device is still connected /// </summary> /// <param name="hUSB"></param> /// <returns></returns> public static bool isButtonConnected(uint hUSB) { int deviceVersion = Delcom.DelcomReadDeviceVersion(hUSB); //If no longer connected we will get a return value of 0 or 255 (manual says 0 but in practice we get 255) if (deviceVersion == 0 || deviceVersion == 255) { return(false); } return(true); }
/// <summary> /// Determine whether the current device is still connected /// </summary> private bool DeviceIsConnected() { if (this.deviceHandle == InvalidDevcieHandle) { return(false); } // If no longer connected we will get a return value of 0 or 255 (manual says 0 but in practice we get 255). int deviceVersion = Delcom.DelcomReadDeviceVersion(this.deviceHandle); if (deviceVersion == 0 || deviceVersion == 255) { // This frequently happens (once in a few minutes) even on the healthy system. // Retry once before reporting back. Thread.Sleep(DelcomLightWrapper.DeviceConnectionCheckRetryInterval); deviceVersion = Delcom.DelcomReadDeviceVersion(this.deviceHandle); if (deviceVersion == 0 || deviceVersion == 255) { return(false); } } return(true); }