1 package RFID::Biblio::RFID501;
6 use Data::Dump qw(dump);
10 RFID::Biblio::RFID501 - RFID Standard for Libraries
14 This module tries to decode tag format as described in document
16 RFID 501: RFID Standards for Libraries
18 L<http://solutions.3m.com/wps/portal/3M/en_US/3MLibrarySystems/Home/Resources/CaseStudiesAndWhitePapers/RFID501/>
20 Goal is to be compatibile with existing 3M Alphanumeric tag format
21 which, as far as I know, isn't specificed anywhere. My documentation about
22 this format is available at
24 L<http://saturn.ffzg.hr/rot13/index.cgi?hitchhikers_guide_to_rfid>
28 =head2 3M Alphanumeric tag
30 0 04 is 00 tt i [4 bit] = number of item in set [1 .. i .. s]
31 s [4 bit] = total items in set
32 tt [8 bit] = item type
34 1 dd dd dd dd dd [16 bytes] = barcode data
39 5 bb bl ll ll b [12 bit] = branch [unsigned]
40 l [20 bit] = library [unsigned]
42 6 cc cc cc cc c [32 bit] = custom signed integer
44 =head2 3M Manufacturing Blank
64 my $hash = RFID::Biblio::Decode::RFID501->to_hash( $bytes );
66 my $hash = RFID::Biblio::Decode::RFID501->to_hash( [ 'blk1', 'blk2', ... , 'blk7' ] );
70 my $blocks = RFID::Biblio::Decode::RFID->from_hash({ content => "1301234567" });
74 my $blocks = RFID::Biblio::Decode::RFID->blank;
82 13 => 'Book with Audio Tape',
83 9 => 'Book with CD/CD ROM',
89 8 => 'Book with Diskette',
94 my ( $self, $data ) = @_;
98 $data = join('', @$data) if ref $data eq 'ARRAY';
100 warn "## to_hash ",dump($data);
102 my ( $u1, $set_item, $u2, $type, $content, $br_lib, $custom, $zero ) = unpack('C4Z16Nl>l',$data);
104 u1 => $u1, # FIXME 0x04
105 set => ( $set_item & 0xf0 ) >> 4,
106 total => ( $set_item & 0x0f ),
108 u2 => $u2, # FIXME 0x00
111 type_label => $item_type->{$type},
115 branch => $br_lib >> 20,
116 library => $br_lib & 0x000fffff,
121 warn "expected first byte to be 0x04, not $u1\n" if $u1 != 4;
122 warn "expected third byte to be 0x00, not $u2\n" if $u2 != 0;
123 warn "expected last block to be zero, not $zero\n" if $zero != 0;
129 my ( $self, $hash ) = @_;
131 warn "## from_hash ",dump($hash);
133 return pack('C4Z16Nl>l',
135 ( $hash->{set} << 4 ) | ( $hash->{total} & 0x0f ),
141 ( $hash->{branch} << 20 ) | ( $hash->{library} & 0x000fffff ),
150 return ( "\x55" x ( 5 * 4 ) ) . ( "\x00" x 4 );