Hello,
my problem is following: I try to use Epson 1200U USB scanner and get
communication(?) errors. I tried different kernels (I use currently 2.4.0-test1-ac15)
and
different computers (Gateway GP7-550 and IBM 300GL) but it fails in all the
cases no matter if I use UHCI or UHCI-alt driver. From /dev/bus/usb/devices I
conclude that the scanner is recognized:
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.00 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 0.00
S: Product=USB UHCI-alt Root Hub
S: SerialNumber=ff00
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=255ms
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1
P: Vendor=04b8 ProdID=0104 Rev= 1.03
S: Manufacturer=EPSON
S: Product=Perfection1200
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr= 2mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=usbscanner
E: Ad=81(I) Atr=02(Bulk) MxPS= 64 Ivl= 0ms
E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl= 0ms
When I realized that sane doesn't work out of the box, I asked Karl Heinz for
help and he sent me attached program for testing the communication. The output
is:
Opening /dev/usb/scanner0...
writing sequence...
reading ack message.
read 1 bytes
Asking for ident string.
REading answer...
read 1 bytes of ident
Did not receive STX
in_buf[0] = 0x15
It basically means that the scanner reset is successful but when asked for
identity string, the scanner or the scanner module answers NAK.
Has anyone seen it, too? Any clues? What is the best approach to debug this
problem (I know how to debug ordinary programs, but never tried to debug kernel, or
kernel modules). Is there any other information you would like to get?
/Pawel
--
Pawel Salek ([EMAIL PROTECTED]) http://www.theochem.kth.se/~pawsa/
Theoretical Chemistry Division, KTH voice: +46 8 790-8202
#define USB_DEVICE "/dev/usb/scanner0"
#define MAX_BUF_LEN (1024 + 1)
#define ACK 0x06
#define STX 0x02
#define NAK 0x15
#define ESC 0x1B
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
typedef struct
{
u_char code;
u_char status;
u_short count;
u_char buf[1];
} EpsonHdrRec, *EpsonHdr;
int
main(int argc, char *argv[])
{
int flags;
int fd;
unsigned int result;
int len;
EpsonHdr head;
u_char in_buf[MAX_BUF_LEN];
u_char out_buf[MAX_BUF_LEN];
#ifdef _O_RDWR
flags = _O_RDWR;
#else
flags = O_RDWR;
#endif
#ifdef _O_EXCL
flags |= _O_EXCL;
#else
flags |= O_EXCL;
#endif
#ifdef _O_BINARY
flags |= _O_BINARY;
#endif
#ifdef O_BINARY
flags |= O_BINARY;
#endif
fprintf(stderr, "Opening %s...\n", USB_DEVICE);
fd = open(USB_DEVICE, flags);
if (fd < 0)
{
fprintf(stderr, "Can not open device %s\n", USB_DEVICE);
exit (fd);
}
/* send reset to scanner */
strcpy(out_buf, "\033@");
fprintf(stderr,"writing sequence...\n");
result = write(fd, out_buf, strlen(out_buf));
if (result != strlen(out_buf))
{
fprintf(stderr, "Error writing %d bytes, actually written %d bytes\n", strlen(out_buf), result);
exit(-1);
}
/* read ACK message */
fprintf(stderr,"reading ack message.\n");
result = read(fd, in_buf, MAX_BUF_LEN);
fprintf(stderr, "read %d bytes\n", result);
if (in_buf[0] != ACK)
{
unsigned int i;
fprintf(stderr, "Did not receive ACK\n");
for (i=0; i< result; i++)
{
fprintf(stderr, "\tin_buf[%d] = 0x%02x\n", i, in_buf[i]);
}
exit(-1);
}
/* get scanner ident msg */
strcpy(out_buf, "\033i");
fprintf(stderr,"Asking for ident string.\n");
result = write(fd, out_buf, strlen(out_buf));
if (result != strlen(out_buf))
{
fprintf(stderr, "Error writing %d bytes, actually written %d bytes\n", strlen(out_buf), result);
exit(-1);
}
/* read ident result */
fprintf(stderr,"REading answer...\n");
result = read(fd, in_buf, MAX_BUF_LEN);
fprintf(stderr, "read %d bytes of ident\n", result);
if (in_buf[0] != STX)
{
unsigned int i;
fprintf(stderr, "Did not receive STX\n");
for (i=0; i< result; i++)
{
fprintf(stderr, "\tin_buf[%d] = 0x%02x\n", i, in_buf[i]);
}
exit(-1);
}
/* read actual ident data */
head = (EpsonHdr) in_buf;
len = head->count;
result = read(fd, in_buf, len);
fprintf(stderr, "read %d bytes\n", result);
fprintf(stderr, "Optical resolution: %d\n", in_buf[0] + 256 * in_buf[1]);
fprintf(stderr, "Structure of Sensor: 0x%02x\n", in_buf[2]);
fprintf(stderr, "Scanning order: %d\n", in_buf[3]);
fprintf(stderr, "line distance (1st - 2nd): %d\n", in_buf[4]);
fprintf(stderr, "line distance (2st - 3nd): %d\n", in_buf[5]);
fprintf(stderr, "main resolution[1]: %d\n", in_buf[14] + 256 * in_buf[15]);
fprintf(stderr, "main resolution[2]: %d\n", in_buf[16] + 256 * in_buf[17]);
fprintf(stderr, "main resolution[3]: %d\n", in_buf[18] + 256 * in_buf[19]);
fprintf(stderr, "main resolution[4]: %d\n", in_buf[20] + 256 * in_buf[21]);
fprintf(stderr, "main resolution[5]: %d\n", in_buf[22] + 256 * in_buf[23]);
fprintf(stderr, "main resolution[6]: %d\n", in_buf[24] + 256 * in_buf[25]);
fprintf(stderr, "main resolution[7]: %d\n", in_buf[26] + 256 * in_buf[27]);
fprintf(stderr, "sub resolution[1]: %d\n", in_buf[30] + 256 * in_buf[31]);
fprintf(stderr, "sub resolution[2]: %d\n", in_buf[32] + 256 * in_buf[33]);
fprintf(stderr, "sub resolution[3]: %d\n", in_buf[34] + 256 * in_buf[35]);
fprintf(stderr, "sub resolution[4]: %d\n", in_buf[36] + 256 * in_buf[37]);
fprintf(stderr, "sub resolution[5]: %d\n", in_buf[38] + 256 * in_buf[39]);
fprintf(stderr, "sub resolution[6]: %d\n", in_buf[40] + 256 * in_buf[41]);
/*
* start scan
*/
strcpy(out_buf, "\033G");
result = write(fd, out_buf, strlen(out_buf));
if (result != strlen(out_buf))
{
fprintf(stderr, "Error writing %s bytes, actually written %d bytes\n", strlen(out_buf), result);
exit(-1);
}
/*
* read result
*/
result = read(fd, in_buf, MAX_BUF_LEN);
fprintf(stderr, "read %d bytes\n", result);
switch (in_buf[0]) {
case STX : fprintf(stderr, "found STX\n");
fprintf(stderr, "status = 0x%02x\n", in_buf[1]);
fprintf(stderr, "size = %d\n", in_buf[2] + 256 * in_buf[3]);
result = read(fd, in_buf, MAX_BUF_LEN);
fprintf(stderr, "read %d bytes\n", result);
break;
case ACK : fprintf(stderr, "found ACK\n");
break;
default : fprintf(stderr, "found 0x%02x\n", in_buf[0]);
}
close(fd);
exit (0);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]