Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jun 1996 03:06:31 +0200 (MET DST)
From:      Juergen Lock <nox@jelal.hb.north.de>
To:        bob@luke.pmr.com
Cc:        scsi@freebsd.org
Subject:   Re: Questions about Archive Python DAT autoloader
Message-ID:  <199606240106.DAA26925@saturn.hb.north.de>
In-Reply-To: <199606221751.MAA17716@luke.pmr.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <199606221751.MAA17716@luke.pmr.com> you write:
>I have an Archive Python 4586 DAT autoloader that I have no
>information about and was hoping someone could tell me what the
>DIP switches on the back control.

Cant help on that one (well who bought Archive again?  maybe they
have it on a web site...)

> Also, how can I get it to change
>to a different tape?

 but if its similar to the HP DAT autoloader then this might get you started:

#! /usr/bin/suidperl
$ENV{'PATH'} = '/bin:/usr/bin';
$ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne '';
$ENV{'IFS'} = '' if $ENV{'IFS'} ne '';

# A gross hack to control a HP 1553A tape changer, it uses a single
# SCSI address for both tape io and changer commands (MOVE MEDIUM)...

# tape (control device)
$tape = "/dev/rst0.ctl";
# scsi command timeout
$timeout = "3000";

$load = $ARGV[0];
$loop = 0;
$first = 1;
if ($load eq "0") {
	# `reset': unload to first free slot
	$src = 1;
	$dest = 2;
	$loop = 1;
} elsif ($load > 0) {
	# load #slot
	$src = $load + 1;
	$dest = 1;
	exit 2 if ($src > 7);
} elsif ($load < 0) {
	# unload to #slot
	$src = 1;
	$dest = -$load + 1;
	exit 2 if ($dest > 7);
} else {
	print "Usage: hp1553a slot|0\n";
	print "	0:	reset (catch unit attention, unload to first free slot)\n";
	print "	slot:	load slot\n";
	print "	-slot:	unload to slot\n";
	exit 2;
}

movemedium: while ($loop || $first) {
	# a5 == `MOVE MEDIUM'
	$c = "a5 0 0 0 00 $src 00 $dest 0 0 0 0";
	uattn: while (42) {
		$res = 0;
		$| = 1;
		do {
		    $pid = open(KID_TO_READ, "-|");
		    unless (defined $pid) {
			#warn "cannot fork: $!";
			#die "bailing out" if $sleep_count++ > 6;
			exit 2 if $sleep_count++ > 6;
			sleep 10;
		    }
		} until defined $pid;
		if ($pid) {   # parent
		    $| = 1;
		    $res = 0;
		    $s = '';
		    while (<KID_TO_READ>) {
			# debug:
			#print $_;
			$s .= $_;
			if (s/^Sense key is "(.*)"$/$1/) {
			   if (/^Unit attention/) {
				   $res = 2;
				   $first = 0 unless ($loop);
			   } elsif (/^Illegal request/) {
				   $res = 1;
				   $first = 0;
			   } else {
				   $res = 2;
				   $first = 0;
			   }
			}
		    }
		    if (!close(KID_TO_READ)) {
			$res = $? >> 8;
			exit 2 unless (!$res);
		    }

		} else {      # child
		    $| = 1;
		    ($EUID, $EGID) = ($UID, $GID); # suid only
		    open(STDERR, ">&STDOUT");
		    exec "/sbin/scsi", "-f", $tape, "-s", $timeout, "-c", $c;
		    exit 2;
		    # NOTREACHED
		}

		if ($first) {
			$first = 0;
			if ($res == 2) {
				# maybe got a unit attention, retry
				next uattn;
			}
		}
		last uattn;
	}
	if ($res && $loop) {
		if ($src == 1) {
			# `reset': unload failed, try next slot
			if ($dest < 7) {
				++$dest;
				next movemedium;
			} else {
				# done all slots
				$res = 0;
			}
		}
	}
	$loop = 0;
}
exit $res;
--------cut------

 ATB
	Juergen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606240106.DAA26925>