program tags from command line
[Biblio-RFID.git] / scripts / program.pl
diff --git a/scripts/program.pl b/scripts/program.pl
new file mode 100755 (executable)
index 0000000..4f9eaff
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Data::Dump qw(dump);
+use Getopt::Long;
+use lib 'lib';
+use RFID::Biblio::Readers;
+use RFID::Biblio::RFID501;
+
+my $only;
+
+GetOptions(
+       'only=s', => \$only,
+) || die $!;
+
+my ( $sid, $content ) =  @ARGV;
+die "usage: $0 E0_RFID_SID content\n" unless $sid && $content;
+
+my @rfid = RFID::Biblio::Readers->available( $only );
+
+foreach my $rfid ( @rfid ) {
+       my $visible = $rfid->scan;
+       foreach my $tag ( keys %$visible ) {
+               next unless $tag eq $sid;
+               warn "PROGRAM $tag with $content\n";
+               $rfid->write_blocks( $tag, RFID::Biblio::RFID501->from_hash( content => $content ) );
+       }
+}
+