Changeset 1325 for lm-sensors/trunk/prog/eeprom/decode-vaio.pl
- Timestamp:
- 02/18/02 01:43:24 (11 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/prog/eeprom/decode-vaio.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/eeprom/decode-vaio.pl
r1309 r1325 18 18 # 19 19 # Version 0.1 2002-02-06 Jean Delvare <khali@linux-fr.org> 20 # Version 0.2 2002-02-16 Jean Delvare <khali@linux-fr.org> 21 # Fixed to work with the new, simplified /proc interface names of the eeprom driver 22 # (lm_sensors 2.6.3 and greater.) 23 # Shifted data display by 4 columns left. 24 # Version 0.3 2002-02-17 Jean Delvare <khali@linux-fr.org> 25 # Added UUID field at 0x10 (added decode_uuid.) 26 # Merged decode_string and decode_string32. 27 # Added unknown field at 0x20. 28 # Moved header and footer to BEGIN and END, respectivly. 29 # Reformated history to match those of the other decode scripts. 30 # Deleted decode_char (made useless by decode_string.) 31 # Reordered field display, changed some labels. 32 # Added old /proc interface check. 20 33 # 21 34 # EEPROM data decoding for Sony Vaio laptops. 22 35 # 23 # Two assumptions: lm_sensors-2. xinstalled,36 # Two assumptions: lm_sensors-2.6.3 or greater installed, 24 37 # and Perl is at /usr/bin/perl 25 38 # 26 # Please note that this is a guess-only work. I don't expect much help from27 # Sony, so if someone can provide information, please contact me. I used my39 # Please note that this is a guess-only work. Sony support refused to help 40 # me, so if someone can provide information, please contact me. I used my 28 41 # PCG-GR214EP as a base, but I can't promise that this script will work with 29 42 # other models. Any feedback appreciated anyway. … … 36 49 my ($label,$value) = @_; 37 50 38 printf("\%20s : \%s\n",$label,$value); 39 } 40 41 sub decode_char 42 { 43 my ($bus,$addr,$base,$offset,$length) = @_; 44 45 my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); 46 open(FH,$filename) || die "Can't open $filename"; 47 my $line=<FH>; 48 close(FH); 49 50 my @bytes=split(/[ \n]/,$line); 51 @bytes=@bytes[$offset..$offset+$length-1]; 52 my $string=''; 53 my $item; 54 while(defined($item=shift(@bytes))) 55 { 56 $string.=chr($item); 57 } 58 59 return($string); 51 printf("\%16s : \%s\n",$label,$value); 60 52 } 61 53 … … 64 56 my ($bus,$addr,$base,$offset,$length) = @_; 65 57 66 my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data$base-".($base+15); 67 open(FH,$filename) || die "Can't open $filename"; 68 my $line=<FH>; 69 close(FH); 58 my $line=''; 59 my $remains=$length+$offset; 60 while($remains>0) 61 { 62 my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/".sprintf('%02x',$base); 63 open(FH,$filename) || die "Can't open $filename"; 64 $line.=<FH>; 65 close(FH); 66 $remains-=16; 67 $base+=16; 68 } 70 69 71 70 my @bytes=split(/[ \n]/,$line); … … 81 80 } 82 81 83 sub decode_ string3282 sub decode_uuid 84 83 { 85 84 my ($bus,$addr,$base) = @_; 86 85 87 my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/ data$base-".($base+15);86 my $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/".sprintf('%02x',$base); 88 87 open(FH,$filename) || die "Can't open $filename"; 89 88 my $line=<FH>; 90 close(FH);91 $filename="/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/data".($base+16).'-'.($base+31);92 open(FH,$filename) || die "Can't open $filename";93 $line.=<FH>;94 89 close(FH); 95 90 … … 97 92 my $string=''; 98 93 my $item; 99 while(defined($item=shift(@bytes)) && ($item!=0)) 94 95 for(my $i=0;$i<16;$i++) 100 96 { 101 $string.=chr($item); 97 $string.=sprintf('%02x',shift(@bytes)); 98 if(($i==3)||($i==5)||($i==7)||($i==9)) 99 { 100 $string.='-'; 101 } 102 102 } 103 103 104 104 return($string); 105 105 } … … 109 109 my ($bus,$addr) = @_; 110 110 111 print_item('Model name',decode_string32($bus,$addr,128).' ['.decode_char($bus,$addr,160,10,4).']'); 111 print_item('Machine Name',decode_string($bus,$addr,128,0,32)); 112 print_item('Serial Number',decode_string($bus,$addr,192,0,32)); 113 print_item('UUID',decode_uuid($bus,$addr,16)); 112 114 print_item('Revision',decode_string($bus,$addr,160,0,10)); 113 print_item('Serial number',decode_string32($bus,$addr,192)); 114 print_item('Timestamp',decode_string32($bus,$addr,224)); 115 print_item('Model Number','PCG-'.decode_string($bus,$addr,160,10,4)); 116 print_item('?',decode_string($bus,$addr,32,0,16)); 117 print_item('?',decode_string($bus,$addr,224,0,32)); 115 118 } 116 119 117 print("Sony Vaio EEPROM Decoder\n"); 118 print("Written by Jean Delvare. Copyright 2002.\n"); 119 print("Version 0.1\n\n"); 120 BEGIN 121 { 122 print("Sony Vaio EEPROM Decoder\n"); 123 print("Written by Jean Delvare. Copyright 2002.\n"); 124 print("Version 0.3\n\n"); 125 } 126 127 END 128 { 129 print("\n"); 130 } 120 131 121 132 if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57') 122 133 { 123 vaio_decode('0','57'); 134 if ( -r '/proc/sys/dev/sensors/eeprom-i2c-0-57/data0-15') 135 { 136 print("Deprecated old interface found. Please upgrade to lm_sensors 2.6.3 or greater."); 137 } 138 else 139 { 140 vaio_decode('0','57'); 141 } 124 142 } 125 143 else 126 144 { 127 print("Vaio eepromnot found. Please make sure that the eeprom module is loaded.\n");145 print("Vaio EEPROM not found. Please make sure that the eeprom module is loaded.\n"); 128 146 print("If you believe this is an error, please contact me <khali\@linux-fr.org>\n"); 129 147 print("so that we may see how to fix the problem.\n"); 130 148 } 131 132 print("\n");
