internal NovacomDevice(string host, NovaDeviceInfo devInfo) { this.host = host; this.devInfo = devInfo; }
/// <exception cref="System.IO.IOException" /> /// <exception cref="Palm.Novacom.NovacomException" /> public void WaitForDeviceToAppear(int timeout) { INovacomDevice newdev = null; INovacomController controller = Novacom.GetController(host, Novacom.DEFAULT_PORT); System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); TimeSpan timeToTimeoutOn = TimeSpan.FromMilliseconds(timeout); stopwatch.Start(); /* Loop until we find a new device show up */ do { NovaDeviceInfo[] devices = controller.GetDeviceList(); foreach (NovaDeviceInfo device in devices) { if (device.UIDString == devInfo.UIDString && device.Port != devInfo.Port) { newdev = controller.ConnectToDevice(device); break; } } System.Threading.Thread.Sleep(250); if (stopwatch.Elapsed > timeToTimeoutOn) { throw new NovacomException(Novacom.ERROR, NovacomException.EXIT_NO_DEVICE, "Timeout waiting for device to appear"); } } while (newdev == null); /* Now clone ourselves to be the same as the new device info */ this.devInfo = newdev.DeviceInfo; if ((devInfo.SessionId != null) && (hashNP != null)) { calcHash(null, HashCalcType.HashCalc_ReuseNP); } }