From: Dobrica Pavlinusic Date: Wed, 4 Aug 2010 13:55:29 +0000 (+0200) Subject: split Get System Info X-Git-Tag: RFID-Biblio-0.02~70 X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=commitdiff_plain;h=7af68cb963f4276a4ae311c7769b76b3698d67cf split Get System Info This will allow us to re-use it to get AFI byte --- diff --git a/lib/RFID/Biblio/CPRM02.pm b/lib/RFID/Biblio/CPRM02.pm index dd01a68..6358a67 100644 --- a/lib/RFID/Biblio/CPRM02.pm +++ b/lib/RFID/Biblio/CPRM02.pm @@ -145,29 +145,39 @@ cpr( 'FF B0 01 00', 'ISO - Inventory', sub { } -sub read_blocks { +sub _get_system_info { my $tag = shift; - $tag = shift if ref $tag; - my $max_block; + my $info; cpr( "FF B0 2B 01 $tag", "Get System Information $tag", sub { my $data = shift; warn "# data ",as_hex($data); - my $DSFID = substr($data,5-2,1); - my $UID = substr($data,6-2,8); - my $AFI = substr($data,14-2,1); - my $MEM = substr($data,15-2,1); - my $SIZE = substr($data,16-2,1); - my $IC_REF = substr($data,17-2,1); - - warn "# split ",as_hex( $DSFID, $UID, $AFI, $MEM, $SIZE, $IC_REF ); + $info = { + DSFID => substr($data,5-2,1), + UID => substr($data,6-2,8), + AFI => substr($data,14-2,1), + MEM => substr($data,15-2,1), + SIZE => substr($data,16-2,1), + IC_REF => substr($data,17-2,1), + }; - $max_block = ord($SIZE); }); + return $info; +} + + +sub read_blocks { + my $tag = shift; + $tag = shift if ref $tag; + + my $info = _get_system_info $tag; + + my $max_block = ord($info->{SIZE}) || die "no SIZE in ",dump( $info ); + my $tag_blocks; my $block = 0;