rename module to Biblio::RFID
[Biblio-RFID.git] / lib / RFID / Biblio / Reader / CPRM02.pm
index 3fe3a70..0992fc8 100644 (file)
@@ -1,8 +1,8 @@
-package RFID::Biblio::Reader::CPRM02;
+package Biblio::RFID::Reader::CPRM02;
 
 =head1 NAME
 
-RFID::Biblio::Reader::CPRM02 - support for CPR-M02 RFID reader
+Biblio::RFID::Reader::CPRM02 - support for CPR-M02 RFID reader
 
 =head1 DESCRIPTION
 
@@ -14,8 +14,8 @@ reader as described in document C<H20800-16e-ID-B.pdf>
 use warnings;
 use strict;
 
-use base 'RFID::Biblio';
-use RFID::Biblio;
+use base 'Biblio::RFID::Reader::Serial';
+use Biblio::RFID;
 
 use Time::HiRes;
 use Data::Dump qw(dump);
@@ -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);
 
 }