public void SetProperty(int code, byte[] data, int param1, int param2) { bool timerstate = _timer.Enabled; _timer.Stop(); bool retry = false; int retrynum = 0; //DeviceReady(); do { if (retrynum > 5) { return; } try { retry = false; uint resp = StillImageDevice.ExecuteWriteData(code, data, param1, param2); if (resp != 0 || resp != ErrorCodes.MTP_OK) { //Console.WriteLine("Retry ...." + resp.ToString("X")); if (resp == ErrorCodes.MTP_Device_Busy || resp == 0x800700AA) { Thread.Sleep(100); retry = true; retrynum++; } else { ErrorCodes.GetException(resp); } } } catch (Exception exception) { Log.Debug("Error set property :" + param1.ToString("X"), exception); } } while (retry); if (timerstate) { _timer.Start(); } }
/// <summary> /// Take picture with no autofocus /// If live view runnig the live view is stoped after done restarted /// </summary> public override void CapturePhotoNoAf() { lock (Locker) { byte oldval = 0; byte[] val = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropValue, CONST_PROP_AFModeSelect, -1); if (val != null && val.Length > 0) oldval = val[0]; ErrorCodes.GetException(StillImageDevice.ExecuteWriteData(CONST_CMD_SetDevicePropValue, new[] { (byte)4 }, CONST_PROP_AFModeSelect, -1)); ErrorCodes.GetException(StillImageDevice.ExecuteWithNoData(CONST_CMD_InitiateCapture)); if (val != null && val.Length > 0) ErrorCodes.GetException(StillImageDevice.ExecuteWriteData(CONST_CMD_SetDevicePropValue, new[] { oldval }, CONST_PROP_AFModeSelect, -1)); } }