diff --git a/CHANGES b/CHANGES index 13fabde..322d841 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,8 @@ SVN Split the code into several functions for clarity Add support for short writes (SMBus send byte) Better error message on missing adapter functionality + i2c-stub-from-dump: Add support for partial dumps + Report if only garbage is found in dump file 3.0.1 (2008-04-04) Drop the trailing .pl from all perl script names diff --git a/stub/i2c-stub-from-dump b/stub/i2c-stub-from-dump index 0a6f8ff..96045a2 100755 --- a/stub/i2c-stub-from-dump +++ b/stub/i2c-stub-from-dump @@ -73,24 +73,26 @@ sub process_dump open(DUMP, $dump) || die "Can't open $dump: $!\n"; OUTER_LOOP: while () { - if (m/^([0-9a-f]0):(( [0-9a-f]{2}){16})/) { + if (m/^([0-9a-f]0):(( [0-9a-fX]{2}){16})/) { # Byte dump my $offset = hex($1); my @values = split(/ /, $2); shift(@values); for (my $i = 0; $i < 16 && (my $val = shift(@values)); $i++) { + next if $val =~ m/X/; last OUTER_LOOP if system("i2cset", "-y", $bus_nr, $addr, sprintf("0x\%02x", $offset+$i), "0x$val", "b"); $bytes++; } - } elsif (m/^([0-9a-f][08]):(( [0-9a-f]{4}){8})/) { + } elsif (m/^([0-9a-f][08]):(( [0-9a-fX]{4}){8})/) { # Word dump my $offset = hex($1); my @values = split(/ /, $2); shift(@values); for (my $i = 0; $i < 8 && (my $val = shift(@values)); $i++) { + next if $val =~ m/X/; last OUTER_LOOP if system("i2cset", "-y", $bus_nr, $addr, sprintf("0x\%02x", $offset+$i), @@ -149,4 +151,9 @@ if ($words) { $bus_nr, oct($addr); } -exit($bytes + $words == 0); +if ($bytes + $words == 0) { + printf SAVEOUT "Only garbage found in dump file $ARGV[1]\n"; + exit(1); +} + +exit(0);