#!/usr/local/bin/perl #DNARD Rev. 5, 08:00:2b:81:5f:b6 , 32 MB memory #Open Firmware Built February 25, 1998 17:19:25 #Copyright 1997 FirmWorks All Rights Reserved $ddir = "/n/fast/usr/lsrc/flux/doc/dnard"; $hwfile = "$ddir/hardware"; &readhw(); $maxused++; while (1) { open(TIP, "/dev/cuaa0") || die "could not open dnard: $!\n"; while () { if (/Built (.*)/) { $bdate = $1; chop($bdate); &assign($num, $addr, $bdate); } if (/^DNARD Rev. ([0123456789]), ([^ ]+) , ([0123456789]+)/) { $rev = $1; $addr = $2; $mem = $3; chomp($addr); chomp($mem); if ($rev != 5) { print "\n!!! NOT a revision 5 DNARD: $_\n"; } if ($mem != 32) { print "\n!!! DOES NOT HAVE 32 megs: $_\n"; } # print "Address: $addr\n"; if ($HW{$addr}) { $num = $HW{$addr}; print "DNARD already found as number $num"; } else { print "Assinging it $maxused"; $num = $maxused; $maxused++; } print "... Please plug in the next DNARD\n"; } } close(TIP); } sub assign { local($num) = $_[0]; local($addr) = $_[1]; local($bdate) = $_[2]; local($serial); if ($HW{$addr}) { return; } print "\n\nEnter the DNARD serial number: "; $serial = ; print "Got $serial\n"; chomp($serial); $HW{$addr} = $num; open(HW, ">>$hwfile") || die "Could not open the hardware file\n"; printf(HW "%3.3d\t%s\t\t%s, Serial %s\n", $num, $addr, $bdate, $serial); close(HW); } sub readhw { open(HW, "$hwfile") || die "could not open hwfile: $!\n"; while () { chomp; s/#.*//; ($dnardno, $hwtail) = split; $HW{$hwtail} = $dnardno; if ($dnardno > $maxused) { $maxused = $dnardno; } } close(HW); }