From a14ea0fdd9615a190c7cb1d4e711999d31f9371b Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 29 Jul 2010 15:11:13 +0200 Subject: [PATCH] program tags from command line --- lib/RFID/Biblio/RFID501.pm | 5 ++++- scripts/program.pl | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 scripts/program.pl diff --git a/lib/RFID/Biblio/RFID501.pm b/lib/RFID/Biblio/RFID501.pm index dc30fe8..760fe24 100644 --- a/lib/RFID/Biblio/RFID501.pm +++ b/lib/RFID/Biblio/RFID501.pm @@ -118,7 +118,10 @@ sub to_hash { } sub from_hash { - my ( $self, $hash ) = @_; + my $self = shift; + my $hash = {@_}; + + warn "## from_hash ",dump($hash); return pack('C4Z16Nl>l', 0x04, diff --git a/scripts/program.pl b/scripts/program.pl new file mode 100755 index 0000000..4f9eaff --- /dev/null +++ b/scripts/program.pl @@ -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 ) ); + } +} + -- 2.20.1