From: <mar...@us...> - 2006-10-21 19:16:04
|
Revision: 9365 http://svn.sourceforge.net/gphoto/?rev=9365&view=rev Author: marcusmeissner Date: 2006-10-21 12:15:52 -0700 (Sat, 21 Oct 2006) Log Message: ----------- - Check sequence number of response in transaction. abort on mismatch. - if read hangs, clear HALT condition on IN EP and retry. Modified Paths: -------------- trunk/libgphoto2/camlibs/ptp2/ChangeLog trunk/libgphoto2/camlibs/ptp2/library.c trunk/libgphoto2/camlibs/ptp2/ptp.c Modified: trunk/libgphoto2/camlibs/ptp2/ChangeLog =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ChangeLog 2006-10-19 20:03:52 UTC (rev 9364) +++ trunk/libgphoto2/camlibs/ptp2/ChangeLog 2006-10-21 19:15:52 UTC (rev 9365) @@ -1,3 +1,9 @@ +2006-10-21 Marcus Meissner <ma...@je...> + + * ptp.c: Check sequence number sequence. A mismatched response + sequence number indicates a problem. + * library.c: On read errors, clear USB HALT of the IN EP. + 2006-10-18 Marcus Meissner <ma...@je...> * library.c: added HP Photosmart M425 Modified: trunk/libgphoto2/camlibs/ptp2/library.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/library.c 2006-10-19 20:03:52 UTC (rev 9364) +++ trunk/libgphoto2/camlibs/ptp2/library.c 2006-10-21 19:15:52 UTC (rev 9365) @@ -832,12 +832,13 @@ Camera *camera = ((PTPData *)data)->camera; int toread, result = GP_ERROR, curread = 0; int usecontext = (size > CONTEXT_BLOCK_SIZE); - int progressid = 0; + int progressid = 0, tries = 0; GPContext *context = ((PTPData *)data)->context; /* Split into small blocks. Too large blocks (>1x MB) would * timeout. */ +retry: if (usecontext) progressid = gp_context_progress_start (context, (size/CONTEXT_BLOCK_SIZE), _("Downloading...")); while (curread < size) { @@ -864,6 +865,13 @@ *readbytes = curread; return (PTP_RC_OK); } else { + if (result == GP_ERROR_IO_READ) { + gp_log (GP_LOG_DEBUG, "ptp2/usbread", "Clearing halt on IN EP and retrying once.\n"); + gp_port_usb_clear_halt (camera->port, GP_PORT_USB_ENDPOINT_IN); + /* retrying only makes sense if we did not read anything yet */ + if ((tries++ < 1) && (curread == 0)) + goto retry; + } return (translate_gp_result (result)); } } Modified: trunk/libgphoto2/camlibs/ptp2/ptp.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp.c 2006-10-19 20:03:52 UTC (rev 9364) +++ trunk/libgphoto2/camlibs/ptp2/ptp.c 2006-10-21 19:15:52 UTC (rev 9365) @@ -449,7 +449,13 @@ } /* get response */ CHECK_PTP_RC(params->getresp_func(params, ptp)); - + if (ptp->Transaction_ID != params->transaction_id-1) { + ptp_error (params, + "PTP: Sequence number mismatch %d vs expected %d.", + ptp->Transaction_ID, params->transaction_id-1 + ); + return PTP_ERROR_BADPARAM; + } return ptp->Code; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |