1 package Biblio::RFID::Reader::librfid;
6 use base 'Biblio::RFID::Reader::API';
9 use Data::Dump qw(dump);
13 Biblio::RFID::Reader::librfid - execute librfid-tool
17 This is wrapper around C<librfid-tool> from
19 L<http://openmrtd.org/projects/librfid/>
21 Due to limitation of L<librfid-tool> only
22 L<Biblio::RFID::Reader::API/inventory> and
23 L<Biblio::RFID::Reader::API/read_blocks> is supported.
25 However, this code might provide template for integration
26 with any command-line utilities for different RFID readers.
28 Currently tested with only with Omnikey CardMan 5321 which
29 has problems. After a while it stops responding to commands
30 by C<librfid-tool> so I provided small C program to reset it:
32 C<examples/usbreset.c>
36 sub serial_settings {} # don't open serial
38 our $bin = '/rest/cvs/librfid/utils/librfid-tool';
46 warn "# no $bin found\n";
52 my ( $param, $coderef ) = @_;
54 warn "# _grep_tool $bin $param\n";
55 open(my $s, '-|', "$bin $param") || die $!;
61 if ( m/success.+:\s+(.+)/ ) {
64 $sid = uc join('', reverse split(/\s+/, $sid));
76 _grep_tool '--scan' => sub {
78 push @tags, $sid if $sid;
80 warn "# invetory ",dump(@tags);
88 _grep_tool '--read -1' => sub {
90 $blocks->{$sid}->[$1] = hex2bytes($2)
91 if m/block\[\s*(\d+):.+data.+:\s*(.+)/;
94 warn "# read_blocks ",dump($blocks);