Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make camera_trigger_canon_eos_capture "synchronous" #1027

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions camlibs/ptp2/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -5995,9 +5995,14 @@ camera_trigger_canon_eos_capture (Camera *camera, GPContext *context)
uint32_t result;
struct timeval focus_start;
PTPDevicePropDesc dpd;
int full_press_wait = 0;

GP_LOG_D ("camera_trigger_canon_eos_capture");

for (unsigned i = 0; i < params->nrofcanon_props; i++)
if (params->canon_props[i].proptype == PTP_DPC_CANON_EOS_Owner)
full_press_wait = atoi(params->canon_props[i].dpd.CurrentValue.str);

if (!params->eos_captureenabled)
camera_prepare_capture (camera, context);
else
Expand Down Expand Up @@ -6107,6 +6112,12 @@ camera_trigger_canon_eos_capture (Camera *camera, GPContext *context)
return GP_ERROR;
}
/* no event check between */

if (full_press_wait) {
GP_LOG_D ("waiting %dms", full_press_wait);
usleep (full_press_wait * 1000);
}

/* full release now */
C_PTP_REP_MSG (ptp_canon_eos_remotereleaseoff (params, 2), _("Canon EOS Full-Release failed"));
ptp_check_eos_events (params);
Expand Down Expand Up @@ -6182,6 +6193,23 @@ camera_trigger_canon_eos_capture (Camera *camera, GPContext *context)
return GP_ERROR;
}
}

if (full_press_wait)
{
struct timeval event_start = time_now();
PTPPropertyValue propval = { 0 };
for (unsigned i = 0; i < params->nrofcanon_props; i++)
if (params->canon_props[i].proptype == PTP_DPC_CANON_EOS_ISOSpeed)
propval.u16 = params->canon_props[i].dpd.CurrentValue.u16;

do {
// if setting iso does not return busy, the camera is ready to take new commands or is lost -> exit
ret = ptp_canon_eos_setdevicepropvalue (params, PTP_DPC_CANON_EOS_ISOSpeed, &propval, PTP_DTC_UINT16);
back_off_wait = 0;
} while (ret == PTP_RC_DeviceBusy && waiting_for_timeout (&back_off_wait, event_start, 30*1000));
params->eos_camerastatus = 0; /* manually set it to 'done' */
}

return GP_OK;
}

Expand Down
Loading