From bb5520887c1a9d474688da63e195d14e284bcf1c Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 19 Jan 2014 19:27:18 -0500 Subject: [PATCH] use librfid-tool from $PATH --- lib/Biblio/RFID/Reader/librfid.pm | 19 ++++--------------- t/30-librfid.t | 2 +- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/Biblio/RFID/Reader/librfid.pm b/lib/Biblio/RFID/Reader/librfid.pm index 126d0d5..e4136cc 100644 --- a/lib/Biblio/RFID/Reader/librfid.pm +++ b/lib/Biblio/RFID/Reader/librfid.pm @@ -35,21 +35,10 @@ C sub serial_settings {} # don't open serial -our $bin = '/usr/local/bin/librfid-tool'; - -sub init { - my $self = shift; - if ( -e $bin ) { - warn "# using $bin"; - return 1; - } else { - warn "# no $bin found\n"; - return 0; - } -} +sub init { 1 } sub _grep_tool { - my ( $param, $coderef ) = @_; + my ( $bin, $param, $coderef, $path ) = @_; warn "# _grep_tool $bin $param\n"; open(my $s, '-|', "$bin $param") || die $!; @@ -73,7 +62,7 @@ sub _grep_tool { sub inventory { my @tags; - _grep_tool '--scan' => sub { + _grep_tool 'librfid-tool', '--scan' => sub { my $sid = shift; push @tags, $sid if $sid; }; @@ -85,7 +74,7 @@ sub read_blocks { my $sid; my $blocks; - _grep_tool '--read -1' => sub { + _grep_tool 'librfid-tool', '--read -1' => sub { $sid ||= shift; $blocks->{$sid}->[$1] = hex2bytes($2) if m/block\[\s*(\d+):.+data.+:\s*(.+)/; diff --git a/t/30-librfid.t b/t/30-librfid.t index 6e207e2..c078400 100755 --- a/t/30-librfid.t +++ b/t/30-librfid.t @@ -9,7 +9,7 @@ BEGIN { use_ok( 'Biblio::RFID::Reader::librfid' ); } -ok( my $o = Biblio::RFID::Reader::librfid->new( tool => '/rest/cvs/librfid/utils/librfid-tool' ), 'new' ); +ok( my $o = Biblio::RFID::Reader::librfid->new(), 'new' ); my @tags = $o->inventory; diag 'inventory = ', dump @tags; -- 2.20.1