write_blocks
[Biblio-RFID.git] / lib / RFID / Serial / Decode / RFID501.pm
index 22168e4..14f5bf3 100644 (file)
@@ -22,11 +22,34 @@ was done to be compliant with 3M implementation
 
   my $hash = RFID::Serial::Decode::RFID501->to_hash( $bytes );
 
+  my $hash = RFID::Serial::Decode::RFID501->to_hash( [ 'blk1', 'blk2', ... , 'blk7' ] );
+
 =cut
 
+my $item_type = {
+       1 => 'Book',
+       6 => 'CD/CD ROM',
+       2 => 'Magazine',
+       13 => 'Book with Audio Tape',
+       9 => 'Book with CD/CD ROM',
+       0 => 'Other',
+
+       5 => 'Video',
+       4 => 'Audio Tape',
+       3 => 'Bound Journal',
+       8 => 'Book with Diskette',
+       7 => 'Diskette',
+};
+
 sub to_hash {
        my ( $self, $data ) = @_;
 
+       return unless $data;
+
+       $data = join('', @$data) if ref $data eq 'ARRAY';
+
+       warn "## to_hash $data\n";
+
        my ( $u1, $set_item, $u2, $type, $content, $br_lib, $custom ) = unpack('C4Z16Nl>',$data);
        my $hash = {
                u1 => $u1,      # FIXME
@@ -35,6 +58,7 @@ sub to_hash {
                total => ( $set_item & 0x0f ),
 
                type => $type,
+               type_label => $item_type->{$type},
                content => $content,
 
                branch => $br_lib >> 20,