| | 1070 | sub decode_manufacturing_information($) |
| | 1071 | { |
| | 1072 | my $bytes = shift; |
| | 1073 | my ($l, $temp, $extra); |
| | 1074 | |
| | 1075 | prints "Manufacturing Information"; |
| | 1076 | |
| | 1077 | $l = "Manufacturer"; |
| | 1078 | # $extra is a reference to an array containing up to |
| | 1079 | # 7 extra bytes from the Manufacturer field. Sometimes |
| | 1080 | # these bytes are filled with interesting data. |
| | 1081 | ($temp, $extra) = manufacturer(@{$bytes}[0..7]); |
| | 1082 | printl $l, $temp; |
| | 1083 | $l = "Custom Manufacturer Data"; |
| | 1084 | $temp = manufacturer_data(@{$extra}); |
| | 1085 | printl $l, $temp if defined $temp; |
| | 1086 | |
| | 1087 | if (spd_written($bytes->[8])) { |
| | 1088 | # Try the location code as ASCII first, as earlier specifications |
| | 1089 | # suggested this. As newer specifications don't mention it anymore, |
| | 1090 | # we still fall back to binary. |
| | 1091 | $l = "Manufacturing Location Code"; |
| | 1092 | $temp = (chr($bytes->[8]) =~ m/^[\w\d]$/) ? chr($bytes->[8]) |
| | 1093 | : sprintf("0x%.2X", $bytes->[8]); |
| | 1094 | printl $l, $temp; |
| | 1095 | } |
| | 1096 | |
| | 1097 | $l = "Part Number"; |
| | 1098 | $temp = part_number(@{$bytes}[9..26]); |
| | 1099 | printl $l, $temp; |
| | 1100 | |
| | 1101 | if (spd_written(@{$bytes}[27..28])) { |
| | 1102 | $l = "Revision Code"; |
| | 1103 | $temp = sprintf("0x%02X%02X\n", @{$bytes}[27..28]); |
| | 1104 | printl $l, $temp; |
| | 1105 | } |
| | 1106 | |
| | 1107 | if (spd_written(@{$bytes}[29..30])) { |
| | 1108 | $l = "Manufacturing Date"; |
| | 1109 | # In theory the year and week are in BCD format, but |
| | 1110 | # this is not always true in practice :( |
| | 1111 | if (($bytes->[29] & 0xf0) <= 0x90 |
| | 1112 | && ($bytes->[29] & 0x0f) <= 0x09 |
| | 1113 | && ($bytes->[30] & 0xf0) <= 0x90 |
| | 1114 | && ($bytes->[30] & 0x0f) <= 0x09) { |
| | 1115 | # Note that this heuristic will break in year 2080 |
| | 1116 | $temp = sprintf("%d%02X-W%02X\n", |
| | 1117 | $bytes->[29] >= 0x80 ? 19 : 20, |
| | 1118 | @{$bytes}[29..30]); |
| | 1119 | } else { |
| | 1120 | $temp = sprintf("0x%02X%02X\n", |
| | 1121 | @{$bytes}[29..30]); |
| | 1122 | } |
| | 1123 | printl $l, $temp; |
| | 1124 | } |
| | 1125 | |
| | 1126 | if (spd_written(@{$bytes}[31..34])) { |
| | 1127 | $l = "Assembly Serial Number"; |
| | 1128 | $temp = sprintf("0x%02X%02X%02X%02X\n", |
| | 1129 | @{$bytes}[31..34]); |
| | 1130 | printl $l, $temp; |
| | 1131 | } |
| | 1132 | } |
| | 1133 | |
| | 1134 | # Parameter: bytes 64-127 |
| 1348 | | |
| 1349 | | $l = "Manufacturer"; |
| 1350 | | # $extra is a reference to an array containing up to |
| 1351 | | # 7 extra bytes from the Manufacturer field. Sometimes |
| 1352 | | # these bytes are filled with interesting data. |
| 1353 | | ($temp, my $extra) = manufacturer(@bytes[0..7]); |
| 1354 | | printl $l, $temp; |
| 1355 | | $l = "Custom Manufacturer Data"; |
| 1356 | | $temp = manufacturer_data(@{$extra}); |
| 1357 | | printl $l, $temp if defined $temp; |
| 1358 | | |
| 1359 | | if (spd_written($bytes[8])) { |
| 1360 | | # Try the location code as ASCII first, as earlier specifications |
| 1361 | | # suggested this. As newer specifications don't mention it anymore, |
| 1362 | | # we still fall back to binary. |
| 1363 | | $l = "Manufacturing Location Code"; |
| 1364 | | $temp = (chr($bytes[8]) =~ m/^[\w\d]$/) ? chr($bytes[8]) |
| 1365 | | : sprintf("0x%.2X", $bytes[8]); |
| 1366 | | printl $l, $temp; |
| 1367 | | } |
| 1368 | | |
| 1369 | | $l = "Part Number"; |
| 1370 | | $temp = part_number(@bytes[9..26]); |
| 1371 | | printl $l, $temp; |
| 1372 | | |
| 1373 | | if (spd_written(@bytes[27..28])) { |
| 1374 | | $l = "Revision Code"; |
| 1375 | | $temp = sprintf("0x%02X%02X\n", @bytes[27..28]); |
| 1376 | | printl $l, $temp; |
| 1377 | | } |
| 1378 | | |
| 1379 | | if (spd_written(@bytes[29..30])) { |
| 1380 | | $l = "Manufacturing Date"; |
| 1381 | | # In theory the year and week are in BCD format, but |
| 1382 | | # this is not always true in practice :( |
| 1383 | | if (($bytes[29] & 0xf0) <= 0x90 |
| 1384 | | && ($bytes[29] & 0x0f) <= 0x09 |
| 1385 | | && ($bytes[30] & 0xf0) <= 0x90 |
| 1386 | | && ($bytes[30] & 0x0f) <= 0x09) { |
| 1387 | | # Note that this heuristic will break in year 2080 |
| 1388 | | $temp = sprintf("%d%02X-W%02X\n", |
| 1389 | | $bytes[29] >= 0x80 ? 19 : 20, |
| 1390 | | @bytes[29..30]); |
| 1391 | | } else { |
| 1392 | | $temp = sprintf("0x%02X%02X\n", |
| 1393 | | @bytes[29..30]); |
| 1394 | | } |
| 1395 | | printl $l, $temp; |
| 1396 | | } |
| 1397 | | |
| 1398 | | if (spd_written(@bytes[31..34])) { |
| 1399 | | $l = "Assembly Serial Number"; |
| 1400 | | $temp = sprintf("0x%02X%02X%02X%02X\n", |
| 1401 | | @bytes[31..34]); |
| 1402 | | printl $l, $temp; |
| 1403 | | } |
| | 1411 | decode_manufacturing_information(\@bytes); |