Browse Source

Add support for little-endian word hexdumps.

git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5287 7894878c-1315-0410-8ee3-d5d059ff63e0
tags/v3.0.2
Jean Delvare 17 years ago
parent
commit
d34a2c94fc
  1. 1
      CHANGES
  2. 24
      eeprom/decode-dimms

1
CHANGES

@ -2,6 +2,7 @@ i2c-tools CHANGES
----------------- -----------------
SVN SVN
decode-dimms: Add support for little-endian word hexdumps
decode-vaio: Remove history decode-vaio: Remove history
i2cdetect: Support i2c bus passed by name i2cdetect: Support i2c bus passed by name
Shorten the usage message Shorten the usage message

24
eeprom/decode-dimms

@ -43,6 +43,9 @@ use Fcntl qw(:DEFAULT :seek);
use vars qw($opt_html $opt_bodyonly $opt_igncheck $use_sysfs $use_hexdump use vars qw($opt_html $opt_bodyonly $opt_igncheck $use_sysfs $use_hexdump
@vendors %decode_callback $revision @dimm_list %hexdump_cache); @vendors %decode_callback $revision @dimm_list %hexdump_cache);
use constant LITTLEENDIAN => "little-endian";
use constant BIGENDIAN => "big-endian";
$revision = '$Revision$ ($Date$)'; $revision = '$Revision$ ($Date$)';
$revision =~ s/\$\w+: (.*?) \$/$1/g; $revision =~ s/\$\w+: (.*?) \$/$1/g;
$revision =~ s/ \([^()]*\)//; $revision =~ s/ \([^()]*\)//;
@ -1132,8 +1135,13 @@ sub read_hexdump($)
foreach (split(/\s+/, $2)) { foreach (split(/\s+/, $2)) {
if (/^(..)(..)$/) { if (/^(..)(..)$/) {
$word |= 1; $word |= 1;
if ($use_hexdump eq LITTLEENDIAN) {
$bytes[$addr++] = hex($2);
$bytes[$addr++] = hex($1);
} else {
$bytes[$addr++] = hex($1); $bytes[$addr++] = hex($1);
$bytes[$addr++] = hex($2); $bytes[$addr++] = hex($2);
}
} else { } else {
$bytes[$addr++] = hex($_); $bytes[$addr++] = hex($_);
} }
@ -1141,7 +1149,7 @@ sub read_hexdump($)
} }
close F; close F;
$header and die "Unable to parse any data from hexdump '$_[0]'"; $header and die "Unable to parse any data from hexdump '$_[0]'";
$word and printc "Warning: Assuming big-endian order 16-bit hex dump";
$word and printc "Using $use_hexdump 16-bit hex dump";
# Cache the data for later use # Cache the data for later use
$hexdump_cache{$_[0]} = \@bytes; $hexdump_cache{$_[0]} = \@bytes;
@ -1177,21 +1185,23 @@ sub readspd64($$) # reads 64 bytes from SPD-EEPROM
# Parse command-line # Parse command-line
foreach (@ARGV) { foreach (@ARGV) {
if ($_ eq '-h' || $_ eq '--help') { if ($_ eq '-h' || $_ eq '--help') {
print "Usage: $0 [-c] [-f [-b]] [-x file [files..]]\n",
print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n",
" $0 -h\n\n", " $0 -h\n\n",
" -f, --format Print nice html output\n", " -f, --format Print nice html output\n",
" -b, --bodyonly Don't print html header\n", " -b, --bodyonly Don't print html header\n",
" (useful for postprocessing the output)\n", " (useful for postprocessing the output)\n",
" -c, --checksum Decode completely even if checksum fails\n", " -c, --checksum Decode completely even if checksum fails\n",
" -x, Read data from hexdump files\n", " -x, Read data from hexdump files\n",
" -X, Same as -x except treat multibyte hex\n",
" data as little endian\n",
" -h, --help Display this usage summary\n"; " -h, --help Display this usage summary\n";
print <<"EOF"; print <<"EOF";
Hexdumps can be the output from hexdump, hexdump -C, i2cdump, eeprog and Hexdumps can be the output from hexdump, hexdump -C, i2cdump, eeprog and
likely many other progams producing hex dumps of one kind or another. Note likely many other progams producing hex dumps of one kind or another. Note
that the default output of "hexdump" will be byte-swapped on little-endian that the default output of "hexdump" will be byte-swapped on little-endian
systems and will therefore not be parsed correctly. It is better to use
"hexdump -C", which is not ambiguous.
systems and you must use -X instead of -x, otherwise the dump will not be
parsed correctly. It is better to use "hexdump -C", which is not ambiguous.
EOF EOF
exit; exit;
} }
@ -1209,7 +1219,11 @@ EOF
next; next;
} }
if ($_ eq '-x') { if ($_ eq '-x') {
$use_hexdump = 1;
$use_hexdump = BIGENDIAN;
next;
}
if ($_ eq '-X') {
$use_hexdump = LITTLEENDIAN;
next; next;
} }

Loading…
Cancel
Save