Subject: SCSI question
To: None <port-i386@netbsd.org>
From: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
List: port-i386
Date: 11/27/1999 19:43:20
--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Hi!
I've extracted the "inquiry" part of SANE, which hangs on my
computer. I'm using a Microtek scanner on an Adaptec 1502.
The symptoms are that the scanner reacts (it makes a noise), but the
ioctl never returns.
Could someone give me a hint how to further debug this problem?
Is the SCSI command okay?
Is the comment about the timeout correct? I've waited for more than a
minute without any reaction.
TIA,
Thomas
--
Thomas Klausner - wiz@danbala.tuwien.ac.at
WWW-homepage: http://fbma.tuwien.ac.at/~e9325658/Welcome.html
Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und
das nennen sie ihren Standpunkt. (found on /.)
--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="scsi_hang.c"
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/scsiio.h>
int
main()
{
int fd;
scsireq_t hdr;
int ret;
unsigned char src[] = { 0x12, 0x0, 0x0, 0x0, 0x60, 0x0 };
unsigned char dst[100];
size_t dst_size;
fd = open("/dev/scanner", O_RDWR|O_EXCL);
if (fd < 0)
{
fprintf(stderr, "can't open device: %s", strerror(errno));
return 1;
}
memset (&hdr, 0, sizeof (hdr));
memcpy (hdr.cmd, src, 6);
dst_size = sizeof(dst);
hdr.flags = SCCMD_READ;
hdr.databuf = dst;
hdr.datalen = dst_size;
/* SANE comment says, next line sets a 1 minute timeout */
hdr.timeout = 60000;
hdr.cmdlen = 6;
hdr.senselen = sizeof (hdr.sense);
ret = ioctl(fd, SCIOCCOMMAND, &hdr);
if (ret < 0)
{
fprintf(stderr, "ioctl failed: %s", strerror(errno));
return 1;
}
close(fd);
return 0;
}
--YZ5djTAD1cGYuMQK--