diff options
author | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2008-06-11 13:27:11 +0000 |
---|---|---|
committer | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2008-06-11 13:27:11 +0000 |
commit | d3adc667ee5748b347596992f49a7e1174899a1e (patch) | |
tree | 0f4145ca85a125735e4517e382b5b4a2dc272f8f /stub | |
parent | 0e786431885a703a8d595ed85806415a1e2bd227 (diff) | |
download | i2c-tools-d3adc667ee5748b347596992f49a7e1174899a1e.tar.gz |
Add support for partial dumps.
Report if only garbage is found in dump file.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5280 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'stub')
-rwxr-xr-x | stub/i2c-stub-from-dump | 13 |
1 files changed, 10 insertions, 3 deletions
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 (<DUMP>) { - 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); |