From 498b85aa94007bf04cc2c8ec6a5c91243fa46cfb Mon Sep 17 00:00:00 2001 From: fredlcore Date: Mon, 21 Oct 2024 05:57:10 +0200 Subject: [PATCH] Bugfix --- scripts/dump_eeprom.pl | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/dump_eeprom.pl b/scripts/dump_eeprom.pl index 2b223c8..cc8cc5b 100644 --- a/scripts/dump_eeprom.pl +++ b/scripts/dump_eeprom.pl @@ -1,5 +1,11 @@ #!/usr/bin/perl +# This Perl script extracts information from a binary dump of the EEPROM +# of a Zucchetti AM2000 motherboard. The EEPROM on the board is located in +# different positions, but can be read using a standard EEPROM reader and has +# a size of 2kB. +# Usage: ./dump_eeprom.pl + open (EEPROM, "$ARGV[0]"); while ($line = ) { $dump .= $line; @@ -8,13 +14,13 @@ $dump_layout = unpack("C", substr($dump, 1, 1)); @structure = ( - "Model code", "0x%X", "C", 0x00, 1, 1, - "Password", "%04d", "n", 0x57, 2, 1, - "First charge (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x89,3, 1, - "Last service (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x83,3, 1, + "Model code", "0x%X", "C", 0x00, 1, 0, + "Password", "%04d", "n", 0x57, 2, 0, + "First charge (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x89,3, 0, + "Last service (Y/M/D)", "20%02d/%02d/%02d", "CCC", 0x83,3, 0, "Total work time", "%d hours", "L>", 0x53, 4, 1/60, - "Last error (Y/M/D)", "20%d/%02d/%02d", "CCC", 0x4b,3, 1, - "Last Bluetooth device", "%02X:%02X:%02X:%02X:%02X:%02X","CCCCCC", 0x0f, 6, 1 + "Last error (Y/M/D)", "20%d/%02d/%02d", "CCC", 0x4b,3, 0, + "Last Bluetooth device", "%02X:%02X:%02X:%02X:%02X:%02X","CCCCCC", 0x0f, 6, 0, ); for ($x=0; $x 0x6E && $dump_layout < 0x14) { $index--; } - print sprintf("$desc: $format\n", unpack($pattern, substr($dump, $index-$offset, $len)) * $factor); + @value = unpack($pattern, substr($dump, $index, $len)); + if ($factor) { + $value[0] = $value[0] * $factor; + } + print sprintf("$desc: $format\n", @value); }