From: Dobrica Pavlinusic Date: Mon, 16 Aug 2010 21:31:59 +0000 (+0200) Subject: make programming die-proof X-Git-Tag: RFID-Biblio-0.02~10 X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=commitdiff_plain;h=4e361aa6bd0dcfdc41e568fb98317a1ad8a7e3c1 make programming die-proof --- diff --git a/scripts/print.pl b/scripts/print.pl index a09e0f7..f067038 100755 --- a/scripts/print.pl +++ b/scripts/print.pl @@ -59,22 +59,30 @@ while ( $rfid->tags ) { print_card; +my $programmed; + do { my @visible = $rfid->tags( enter => sub { my $tag = shift; - print localtime()." enter ", tag($tag); + print localtime()." enter ", eval { tag($tag) }; + return if $@; + + if ( ! $programmed->{$tag} ) { + my $card = shift @queue; + my $number = $card->[0]; + print "PROGRAM $tag $number\n"; + $rfid->write_blocks( $tag => RFID::Biblio::RFID501->from_hash({ content => $number }) ); + $rfid->write_afi( $tag => chr($afi) ) if $afi; - my $card = shift @queue; - $rfid->write_blocks( $tag => RFID::Biblio::RFID501->from_hash({ content => $card->[0] }) ); - $rfid->write_afi( $tag => chr($afi) ) if $afi; + $programmed->{$tag} = $number; + } }, leave => sub { my $tag = shift; - print localtime()." leave ", tag($tag); - print_card; + print_card if $programmed->{$tag}; }, ); @@ -89,6 +97,7 @@ sub print_card { my $p = Printer::EVOLIS::Parallel->new( '/dev/usb/lp0' ); print "insert card ", $p->command( 'Si' ),$/; + sleep 1; print "eject card ", $p->command( 'Ser' ),$/; }