diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2015-12-27 13:56:11 +0100 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2015-12-27 13:56:11 +0100 |
commit | f63bdb9d486de2b19e53a43ffbf42f67f822ad2b (patch) | |
tree | 5c4061251491fc61451fe4b9e3ccbef2b9184818 /libgphoto2_port/vusb | |
parent | 146ba117ee795d778fe243c13c585571445fef2f (diff) | |
download | libgphoto2-f63bdb9d486de2b19e53a43ffbf42f67f822ad2b.tar.gz |
allow timeout setting with the 0x9999 command, its the second argument
Diffstat (limited to 'libgphoto2_port/vusb')
-rw-r--r-- | libgphoto2_port/vusb/vcamera.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libgphoto2_port/vusb/vcamera.c b/libgphoto2_port/vusb/vcamera.c index 059c6f5a5..8c72b2a74 100644 --- a/libgphoto2_port/vusb/vcamera.c +++ b/libgphoto2_port/vusb/vcamera.c @@ -1321,10 +1321,20 @@ ptp_setdevicepropvalue_write(vcamera *cam, ptpcontainer *ptp) { static int ptp_vusb_write(vcamera *cam, ptpcontainer *ptp) { static int capcnt = 98; + static int timeout = 1; CHECK_SEQUENCE_NUMBER(); CHECK_SESSION(); - CHECK_PARAM_COUNT(1); + if (ptp->nparams < 1) { + gp_log (GP_LOG_ERROR, __FUNCTION__, "parameter count %d", ptp->nparams); + ptp_response (cam, PTP_RC_InvalidParameter, 0); + return 1; + } + if (ptp->nparams >= 2) { + timeout = ptp->params[1]; + gp_log (GP_LOG_DEBUG, __FUNCTION__, "new timeout %d", timeout); + } else + timeout++; switch (ptp->params[0]) { case 0: {/* add a new image after 1 second */ @@ -1397,7 +1407,7 @@ ptp_vusb_write(vcamera *cam, ptpcontainer *ptp) { sprintf(newcur->name,"GPH_%04d.JPG", capcnt++); first_dirent = newcur; - ptp_inject_interrupt (cam, 100, 0x4002, 1, ptp_objectid, cam->seqnr); /* objectadded */ + ptp_inject_interrupt (cam, timeout, 0x4002, 1, ptp_objectid, cam->seqnr); /* objectadded */ ptp_response (cam, PTP_RC_OK, 0); break; } @@ -1414,13 +1424,13 @@ ptp_vusb_write(vcamera *cam, ptpcontainer *ptp) { ptp_response (cam, PTP_RC_GeneralError, 0); return 1; } - ptp_inject_interrupt (cam, 0, 0x4003, 1, (*pcur)->id, cam->seqnr); /* objectremoved */ + ptp_inject_interrupt (cam, timeout, 0x4003, 1, (*pcur)->id, cam->seqnr); /* objectremoved */ *pcur = (*pcur)->next; ptp_response (cam, PTP_RC_OK, 0); break; } case 2: /* capture complete */ - ptp_inject_interrupt (cam, 0, 0x400d, 2, 0, cam->seqnr); /* capturecomplete */ + ptp_inject_interrupt (cam, timeout, 0x400d, 0, 0, cam->seqnr); /* capturecomplete */ ptp_response (cam, PTP_RC_OK, 0); break; default: @@ -1680,6 +1690,8 @@ ptp_inject_interrupt(vcamera*cam, int when, uint16_t code, int nparams, uint32_t unsigned char *data; int x = 0; + gp_log (GP_LOG_DEBUG, __FUNCTION__, "generate interrupt 0x%04x, %d params, param1 0x%08x, timeout=%d", code, nparams, param1, when); + gettimeofday (&now, NULL); now.tv_usec += (when % 1000)*1000; now.tv_sec += when / 1000; |