From: <mar...@us...> - 2012-12-13 23:24:32
|
Revision: 14158 http://sourceforge.net/p/gphoto/code/14158 Author: marcusmeissner Date: 2012-12-13 23:24:29 +0000 (Thu, 13 Dec 2012) Log Message: ----------- powersjot_prepare_capture ... allow getting called with initialized capture Modified Paths: -------------- trunk/libgphoto2/camlibs/ptp2/config.c Modified: trunk/libgphoto2/camlibs/ptp2/config.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/config.c 2012-12-13 23:04:42 UTC (rev 14157) +++ trunk/libgphoto2/camlibs/ptp2/config.c 2012-12-13 23:24:29 UTC (rev 14158) @@ -75,7 +75,7 @@ PTPPropertyValue propval; int ret; PTPParams *params = &camera->pl->params; - int found, oldtimeout; + int found, oldtimeout, mightbeprepared = 0; propval.u16 = 0; ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_EventEmulateMode, &propval, PTP_DTC_UINT16); @@ -83,29 +83,31 @@ gp_log (GP_LOG_DEBUG, "ptp", "failed get 0xd045"); return translate_ptp_result (ret); } - gp_log (GP_LOG_DEBUG, "ptp","prop 0xd045 value is 0x%4x",propval.u16); + gp_log (GP_LOG_DEBUG, "ptp","prop 0xd045 value is 0x%04x",propval.u16); + if (propval.u16 == 7) + mightbeprepared = 1; propval.u16=1; ret = ptp_setdevicepropvalue(params, PTP_DPC_CANON_EventEmulateMode, &propval, PTP_DTC_UINT16); params->canon_event_mode = propval.u16; ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_SizeOfOutputDataFromCamera, &propval, PTP_DTC_UINT32); - gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfOutputDataFromCamera value is 0x%8x, ret 0x%x",propval.u32, ret); + gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfOutputDataFromCamera value is %d, ret 0x%x",propval.u32, ret); ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_SizeOfInputDataToCamera, &propval, PTP_DTC_UINT32); - gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfInputDataToCamera value is 0x%8x, ret 0x%x",propval.u32, ret); + gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfInputDataToCamera value is %d, ret 0x%x",propval.u32, ret); ret = ptp_getdeviceinfo (params, ¶ms->deviceinfo); ret = ptp_getdeviceinfo (params, ¶ms->deviceinfo); fixup_cached_deviceinfo (camera, ¶ms->deviceinfo); ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_SizeOfOutputDataFromCamera, &propval, PTP_DTC_UINT32); - gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfOutputDataFromCamera value is 0x%8x, ret 0x%x",propval.u32, ret); + gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfOutputDataFromCamera value is %d, ret 0x%x",propval.u32, ret); ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_SizeOfInputDataToCamera, &propval, PTP_DTC_UINT32); - gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfInputDataToCamera value is 0x%8X, ret x0%x",propval.u32,ret); + gp_log (GP_LOG_DEBUG, "ptp", "prop PTP_DPC_CANON_SizeOfInputDataToCamera value is %d, ret x0%x",propval.u32,ret); ret = ptp_getdeviceinfo (params, ¶ms->deviceinfo); fixup_cached_deviceinfo (camera, ¶ms->deviceinfo); ret = ptp_getdevicepropvalue(params, PTP_DPC_CANON_EventEmulateMode, &propval, PTP_DTC_UINT16); params->canon_event_mode = propval.u16; - gp_log (GP_LOG_DEBUG, "ptp","prop 0xd045 value is 0x%4x, ret 0x%x",propval.u16,ret); + gp_log (GP_LOG_DEBUG, "ptp","prop 0xd045 value is 0x%04x, ret 0x%x",propval.u16,ret); gp_log (GP_LOG_DEBUG, "ptp","Magic code ends."); @@ -123,14 +125,24 @@ ret = ptp_setdevicepropvalue(params, PTP_DPC_CANON_EventEmulateMode, &propval, PTP_DTC_UINT16); params->canon_event_mode = propval.u16; - CPR (context, ptp_canon_startshootingmode (params)); - + ret = ptp_canon_startshootingmode (params); +#if 0 + if (ret == PTP_RC_CANON_A009) { + /* I think this means ... already in capture mode */ + return GP_OK; + } + if (ret != PTP_RC_OK) { + gp_log (GP_LOG_DEBUG, "ptp","shooting mode resulted in 0x%04x.", ret); + CPR (context, ret); + } +#endif gp_port_get_timeout (camera->port, &oldtimeout); gp_port_set_timeout (camera->port, 1000); /* Catch the event telling us the mode was switched ... */ + /* If we were prepared already, it will be 5*50*1000 wait, so 1/4 second ... hmm */ found = 0; - while (!found) { + while (found++<10-5*mightbeprepared) { ret = ptp_check_event (params); if (ret != PTP_RC_OK) break; @@ -144,7 +156,7 @@ break; } } - if (!found) usleep(50*1000); + usleep(50*1000); } #if 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |