From: Dobrica Pavlinusic Date: Mon, 14 Mar 2016 13:56:40 +0000 (+0100) Subject: Merge branch 'master' of mjesec.ffzg.hr:/git/Biblio-RFID X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=commitdiff_plain;h=1601b02988d4067fafcf4ab936e0e416e3527d20;hp=282b54550a8a651fe528648d40aa7c582d288511 Merge branch 'master' of mjesec.ffzg.hr:/git/Biblio-RFID --- diff --git a/lib/Biblio/RFID/Reader/3M810.pm b/lib/Biblio/RFID/Reader/3M810.pm index b5bd26d..467b4e7 100644 --- a/lib/Biblio/RFID/Reader/3M810.pm +++ b/lib/Biblio/RFID/Reader/3M810.pm @@ -208,9 +208,9 @@ sub read_blocks { } elsif ( $rest = _matched $data => 'FE 00 00 05 01' ) { warn "FIXME ready? ",as_hex $rest; } elsif ( $rest = _matched $data => '02 06' ) { - die "ERROR ",as_hex($rest); + die "ERROR ",as_hex($data); } else { - die "FIXME unsuported ",as_hex($rest); + die "FIXME unsuported ",as_hex($data); } }); @@ -235,6 +235,9 @@ sub write_blocks { my $hex_data = as_hex $data; my $blocks = sprintf('%02x', length($data) / 4 ); + my $retry = 0; +retry_write: + cmd( "04 $tag 00 $blocks 00 $hex_data", "write_blocks $tag [$blocks] $hex_data", sub { my $data = shift; @@ -243,13 +246,23 @@ sub write_blocks { my $blocks = substr($rest,8,1); warn "# WRITE ",as_hex($tag), " [$blocks]\n"; } elsif ( $rest = _matched $data => '04 06' ) { - die "ERROR ",as_hex($rest); + die "ERROR ",as_hex($data); } else { - die "UNSUPPORTED"; + die "UNSUPPORTED ", as_hex($data); } } ); + my $verify_blocks = read_blocks($tag); + die "can't find data from tag $tag" unless exists $verify_blocks->{$tag}; + + if ( join('', @{ $verify_blocks->{$tag} }) ne $data ) { + $retry++; + warn "ERROR reading data back from tag, retry $retry\n"; + die "ABORTED" if $retry == 10; + goto retry_write; + } + } sub read_afi { diff --git a/scripts/program.pl b/scripts/program.pl index b0fc125..565bb2a 100755 --- a/scripts/program.pl +++ b/scripts/program.pl @@ -29,6 +29,10 @@ GetOptions( ) || die $!; my ( $sid, $content ) = @ARGV; +if ( $sid =~ m/.+,.+/ && ! defined $content ) { + ( $sid, $content ) = split(/,/, $sid); +} + die "usage: $0 [--reader regex_filter] [--afi 214] [--type 1] E0_RFID_SID [barcode]\n" unless $sid && ( $content || $afi || $blank ); $hash->{content} = $content if defined $content; @@ -38,7 +42,7 @@ $Biblio::RFID::debug = $debug; foreach my $tag ( $rfid->tags, $sid ) { warn "visible $tag\n"; -# next unless $tag eq $sid; + next unless $tag eq $sid; if ( grep { defined $_ } values %$blank ) { my $type = ( grep { $blank->{$_} } keys %$blank )[0]; warn "BLANK $type $tag\n"; diff --git a/scripts/scan.pl b/scripts/scan.pl index 09846c7..d2e18b9 100755 --- a/scripts/scan.pl +++ b/scripts/scan.pl @@ -7,6 +7,7 @@ use Data::Dump qw(dump); use Getopt::Long; use lib 'lib'; use Biblio::RFID::Reader; +use Biblio::RFID::RFID501; my $loop = 0; my $reader;