Skip to content

Commit

Permalink
implement model-specific hack for serial number
Browse files Browse the repository at this point in the history
closes: 1607
  • Loading branch information
guillomovitch committed Aug 16, 2012
1 parent 7eb9cba commit 74a1be7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
22 changes: 13 additions & 9 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Screen.pm
Expand Up @@ -96,11 +96,6 @@ my %manufacturers = (
PDC => "Polaroid"
);

# list of models with unsuited constant ASCII serial numbers
my %blacklist = (
ACRad49 => 1
);

sub isEnabled {

return
Expand Down Expand Up @@ -159,15 +154,24 @@ sub _getEdidInfo {
# they are two different serial numbers in EDID
# - a mandatory 4 bytes numeric value
# - an optional 13 bytes ASCII value
# we use the ASCII value if present, and if the model is not part of an
# exception, otherwise we use the numerical one, as an 8-length hex string
# we use the ASCII value if present, the numeric value as an hex string
# unless for a few list of known exceptions deserving specific handling
# References:
# http://forge.fusioninventory.org/issues/1607
# http://forge.fusioninventory.org/issues/1614
$info->{SERIAL} =
$edid->{serial_number2} && !$blacklist{$edid->{EISA_ID}} ?
if (
$edid->{EISA_ID} &&
$edid->{EISA_ID} =~ /^ACR(0018|0020|00A8|7883|ad49|adaf)$/
) {
$info->{SERIAL} =
substr($edid->{serial_number2}->[0], 0, 8) .
sprintf("%08x", $edid->{serial_number}) .
substr($edid->{serial_number2}->[0], 8, 4) ;
} else {
$info->{SERIAL} = $edid->{serial_number2} ?
$edid->{serial_number2}->[0] :
sprintf("%08x", $edid->{serial_number});
}

return $info;
}
Expand Down
8 changes: 4 additions & 4 deletions t/inventory/generic/screen.t
Expand Up @@ -151,25 +151,25 @@ my %tests = (
'lcd.acer-al19161.1' => {
MANUFACTURER => 'Acer America Corp.',
CAPTION => 'Acer AL1916',
SERIAL => '719030c6',
SERIAL => 'L4908669719030c64237',
DESCRIPTION => '19/2007'
},
'lcd.acer-al19161.2' => {
MANUFACTURER => 'Acer America Corp.',
CAPTION => 'Acer AL1916',
SERIAL => '7190328f',
SERIAL => 'L49086697190328f4237',
DESCRIPTION => '19/2007'
},
'lcd.acer-al19161.3' => {
MANUFACTURER => 'Acer America Corp.',
CAPTION => 'Acer AL1916',
SERIAL => '71903291',
SERIAL => 'L4908669719032914237',
DESCRIPTION => '19/2007'
},
'lcd.acer-al19161.4' => {
MANUFACTURER => 'Acer America Corp.',
CAPTION => 'Acer AL1916',
SERIAL => '71903290',
SERIAL => 'L4908669719032904237',
DESCRIPTION => '19/2007'
},
'lcd.acer-asp1680' => {
Expand Down

0 comments on commit 74a1be7

Please sign in to comment.