--Boundary-00=_WwDdAZYOumXfd5e Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline
I patch the code to count urb packets as suggested in: http://lists.alioth.debian.org/pipermail/sane-devel/2004-March/010534.html and I have some success, but it don't work well absolutely. I think that the problem is in th count of the urb read packets, and perhaps there is a better solution to make the number of packets even. I attach the patch. Thanks. Jose Alberto Reguero. --Boundary-00=_WwDdAZYOumXfd5e Content-Type: text/x-diff; charset="us-ascii"; name="snapscan-usb.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="snapscan-usb.patch" --- snapscan-usb.c 2004-04-07 19:18:21.189514624 +0200 +++ snapscan-usb.c.coque 2004-04-07 19:17:59.742775024 +0200 @@ -96,6 +96,8 @@ static struct sembuf sem_signal = { 0, 1, 0 }; static sense_handler_type usb_sense_handler; static void* usb_pss; +static int read_urb = 0; +static int write_urb = 0; /* Forward declarations */ static SANE_Status usb_request_sense(SnapScan_Scanner *pss); @@ -186,6 +188,36 @@ DBG (DL_CALL_TRACE, "%s(%d)\n", me, fd); semctl(sem_id, 0, IPC_RMID, dummy_semun_arg); + printf ("1 read %d write %d\n", read_urb, write_urb); + if ((read_urb % 2) == 1 && (write_urb % 2) == 1) + { + char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; + + snapscani_usb_cmd (fd, cmd, sizeof (cmd), NULL, 0); + } + else if ((read_urb % 2) == 1) + { + size_t read_bytes; + char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; + char cmd2[] = {INQUIRY, 0, 0, 0, 120, 0}; + char data[120]; + + read_bytes = 120; + snapscani_usb_cmd (fd, cmd2, sizeof (cmd2), data, &read_bytes); + snapscani_usb_cmd (fd, cmd, sizeof (cmd), NULL, 0); + } + else if ((write_urb %1) == 1) + { + size_t read_bytes; + char cmd[] = {INQUIRY, 0, 0, 0, 120, 0}; + char data[120]; + + read_bytes = 120; + snapscani_usb_cmd (fd, cmd, sizeof (cmd), data, &read_bytes); + } + printf ("2 read %d write %d\n", read_urb, write_urb); + read_urb = 0; + write_urb = 0; sanei_usb_close(fd); } @@ -241,6 +273,8 @@ DBG (DL_MAJOR_ERROR, "%s Only %d bytes written\n",me,bytes_written); status = SANE_STATUS_IO_ERROR; } + write_urb++; + printf ("write %d\n",n); return status; } @@ -255,6 +289,8 @@ DBG (DL_MAJOR_ERROR, "%s Only %d bytes read\n",me,bytes_read); status = SANE_STATUS_IO_ERROR; } + read_urb += ((63 + n) / 64); + printf ("read %d\n",n); DBG(DL_DATA_TRACE, "%s: reading: %s\n",me,usb_debug_data(dbgmsg,buf,n)); return status; --Boundary-00=_WwDdAZYOumXfd5e--