The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

RFID::Alien::Reader - Abstract base class for a Alien RFID reader

SYNOPSIS

This abstract base class provides most of the methods required for interfacing Perl with an Alien RFID reader. To actually create an object, use RFID::Alien::Reader::Serial or RFID::Alien::Reader::TCP. For example:

    use RFID::Alien::Reader::Serial;
    use Win32::SerialPort;

    $com = Win32::SerialPort->new('COM1')
        or die "Couldn't open COM port 'COM1': $^E\n";
    my $reader = 
      RFID::Alien::Reader::Serial->new(Port => $com,
                                       PersistTime => 0,
                                       AcquireMode => 'Inventory',
                                       )
        or die "Couldn't create reader object";

    $reader->set(AntennaSequence => [0,1],
                 TagListAntennaCombine => 'OFF') == 0
        or die "Couldn't set reader properties";

    my @tags = $reader->readtags();
    foreach my $tag (@tags)
    {
        print "I see tag ",$tag->id,"\n";
    }

DESCRIPTION

This abstract base class implements the commands for communicating with an Alien reader. It is written according to the specifications in the Alien Technology Reader Interface Guide v02.00.00. It was tested with the original tag reader and also the ALR-9780. It inherits from RFID::Reader.

To actually create a reader object, use RFID::Alien::Reader::Serial or RFID::Alien::Reader::TCP. Those classes inherit from this one.

Methods

set

Set various properties of the reader or the internal state of the object. This method takes a hash-style list of any number of key/value pairs, and returns a list of errors that occured. In a scalar context, that evaluates to the number of errors that occured, so you can test for errors like this:

    my @errs = $alien->set(SomeVariable => "New Value") == 0
      or die "Couldn't set SomeVariable: @errs";

See Properties for the properties that can be set, and see the RFID::Reader set method for more details about this method.

get

Get various properties of the reader or the internal state of the object. This method takes a list of parameters whose value you'd like to get. In a list context, it returns a hash with the parameters you asked for as the keys, and their values as the values. In a scalar context, it returns the value of the last property requested. If an error occurs or a value for the requested property can't be found, it is set to undef.

For example:

    my $AcquireMode = $alien->get('AcquireMode');
    my %props = $alien->get(qw(AcquireMode PersistTime ReaderVersion));

See Properties for the properties that can be retreived with get, and the RFID::Reader get method for more information about this method.

readtags

Read all of the tags in the reader's field, honoring the requested Mask and AntennaSequence settings. This returns a (possibly empty) list of RFID::Tag objects. For example:

    my @tags = $reader->readtags();
    foreach my $tag (@tags)
    {
        print "I see tag ",$tag->id,"\n";
    }

Parameters are a hash-style list of parameters that should be set for just this read. The parameters are actually set to the requested value at the beginning of the method call, and set back before returning, so if you want to use the same parameters for many calls (say in a loop) you will probably want to set them just once with set.

See the RFID::Reader readtags method for more information about this method.

sleeptags

Request that all tags addressed by the reader go to sleep, causing them to ignore all requests from the reader until they are awakened. Which tags are addressed by the reader is affected by the Mask and AntennaSequence settings.

Returns 1 to indicate success; currently it dies on an error, but may return undef in the future.

This method is not very well tested yet. In particular, although the commands appear to be issued correctly to the reader, the tags don't seem to actually go to sleep.

Parameters are a hash-style list of parameters that should be set for just this read. The parameters are actually set to the requested value at the beginning of the method call, and set back before returning, so if you want to use the same parameters for many calls (say in a loop) you will probably want to set them just once with set.

waketags

Request that all tags addressed by the reader which are currently asleep wake up, causing them to once again pay attention to requests from the reader. Which tags are addressed by the reader is affected by the Mask and AntennaSequence settings.

Returns 1 to indicate success; currently it dies on an error, but may return undef in the future.

This method is not very well tested yet, since sleeptags doesn't quite behave as expected.

Parameters are a hash-style list of parameters that should be set for just this read. The parameters are actually set to the requested value at the beginning of the method call, and set back before returning, so if you want to use the same parameters for many calls (say in a loop) you will probably want to set them just once with set.

reboot

Request that the reader unit reboot.

The object may behave unpredictably after a reboot; if you want to continue using the reader you should create a new object. This new object will sync up with the reader and should work OK, once the reboot is completed. This may be fixed in the future.

Properties

There are various properties that can be controlled by the get and set methods. Some of these settings will cause one or more commands to be sent to the reader, while other will simply return the internal state of the object. The value for a property is often a string, but can also be an arrayref or hashref. These properties try to hide the internals of the Alien reader, and so their syntax doesn't always exactly match that of the actual Alien command.

AcqCycles, AcqEnterWakeCount, AcqCount, AcqSleepCount, AcqExitWakeCount

These settings affect the operations of the anti-collision algorithm used by Alien to scan for tags. See the Alien documentation for more information.

AcquireMode

Affects the way in which tags are found during a call to readtags. If the mode is set to the string Inventory, an anti-collision search algorithm is used to find all tags in the reader's view; if the mode is set to the string Global Scroll, the reader will quickly search for a single tag.

See the Alien documentation for more information.

AntennaSequence

An arrayref of the antenna numbers that should be queried, and in what order. Antennas are numbered from 0 to 3 (the same as on the front of the reader unit). For example:

    $alien->set(AntennaSequence => [0,1,2,3]);

The default AntennaSequence is [0]; you must override this if you want to read from more than one antenna.

Debug

Send debugging information to STDERR. Currently this is only on or off, but in the future various debugging levels may be supported. Debugging information is currently mostly I/O with the reader.

Mask

Set or get a bitmask for the tags. After setting the mask, all commands will only apply to tags whose IDs match the given mask.

The mask format is a string beginning with the bits of the tag as a hex number, optionally followed by a slash and the size of the mask, optionally followed by the bit offset in the tag ID where the comparison should start. For example, to look for 8 ones at the end of a tag, you could use:

    $alien->set(Mask => 'ff/8/88');

A zero-length mask (which matches all tags) is represented by an empty string.

PersistTime

Controls how long the reader will remember a tag after seeing it. If the reader has seen a tag within this time period when you use readtags, it will be returned even if it is no longer in view of the reader. You can set it to a number of seconds to remember a tag, to 0 to not remember tags, or to -1 to remember tags until the readtags method is executed. The default is -1.

See the Alien documentation for more information.

TagListAntennaCombine

If this is set to ON, a tag seen by multiple antennas will only return one tag list entry.

See the Alien documentation for more information.

Time

The current time on the reader unit. All tag responses are timestamped, so setting the time may be useful.

The time is represented as Unix epoch time---that is, the number of seconds since midnight on January 1 1970 in GMT. You can either set or get it using this format.

If you set the time to an empty string, the reader's time will be set to the current time of the computer running the script.

Currently, no attempt is made to deal with the timezone. That may be addressed in the future.

Timeout

Request that requests to the reader that do not complete in the given number of seconds cause a die to happen.

ReaderVersion

Cannot be set. Returns a string containing information about the reader.

SEE ALSO

RFID::Alien::Reader::Serial, RFID::Alien::Reader::TCP, RFID::Reader, RFID::EPC::Tag, http://whereabouts.eecs.umich.edu/code/rfid-perl/.

AUTHOR

Scott Gifford <gifford@umich.edu>, <sgifford@suspectclass.com>

Copyright (C) 2004-2006 The Regents of the University of Michigan.

See the file LICENSE included with the distribution for license information.