home *** CD-ROM | disk | FTP | other *** search
- From: rdg@hpfcso.FC.HP.COM (Rob Gardner)
- Date: Tue, 21 Jul 1992 18:58:57 GMT
- Subject: Re: Writing a non-disc SCSI device driver for HP 700 (Snake)
- Message-ID: <7371158@hpfcso.FC.HP.COM>
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!mips!sdd.hp.com!hpscdc!cupnews0.cup.hp.com!hppad.waterloo.hp.com!hppad!hpfcso!rdg
- Newsgroups: comp.sys.hp
- References: <1992Jul21.141340.1615@sni.ca>
- Lines: 113
-
-
- > Can anyone out there point to to information that would allow me
- > to write a non-disc SCSI driver (printers, scanners in particular)
- > for HP-UX on a Snake? I have checked all the documentation we have
- > for our 710 and can't find anything other than dire warnings against
- > using unsupported equipment.
-
- In many cases, you can communicate with your device adequately using
- scsi ioctl's. These allow you to send raw scsi commands to a target
- without (much) interference from the disk driver. At the risk of
- reducing my job security (;-) I am posting an example program that
- you should be able to use to talk to your printer/scanner/whatever.
-
- > Is there a Device Driver manual somewhere that I have missed?
-
- No. There will undoubtedly be some responses to your message telling
- you about the HPUX Driver Development Guide, but you should ignore
- them. The DDG contains absotively no information on SCSI!
-
- Rob
-
- /*
- * Example SCSI ioctl program
- *
- * Use scsi disk driver (major 47)
- *
- */
-
- /*
- * This program is the creation of Rob Gardner, and is not for
- * sale, trade, or barter. It may not be copied for any reason.
- * It may not even be examined, and as a matter of fact, it is
- * forbidden for human eyes to see this program. You are probably
- * violating this decree right now. This program is probably the
- * property of Hewlett-Packard, since they own me and everything
- * I have ever done. May the Source be with you.
- */
-
-
- #include <sys/types.h>
- #include <sys/scsi.h>
- #include <fcntl.h>
- #include <stdio.h>
-
- struct scsi_cmd_parms scsi_inquiry = {
- 6, 1, 5000,
- 0x12, 0x00, 0x00, 0x00, 0xff, 0x00
- };
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int eid, flag = 1, ret;
- unsigned char buffer[256];
-
- if (argc < 2)
- {
- fprintf(stderr, "usage: %s device\n", argv[0]);
- exit(1);
- }
-
- eid = open(argv[1], O_RDWR | O_NDELAY);
- if (eid < 0)
- {
- perror("open");
- exit(2);
- }
-
- printf("-->Opened Succesfully eid = %d\n",eid);
-
- ret = ioctl(eid, SIOC_CMD_MODE, &flag);
- if (ret < 0)
- {
- perror("setting command mode");
- exit(3);
- }
-
- ioctl(eid, SIOC_SET_CMD, &scsi_inquiry);
-
- ret = read(eid, buffer, 256);
- if (ret < 0)
- {
- perror("inquiry");
- printf("ret = %d\n", ret);
- do_sense(eid);
- }
- else
- {
- struct inquiry *i = (struct inquiry *) buffer;
- printf("%s\n", i->vendor_id);
- }
- close(eid);
- }
-
-
- do_sense(eid)
- int eid;
- {
- char buffer[256];
- int ret;
- union sense_data *foo = (union sense_data *) buffer;
-
- if (ioctl(eid, SIOC_XSENSE, buffer) < 0) {
- perror("request sense");
- printf("ret = %d\n", ret);
- return;
- }
- printf("*error code = %d\n", buffer[0] & 0xf);
- printf("*sense key = %d\n", buffer[2] & 0xf);
- printf("*additional sense byte = 0x%x\n", buffer[8]);
- exit(42);
- }
-