Here is an example showing how to perform a command and fetch the results. Note that this is an EXAMPLE only; your mileage may vary!
sub read_element_status {
my $self = shift;
my $element = shift;
my %options = @_;
my $hashref = {};
unless (defined $element) {
warn "No element id specified for read_element_status()";
return $hashref;
}
my $command = pack("C12",
0xb8, # READ ELEMENT STATUS
($options{'LUN'} << 5), # Bits 0-3 is Element Type Code (0), bits 5-7 is LUN
$element >> 8, # $element MSB
$element & 0xff, # $element LSB
0, # Number of elements, MSB
1, # Number of elements, LSB
0x00, # (reserved)
0, # Allocation length, MSB
0, # Allocation length, ...
32, # Allocation length, LSB (32 bytes)
0x00, # (reserved)
0x00, # (reserved)
);
my $wanted = 32;
my ($result, $sense) = $self->execute($command, $wanted);
unless ($self->sense_error($sense)) {
# Element Status Data - discard this header, we have no use for it
my $unused = substr($result, 0, 10);
$result = substr($result,
;
# Element Status Page - discard this header, we have no use for it
$unused = substr($result, 0,
;
$result = substr($result,
;
# Element Status Descriptor
my $page = substr($result, 0, 16);
my $flags, $valid;
(
$hashref->{'ELEMENT'},
$flags,
$unused, # (reserved)
$hashref->{'ADDITIONAL_SENSE_CODE'},
$hashref->{'ADDITIONAL_SENSE_QUALIFIER'},
$unused, # (reserved)
$unused, # (reserved)
$unused, # (reserved)
$valid,
$hashref->{'SOURCE_ELEMENT'},
$unused, # (reserved)
$unused, # (reserved)
$unused, # (reserved)
$unused, # (reserved)
) = unpack("n1 C8 n1 C4", $result);
unless ($valid & 0x80) { delete $hashref->{'SOURCE_ELEMENT'}; }
$hashref->{'FULL'} = ($flags & 0x01) ? 1 : 0;
$hashref->{'EXCEPTION'} = ($flags & 0x04) ? 1 : 0;
}
return $hashref;
}