_get_system_info MIGHT return undef
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 9 Aug 2010 12:27:38 +0000 (14:27 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 9 Aug 2010 12:27:38 +0000 (14:27 +0200)
lib/RFID/Biblio/Reader/CPRM02.pm

index 1c91323..425546c 100644 (file)
@@ -155,6 +155,8 @@ sub _get_system_info {
 
                warn "# data ",as_hex($data);
 
+               return if length($data) < 17;
+
                $info = {
                        DSFID    => substr($data,5-2,1),
                        UID      => substr($data,6-2,8),
@@ -178,7 +180,9 @@ sub read_blocks {
 
        my $info = _get_system_info $tag;
 
-       my $max_block = ord($info->{SIZE}) || die "no SIZE in ",dump( $info );
+       return unless $info->{SIZE};
+
+       my $max_block = ord($info->{SIZE});
 
        my $tag_blocks;
 
@@ -240,7 +244,7 @@ sub read_afi {
        $tag = shift if ref $tag;
 
        my $info = _get_system_info $tag;
-       return $info->{AFI} || die "no AFI for $tag in ",dump($info);
+       return $info->{AFI} || warn "no AFI for $tag in ",dump($info);
 
 }