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" });
76 my $blocks = RFID::Biblio::Decode::RFID->blank;
84 13 => 'Book with Audio Tape',
85 9 => 'Book with CD/CD ROM',
91 8 => 'Book with Diskette',
96 my ( $self, $data ) = @_;
100 $data = join('', @$data) if ref $data eq 'ARRAY';
102 warn "## to_hash ",dump($data);
104 my ( $u1, $set_item, $u2, $type, $content, $br_lib, $custom, $zero ) = unpack('C4Z16Nl>l',$data);
106 u1 => $u1, # FIXME 0x04
107 set => ( $set_item & 0xf0 ) >> 4,
108 total => ( $set_item & 0x0f ),
110 u2 => $u2, # FIXME 0x00
113 type_label => $item_type->{$type},
117 branch => $br_lib >> 20,
118 library => $br_lib & 0x000fffff,
123 warn "expected first byte to be 0x04, not $u1\n" if $u1 != 4;
124 warn "expected third byte to be 0x00, not $u2\n" if $u2 != 0;
125 warn "expected last block to be zero, not $zero\n" if $zero != 0;
131 my ( $self, $hash ) = @_;
133 warn "## from_hash ",dump($hash);
135 return pack('C4Z16Nl>l',
137 ( $hash->{set} << 4 ) | ( $hash->{total} & 0x0f ),
143 ( $hash->{branch} << 20 ) | ( $hash->{library} & 0x000fffff ),
151 return ( "\x55" x ( 6 * 4 ) ) . ( "\x00" x 4 );
155 return "\x00" x ( 4 * 3 );