=================================================================== RCS file: /cvs/trango/Net-Telnet-Trango/scripts/update_trango.pl,v retrieving revision 1.18 retrieving revision 1.21 diff -u -r1.18 -r1.21 --- trango/Net-Telnet-Trango/scripts/update_trango.pl 2007/01/31 19:01:12 1.18 +++ trango/Net-Telnet-Trango/scripts/update_trango.pl 2007/02/01 17:08:44 1.21 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $RedRiver: update_trango.pl,v 1.17 2007/01/31 18:44:27 mike Exp $ +# $RedRiver: update_trango.pl,v 1.20 2007/01/31 22:19:07 mike Exp $ ######################################################################## # update_trango.pl *** Updates trango foxes with a new firmware # @@ -50,7 +50,13 @@ next; } - if ($t->host_type ne $conf->{'type'}) { + my $host_type = $t->host_type; + + if (lc($conf->{'firmware_type'}) eq 'fpga') { + $host_type =~ s/\s.*$//; + } + + if ($host_type ne $conf->{'type'}) { $l->sp("Wrong type of unit ('" . $t->host_type . "' should be '$conf->{'type'}')"); $t->close; next; @@ -83,15 +89,20 @@ my $t = shift; my $file = shift; + my $fw_type = 'Firmware'; + if (uc($conf->{'firmware_type'}) eq 'FPGA') { + $fw_type = 'FPGA'; + } + my $ver = $t->ver; - $l->p("Current version '$ver->{'Firmware Version'}'"); + $l->p("Current version '" . $ver->{$fw_type . ' Version'} . "'"); if ( - $ver->{'Firmware Version'} eq $conf->{'ver'} && - $ver->{'Firmware Checksum'} eq $conf->{'cksum'} + $ver->{$fw_type . ' Version'} eq $conf->{'ver'} && + $ver->{$fw_type . ' Checksum'} eq $conf->{'cksum'} ) { $l->sp("Already updated!"); - return 1; + return 0; } my $try = 0; @@ -111,8 +122,10 @@ # use tftp to push the file up my $tftp = Net::TFTP->new($t->Host, Mode => 'octet'); - $tftp->put($file, $file) - or die "Error uploading: " . $tftp->error; + unless ($tftp->put($file, $file)) { + print "Error uploading: " . $tftp->error; + next; + } # waitfor some sort of output # make sure it says 'Success.' otherwise error @@ -126,7 +139,7 @@ if ( $results->{'File Checksum'} ne $conf->{'file_cksum'}) { $l->sp( "File checksum '" . $results->{'File Checksum'} . - "does not match config file '" . $conf->{'file_cksum'} . "'!" + " does not match config file '" . $conf->{'file_cksum'} . "'!" ); next; } @@ -150,9 +163,13 @@ } $l->p("File name matches . . . "); - $l->p("Updating flash (new checksum '$conf->{'cksum'}')"); + my $image_type = 'mainimage'; + if ($fw_type eq 'FPGA') { + $image_type = 'fpgaimage'; + } + $l->p("Updating $image_type (new checksum '$conf->{'cksum'}')"); unless ($results = $t->updateflash( - args => 'mainimage ' . $ver->{'Firmware Checksum'} . + args => $image_type . ' ' . $ver->{$fw_type . ' Checksum'} . ' ' . $conf->{'cksum'}, Timeout => 90, ) ) {