fix: Ignore toners with values -2 which is unknown #5637 (#5654)

This commit is contained in:
Neil Lathwood
2017-01-31 08:07:50 +00:00
committed by GitHub
parent 981e974a70
commit 4390347508
2 changed files with 20 additions and 13 deletions

View File

@@ -48,17 +48,19 @@ if ($device['os_group'] == 'printer') {
$capacity = get_toner_capacity($data['prtMarkerSuppliesMaxCapacity']); $capacity = get_toner_capacity($data['prtMarkerSuppliesMaxCapacity']);
$current = get_toner_levels($device, $raw_toner, $capacity); $current = get_toner_levels($device, $raw_toner, $capacity);
discover_toner( if (is_numeric($current)) {
$valid_toner, discover_toner(
$device, $valid_toner,
$toner_oid, $device,
$last_index, $toner_oid,
$type, $last_index,
$descr, $type,
$capacity_oid, $descr,
$capacity, $capacity_oid,
$current $capacity,
); $current
);
}
} }
} }

View File

@@ -1821,8 +1821,13 @@ function get_toner_levels($device, $raw_value, $capacity)
return 50; return 50;
} }
// -2 means unknown, -1 mean no restrictions // -2 means unknown
if ($raw_value == '-2' || $raw_value == '-1') { if ($raw_value == '-2') {
return false;
}
// -1 mean no restrictions
if ($raw_value == '-1') {
return 0; // FIXME: is 0 what we should return? return 0; // FIXME: is 0 what we should return?
} }