Biblio-RFID
view release on metacpan or search on metacpan
lib/Biblio/RFID.pm view on Meta::CPAN
package Biblio::RFID;
use warnings;
use strict;
use base 'Exporter';
our @EXPORT = qw( hex2bytes as_hex hex_tag $debug );
use Data::Dump qw(dump);
=head1 NAME
Biblio::RFID - perl tools to use different RFID readers for library use
=cut
our $VERSION = '0.05';
our $debug = $ENV{DEBUG} || 0;
=head1 DESCRIPTION
Main idea is to develop simple API to reader, and than provide useful
abstractions on top of it to quickly write applications to respond on
tags which come in range of RFID reader using L<Biblio::RFID::Reader>.
Writing support for new RFID readers should be easy.
L<Biblio::RFID::Reader::API> provides documentation on writing support
for different readers.
Currently, two serial RFID readers based on L<Biblio::RFID::Reader::Serial>
are implemented:
=over 4
=item *
L<Biblio::RFID::Reader::3M810>
=item *
L<Biblio::RFID::Reader::CPRM02>
=back
There is also simple read-only reader using shell commands in
L<Biblio::RFID::Reader::librfid>.
For implementing application take a look at L<Biblio::RFID::Reader>
C<scripts/RFID-JSONP-server.pl> is example of such application. It's local
interface to RFID reader and JSONP REST server.
C<examples/koha-rfid.js> is jQuery based JavaScript code which can be inserted
in Koha Library System to provide overlay with tags in range and
check-in/check-out form-fill functionality.
Applications can use L<Biblio::RFID::RFID501> which is some kind of
semi-standard 3M layout or blocks on RFID tags.
=for readme stop
=head1 EXPORT
Formatting functions are exported
=head2 hex2bytes
my $bytes = hex2bytes($hex);
=cut
sub hex2bytes {
my $str = shift || die "no str?";
my $b = $str;
$b =~ s/\s+//g;
$b =~ s/(..)/\\x$1/g;
$b = "\"$b\"";
my $bytes = eval $b;
die $@ if $@;
warn "## str2bytes( $str ) => $b => ",as_hex($bytes) if $debug;
return $bytes;
}
=head2 as_hex
print as_hex( $bytes );
=cut
sub as_hex {
my @out;
foreach my $str ( @_ ) {
my $hex = uc unpack( 'H*', $str );
$hex =~ s/(..)/$1 /g if length( $str ) > 2;
$hex =~ s/\s+$//;
push @out, $hex;
}
return join(' | ', @out);
}
=head2 hex_tag
print hex_tag $8bytes;
=cut
sub hex_tag { uc(unpack('H16', shift)) }
=head1 WARN
We are installing L<perldoc/warn> handler to control debug output
based on C<$Biblio::RFID::debug> level
=cut
( run in 2.883 seconds using v1.01-cache-2.11-cpan-ad19def0cd9 )