NAME
RFID::Matrics::Reader - Abstract base class for a Matrics RFID reader
SYNOPSIS
This abstract base class provides most of the methods required for interfacing Perl with a Matrics RFID reader. To actually create an object, use RFID::Matrics::Reader::Serial or RFID::Matrics::Reader::TCP.
use RFID::Matrics::Reader::Serial;
my $reader =
RFID::Matrics::Reader::Serial->new(comport => $com,
node => 4,
antenna => MATRICS_ANT_1);
$reader->changeparam(antenna => MATRICS_ANT_1,
environment => 4,
power_level => 0xff,
combine_antenna_bits => 0);
my $rff = $reader->readfullfield_unique(antenna => MATRICS_ANT_1);
foreach my $tag (@{$pp->{utags}})
{
print "I see tag $tag->{id}\n";
}
DESCRIPTION
This abstract base class implements the commands for communicating with a Matrics reader. It is written according to the specifications in Matrics' Stationary Reader / Host Protocol (RS-485) Specification, using version 2.8 from October 19th 2003. It was tested with an RDR-001 model reader.
To actually create a reader object, use RFID::Matrics::Reader::Serial or RFID::Matrics::Reader::TCP. Those classes inherit from this one.
CONSTANTS
- MATRICS_ANT_n
-
Specific antennas on the reader. The constants MATRICS_ANT_1, MATRICS_ANT_2, MATRICS_ANT_3, MATRICS_ANT_4 are provided.
METHODS
getparamblock
Gets the configuration for a particular antenna on a particular reader. Takes a hash as an argument, which can have the following parameters:
- node
-
Node to be queried.
- antenna
-
Antenna whose configuration you want
Returns a hash reference with the following attributes:
- power_level
-
The amount of power this antenna should use when doing a read, between 0 and 255. 255 is full-power; the scale of this setting is logarithmic, so 0xC0 is about 50% power, and 0x80 is about 25% power.
- environment
-
How long the reader should try to read tags during a
readfullfield
command, between 0 and 4. 0 will read for a very short time, and is appropriate for environments where tags come and go very quickly, and it's OK if you miss a tag somtimes. 4 will read for longer, and is appropriate where tags stay relatively static and you want the reader to try its best to find all of them.
The parameters for combined antennas and filters are not yet fully implemented.
setparamblock
Sets parameters for a specific reader and antenna. It can set all of the parameters which can be read by getparamblock.
changeparamblock
Reads the current parameters from the reader, changes any which are specified in the arguments, then writes them back out. This is impelemented in terms of getparamblock and setparamblock, and recognizes the same parameters as they do. Returns a hash reference with the following attributes:
readfullfield
Read all tags in the field of the specified antenna. Takes parameters node and antenna to specify what field should be read, and returns a reference to a hash containing the following attributes:
-
The total number of tags read. Note that this number can contain duplicates; use readfullfield_unique to filter out duplicates.
-
An array reference containing zero or more RFID::Matrics::Tag objects representing the tags that were read.
readfullfield_unique
Performs a readfullfield, then adds the following attributes to the hash reference:
-
The number of unique tags found.
-
An array reference containing zero or more RFID::Matrics::Tag objects representing the unique tags that were read.
start_constant_read
Start a constant read until a stop_constant_read command. After calling this method, repeatedly call constant_read to get tags that the reader sees. The parameter to this method is a hash that can specify the node and antenna that should do the reading, and also:
- antenna1, antenna2, antenna3, antenna4
-
Which antennas should be read in each time slot. Leave a parameter undefined to skip that timeslot. If antenna1 isn't given, antenna is used.
- antenna1_power, antenna2_power, antenna3_power, antenna4_power
-
The power level for the antenna in each of the time slots.
- dwell_time
-
The number of milliseconds to scan for, between 6 and 150.
- channel
-
The frequency channel to use, from 0 to 16.
constant_read
Returns tags from an ongoing constant read operation. You call start_constant_read to start reading, and stop_constant_read when you're finished.
Each time this method is called, it returns a hashref with the following attributes:
-
The number of tags found
-
An array reference containing zero or more RFID::Matrics::Tag objects representing the tags that were read.
stop_constant_read
Take the reader out of constant read mode.
stop_all_constant_read
Stop all ongoing constant read operations, returning the reader to its default mode.
epc_readfullfield
Reads all tags in the field of the specified antenna. Parameters and return values are identical to readfullfield.
epc_readfullfield_unique
Performs an epc_readfullfield, then adds attributes to the hash reference representing the unique tags. Pretty much the same as readfullfield_unique.
epc_getparamblock
Get parameters for a particular reader and antenna using the EPC style. The only difference seems to be the way filters are returned, and since filters are not yet implemented, this method is currently functionally identical to getparamblock, although it sends a different command. The parameters are identical.
epc_setparamblock
Set parameters for a particular reader and antenna using the EPC style. The only difference between this command and setparamblock seems to be the way filters are defined, and since filters are not yet implemented, this method is currently functionally identical to setparamblock, although it sends a different command. The parameters are identical.
epc_changeparamblock
Modifies parameters for a particular reader and antenna using the EPC style. This command is implemented in terms of epc_getparamblock and epc_setparamblock. The only difference between this command and changeparamblock seems to be the way filters are defined, and since filters are not yet implemented, this method is currently functionally identical to setparamblock, although it sends different commands. The parameters are identical.
setnodeaddress
Sets the node number for the reader with the given serial number. Takes a hash that can contain the following parameters:
- serialnum
-
The serial number of the reader unit, as a hexadecimal string. For example:
serialnum => "00000000000003AF"
- newnode
-
The new node number. If not given, node is used.
- oldnode
-
The old node number that the message should be addressed to. If not given, the broadcast address
0xFF
is used.
getreaderstatus
Gets the status of a reader, including firmware version. Takes as parameters a hash that can have the node and address. Returns a hash reference with the following attributes:
- serialnum
-
The serial number of the reader.
- version
-
The firmware version number.
Other attributes are not yet implemented.
getnodeaddress
Gets the node address of the reader with the given serial number. Takes a hash containing the following parameters:
- serialnum
-
A hex string of the serial number of the router.
Returns a hash reference with a node parameter giving the node number.
finish
Perform any cleanup tasks for the reader. In particular, shut off any constant reads that are currently running.
SEE ALSO
RFID::Matrics::Reader::Serial, RFID::Matrics::Reader::TCP, RFID::Matrics::Tag.
AUTHOR
Scott Gifford <gifford@umich.edu>, <sgifford@suspectclass.com>
Copyright (C) 2004 The Regents of the University of Michigan.
See the file LICENSE included with the distribution for license information.