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
41 my ( $bin, $param, $coderef, $path ) = @_;
43 warn "# _grep_tool $bin $param\n";
44 open(my $s, '-|', "$bin $param") || die $!;
50 if ( m/success.+:\s+(.+)/ ) {
53 $sid = uc join('', reverse split(/\s+/, $sid));
65 _grep_tool 'librfid-tool', '--scan' => sub {
67 push @tags, $sid if $sid;
69 warn "# invetory ",dump(@tags);
77 _grep_tool 'librfid-tool', '--read -1' => sub {
79 $blocks->{$sid}->[$1] = hex2bytes($2)
80 if m/block\[\s*(\d+):.+data.+:\s*(.+)/;
83 warn "# read_blocks ",dump($blocks);