From 31177ee398831c9d137a8574479785b6db9779ea Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 20 Mar 2009 14:32:08 +0000 Subject: [PATCH] Add an option to merge identical cells. This makes the output even clearer. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5702 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 2 ++ eeprom/decode-dimms | 31 +++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index ca5a3a9..f67b192 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ SVN decode-dimms: Handle CRC of FB-DIMM and DDR3 SDRAM memory modules Add support for DDR3 SDRAM Fix decoding of SDR SDRAM bytes 12-14 + Add side-by-side formatting option + Add merged cells formatting option decode-xeon: Delete i2c-stub-from-dump: Use udev settle to speed up initialization diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index 62ad29f..f21b650 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -5,7 +5,7 @@ # Copyright 1998, 1999 Philip Edelbrock # modified by Christian Zuckschwerdt # modified by Burkart Lingner -# Copyright (C) 2005-2008 Jean Delvare +# Copyright (C) 2005-2009 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -40,8 +40,8 @@ require 5.004; use strict; use POSIX qw(ceil); use Fcntl qw(:DEFAULT :seek); -use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_igncheck - $use_sysfs $use_hexdump +use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge + $opt_igncheck $use_sysfs $use_hexdump @vendors %decode_callback $revision @dimm $current %hexdump_cache); use constant LITTLEENDIAN => "little-endian"; @@ -359,6 +359,15 @@ sub html_encode($) return $text; } +sub same_values(@) +{ + my $value = shift; + while (@_) { + return 0 unless $value eq shift; + } + return 1; +} + sub real_printl($$) # print a line w/ label and values { my ($label, @values) = @_; @@ -368,9 +377,17 @@ sub real_printl($$) # print a line w/ label and values $label = html_encode($label); @values = map { html_encode($_) } @values; print "$label"; - print "$_" foreach @values; + if ($opt_merge && same_values(@values)) { + print "$values[0]"; + } else { + print "$_" foreach @values; + } print "\n"; } else { + if ($opt_merge && same_values(@values)) { + splice(@values, 1); + } + my $format = "%-47s".(" %-19s" x (scalar @values - 1))." %s\n"; my $maxl = 0; # Keep track of the max number of lines @@ -1595,6 +1612,8 @@ foreach (@ARGV) { " -b, --bodyonly Don't print html header\n", " (useful for postprocessing the output)\n", " --side-by-side Display all DIMMs side-by-side if possible\n", + " --merge-cells Merge neighbour cells with identical values\n", + " (side-by-side output only)\n", " -c, --checksum Decode completely even if checksum fails\n", " -x, Read data from hexdump files\n", " -X, Same as -x except treat multibyte hex\n", @@ -1623,6 +1642,10 @@ EOF $opt_side_by_side = 1; next; } + if ($_ eq '--merge-cells') { + $opt_merge = 1; + next; + } if ($_ eq '-c' || $_ eq '--checksum') { $opt_igncheck = 1; next;