Date: Fri, 26 Jan 1996 09:35:24 +0200 (EET) From: Seppo Kallio <kallio@beeblebrox.pccc.jyu.fi> To: questions@freebsd.org, hardware@freebsd.org Cc: Seppo Kallio <kallio@beeblebrox.pccc.jyu.fi> Subject: HP C1553A Autoloading DDS-2 DAT tape drive control? Message-ID: <Pine.BSF.3.91.960126091900.207C-100000@beeblebrox.pccc.jyu.fi>
next in thread | raw e-mail | index | archive | help
Hi, we have HP C1553A Autoloading DDS2 DAT tape drives attached to a FreeBSD node. Is there a program available that would allow me to fully manipulate the drive? I have code for HPUX and Solaris, but it is so OS dependend I cannot compile it in FreeBSD. Seppo /************************************************************* * * dds_changer.c * * Utility to control a DDS autochanger (eg. C1553A, C156XA) * HP S700 and SOLARIS only. * * Kevin Jones kev@hpcpbla.bri.hp.com * * eg. dds_changer [123456ne] /dev/rmt/3hcn * * 1..6 = Select cartridge * n = next cartridge * e = eject magazine * ******************************************************************* * * To make: cc -o dds_changer dds_changer.c * * For HPUX * You must use with major number 121, eg. * crw-rw-rw- 1 bin bin 121 0x20130f Feb 26 1993 3hcn * ***************************************************************/ #define SOLARIS #include <stdio.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #ifdef HPUX #include <sys/scsi.h> #else #ifdef SOLARIS #include <sys/scsi/impl/uscsi.h> #include <errno.h> #endif #endif int fd; int temp = 1; main(argc, argv) int argc; char *argv[]; { int stat; #ifdef HPUX struct sctl_io sctl_io; #else #ifdef SOLARIS struct uscsi_cmd scsi_cmd, *cmd = &scsi_cmd; #endif #endif if (argc < 3) { fprintf (stderr, "Usage: dds_changer [123456ne] device-filename\n"); exit(1); } #ifdef HPUX if ((fd = open (argv[2], O_RDWR | O_NDELAY)) < 0) #else #ifdef SOLARIS if ((fd = open(argv[2], O_RDWR | O_NONBLOCK)) < 0) #endif #endif { fprintf(stderr,"errno on %d\n",errno); perror("open:"); fprintf (stderr, "Couldn't open device: %s\n", argv[2]); /* exit(1); */ } #ifdef HPUX sctl_io.cdb_length = 6; sctl_io.data_length = 0; sctl_io.max_msecs = 100000; /* Allow 100 seconds */ sctl_io.flags = 0; /* Wrt, No WDTR, No ADTR, Use ATN */ sctl_io.cdb[0] = 0x1B; sctl_io.cdb[1] = 0x00; sctl_io.cdb[2] = 0x00; sctl_io.cdb[3] = 0x00; sctl_io.cdb[4] = 0x00; sctl_io.cdb[5] = 0x00; #else #ifdef SOLARIS cmd->uscsi_cdb = malloc( (size_t) 6); cmd->uscsi_cdblen = 0x06; cmd->uscsi_timeout = 30000; cmd->uscsi_flags = USCSI_WRITE; cmd->uscsi_bufaddr = 0; cmd->uscsi_buflen = 0; cmd->uscsi_cdb[0] = 0x1B; cmd->uscsi_cdb[1] = 0x00; cmd->uscsi_cdb[2] = 0x00; cmd->uscsi_cdb[3] = 0x00; cmd->uscsi_cdb[4] = 0x00; cmd->uscsi_cdb[5] = 0x00; #endif #endif switch (*argv[1]) { case 'e' : #ifdef HPUX sctl_io.cdb[5] = 0x80; #else #ifdef SOLARIS cmd->uscsi_cdb[5] = 0x80; #endif #endif break; case 'n' : break; default : if ((*argv[1] >= '1') && (*argv[1] <= '6')) { #ifdef HPUX sctl_io.cdb[3] = *argv[1] - '0'; sctl_io.cdb[4] = 0x01; #else #ifdef SOLARIS cmd->uscsi_cdb[3] = *argv[1] - '0'; cmd->uscsi_cdb[4] = 0x01; #endif #endif break; } fprintf (stderr, "Unrecognized option\n"); close (fd); exit (1); } for (temp = 0; temp < 2; ++temp) /* 2 tries in case we hit unit a ttention */ { #ifdef HPUX if (ioctl(fd, SIOC_IO, sctl_io) < 0) #else #ifdef SOLARIS if ((stat = ioctl (fd, USCSICMD ,cmd)) < 0) #endif #endif { fprintf(stderr,"errno on %d stat on %d\n",errno,stat); perror("write:"); fprintf (stderr, "Failed to exec IOCTL command !\n"); close (fd); exit (1); } else { close(fd); exit( 0); } #ifdef HPUX if (sctl_io.cdb_status == S_GOOD) { close (fd); exit (0); } else if ( (sctl_io.cdb_status != S_CHECK_CONDITION) || (sctl_io.sense_status != S_GOOD) || ((sctl_io.sense[2] & 0xF) != S_UNIT_ATTENTION) ) break; #endif } fprintf (stderr, "Device Reported Error !\n"); close (fd); exit (1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.960126091900.207C-100000>