use warnings;
use strict;
+use base 'Exporter';
+our @EXPORT = qw( hex2bytes as_hex hex_tag );
+
use Device::SerialPort qw(:STAT);
use Data::Dump qw(dump);
my $debug = 0;
-use base 'Exporter';
-our @EXPORT = qw( hex2bytes as_hex );
-
=head1 SYNOPSIS
my $rfid = RFID::Serial->new(
device => '/dev/ttyUSB0', # with fallback to RFID_DEVICE
);
+ my $visible = $rfid->scan;
=head1 SUBROUTINES/METHODS
return $self;
}
+=head2 port
+
+ my $serial_obj = $self->port;
+
+=cut
+
sub port {
my $self = shift;
}
-sub init {
- warn "no init";
+=head2 scan
+
+ my $visible = $rfid->scan;
+
+Returns hash with keys which match tag UID and values with blocks
+
+=cut
+
+sub scan {
+ my $self = shift;
+
+ warn "# scan tags in reader range\n";
+ my @tags = $self->inventory;
+
+ my $visible;
+ # FIXME this is naive implementation which just discards other tags
+ $visible->{$_} = $self->read_blocks( $_ )->{$_} foreach @tags;
+
+ return $visible;
}
+
+=head1 MANDATORY IMPLEMENTATIONS
+
+Each reader must implement following hooks as sub-classes.
+
+=head2 init
+
+ $self->init;
+
+=head2 inventory
+
+ my @tags = $self->invetory;
+
+=head2 read_blocks
+
+ my $hash = $self->read_blocks $tag;
+
+All blocks are under key which is tag UID
+
+ $hash = { 'E000000123456789' => [ undef, 'block1', 'block2', ... ] };
+
+L<RFID::Serial::3M810> sends tag UID with data payload, so we might expect
+to receive response from other tags from protocol specification,
+
+
=head1 EXPORT
Formatting functions are exported
return join(' | ', @out);
}
+=head2 hex_tag
+
+ print hex_tag $8bytes;
+
+=cut
+
+sub hex_tag { uc(unpack('H16', shift)) }
+
=head1 AUTHOR