/[mdap]/bin/fw-info.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /bin/fw-info.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 73 - (hide annotations)
Sun Nov 18 14:17:54 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: text/plain
File size: 833 byte(s)
 r108@brr:  dpavlin | 2007-11-18 15:17:49 +0100
 moved to bin dir

1 dpavlin 5 #!/usr/bin/perl -w
2    
3     # fw-info.pl
4     #
5     # 04/22/07 16:33:13 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6    
7     use strict;
8     use Data::Dump qw/dump/;
9    
10 dpavlin 34 my @images = @ARGV;
11     push @images, '/srv/tftp/BANT-R' unless @images;
12 dpavlin 5
13 dpavlin 18 my $magic = 'BLI223QH0';
14    
15 dpavlin 59 sub get_from {
16     my ($fh,$seek,$len) = @_;
17     my $b;
18     seek($fh, $seek, 0) || die "can't seek to $seek: $!";
19     read($fh, $b, $len) || die "can't read $len bytes: $!";
20     return $b;
21     }
22    
23 dpavlin 34 for my $path ( @images ) {
24 dpavlin 59 next unless -f $path;
25 dpavlin 34 open(my $fh, $path) || die "Can't open $path: $!";
26     my $b;
27     read($fh, $b, length($magic));
28     warn "# $path not a firmware image\n" unless ($b eq $magic);
29 dpavlin 59 my $version = get_from($fh, 32, 4);
30     my $board = get_from($fh, 0x136, 6);
31     my $name = get_from($fh, 0x144, 15);
32     chomp($name);
33    
34     printf("%8s %6s %s\t%s\n", join('.',unpack('CCCC', $version)), $board, $name, $path);
35 dpavlin 34 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26