Tidy poll call in kodakaio

merge-requests/1/head
Paul Newall 2012-08-09 16:33:41 +01:00
rodzic 245c9600f3
commit 9ed65d3ea2
4 zmienionych plików z 3227 dodań i 24 usunięć

Wyświetl plik

@ -1,3 +1,7 @@
2012-08-09 Paul Newall <quandry at ntlworld dot com>
* /backend/kodakaio.c:
calling of poll tidied up, may fix problems with repeated scans.
2012-07-30 Stéphane Voltz <stef.dev@free.fr>
* doc/sane-genesys.man backend/genesys_low.h backend/genesys*.c:
rewrite lineart emulation du to bugs exhibited by the use of the

Wyświetl plik

@ -18,7 +18,7 @@
/* convenient lines to paste
export SANE_DEBUG_KODAKAIO=40
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var BACKENDS=kodakaio
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-latex BACKENDS=kodakaio
*/
/* SANE-FLOW-DIAGRAM Kodakaio commands in [] brackets
@ -114,7 +114,7 @@ export SANE_DEBUG_KODAKAIO=40
#define KODAKAIO_VERSION 02
#define KODAKAIO_REVISION 4
#define KODAKAIO_BUILD 2
#define KODAKAIO_BUILD 3
/* for usb (but also used for net). I don't know if this size will always work */
/* #define MAX_BLOCK_SIZE 32768 */
@ -186,9 +186,9 @@ normal levels. This system is a plan rather than a reality
#define min(x,y) (((x)<(y))?(x):(y))
/* I think these timeouts are defaults, overridden by any timeouts in the kodakaio.conf file */
static int MC_SNMP_Timeout = 2500;
static int MC_Scan_Data_Timeout = 40000;
static int MC_Request_Timeout = 5000;
static int K_SNMP_Timeout = 2500;
static int K_Scan_Data_Timeout = 40000;
static int K_Request_Timeout = 5000;
/* This file is used to store directly the raster returned by the scanner for debugging
If RawScanPath has no length it will not be created */
@ -635,30 +635,39 @@ kodakaio_net_read(struct KodakAio_Scanner *s, unsigned char *buf, size_t wanted,
{
size_t size, read = 0;
struct pollfd fds[1];
int pollreply;
*status = SANE_STATUS_GOOD;
/* poll for data-to-be-read (using MC_Request_Timeout) */
/* poll for data-to-be-read (using K_Request_Timeout) */
fds[0].fd = s->fd;
fds[0].events = POLLIN;
if (poll (fds, 1, MC_Request_Timeout) <= 0) {
fds[0].revents = 0;
if (pollreply = poll (fds, 1, K_Request_Timeout) <= 0) {
if (pollreply ==0)
DBG(1, "poll timeout\n");
else
DBG(1, "poll error\n");
*status = SANE_STATUS_IO_ERROR;
return read;
}
else if(fds[0].revents & POLLIN) {
while (read < wanted) {
size = sanei_tcp_read(s->fd, buf + read, wanted - read);
while (read < wanted) {
size = sanei_tcp_read(s->fd, buf + read, wanted - read);
if (size == 0)
if (size == 0)
break;
read += size;
}
read += size;
}
if (read < wanted)
*status = SANE_STATUS_IO_ERROR;
DBG(32, "net read %d bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]);
return read;
if (read < wanted)
*status = SANE_STATUS_IO_ERROR;
DBG(32, "net read %d bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]);
return read;
}
else
DBG(1, "Unknown problem with poll\n");
}
/* kodak does not pad commands like magicolor, so there's only a write_raw function */
@ -1157,15 +1166,15 @@ when you get the ackstring return EOF status
*/
KodakAio_Scanner *s = (KodakAio_Scanner *) handle;
SANE_Status status;
int oldtimeout = MC_Request_Timeout;
int oldtimeout = K_Request_Timeout;
size_t bytecount;
/* DBG(8, "%s\n", __func__); */
/* Temporarily set the poll timeout long instead of short,
* because a color scan needs >5 seconds to initialize. Is this needed for kodak?*/
MC_Request_Timeout = MC_Scan_Data_Timeout;
sanei_usb_set_timeout (MC_Scan_Data_Timeout);
K_Request_Timeout = K_Scan_Data_Timeout;
sanei_usb_set_timeout (K_Scan_Data_Timeout);
bytecount = k_recv(s, buf, *len, &status);
*len = bytecount;
s->bytes_unread -= bytecount;
@ -1174,7 +1183,7 @@ when you get the ackstring return EOF status
only compare 4 bytes because we sometimes get escSS02.. or escSS00.. */
if (cmparray(buf,KodakEsp_Ack,4) == 0) status = SANE_STATUS_EOF;
MC_Request_Timeout = oldtimeout;
K_Request_Timeout = oldtimeout;
sanei_usb_set_timeout (oldtimeout);
if (status == SANE_STATUS_GOOD)
@ -2292,17 +2301,17 @@ attach_one_config(SANEI_Config __sane_unused__ *config, const char *line)
} else if (sscanf(line, "snmp-timeout %i\n", &timeout)) {
/* Timeout for SNMP network discovery */
DBG(50, "%s: SNMP timeout set to %d\n", __func__, timeout);
MC_SNMP_Timeout = timeout;
K_SNMP_Timeout = timeout;
} else if (sscanf(line, "scan-data-timeout %i\n", &timeout)) {
/* Timeout for scan data requests */
DBG(50, "%s: Scan data timeout set to %d\n", __func__, timeout);
MC_Scan_Data_Timeout = timeout;
K_Scan_Data_Timeout = timeout;
} else if (sscanf(line, "request-timeout %i\n", &timeout)) {
/* Timeout for all other read requests */
DBG(50, "%s: Request timeout set to %d\n", __func__, timeout);
MC_Request_Timeout = timeout;
K_Request_Timeout = timeout;
} else {
/* TODO: Warning about unparsable line! */

3189
backend/kodakaio2.c 100644

Plik diff jest za duży Load Diff

1
doc/missfont.log 100644
Wyświetl plik

@ -0,0 +1 @@
mktextfm ptmr7t