mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-01 01:09:47 +00:00
6e80b10ba4
git-svn-id: https://svn.fhem.de/fhem/trunk@201 2b470e98-0d58-463d-a4d8-8e2adae1ed80
29 lines
668 B
Perl
29 lines
668 B
Perl
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
use strict;
|
|
|
|
if(@ARGV != 3) {
|
|
die("Usage: extract_fw.pl update.exe <hex_offset> <output_file>\n" .
|
|
" <hex_offset> is usually 25808\n")
|
|
}
|
|
|
|
open(IN, $ARGV[0]) || die("$ARGV[0]: $!\n");
|
|
open(OUT, ">$ARGV[2]") || die("$ARGV[2]: $!\n");
|
|
|
|
my ($b1, $b2);
|
|
my $len = hex($ARGV[1]);
|
|
(sysread(IN, $b1, $len) == $len) || die("Cannot read $ARGV[1]/$len bytes\n");
|
|
|
|
my $count = 0;
|
|
for(;;) {
|
|
(sysread(IN, $b1, 2) == 2) || last;
|
|
$len = unpack("n", $b1);
|
|
($len <= 255) || last;
|
|
(sysread(IN, $b2, $len) == $len) || last;
|
|
print OUT unpack("H*", $b1) . unpack("H*", $b2) . "\n";
|
|
$count++;
|
|
}
|
|
print "Read $count packets\n";
|
|
exit(0);
|