RFID::Matrics::CRC - Implements the Matrics CRC algorithm.
use RFID::Matrics::CRC qw(crc); # Generate a packet to send $data = "\x04\x06\x22\xa0"; $crc = crc(length($data),0xBEEF,$data); $packet = pack("Ca*v",1,$data,$crc); # Check an existing packet ($sof,@dat{qw(node len cmd status data crc)}) = unpack("CCCCCa${dl}v",$packet); unless (crc(length($packet)-3,0xBEEF,substr($packet,1,-2)) == $dat{crc}) { return $self->error("Bad CRC in packet!\n"); }
Implements the Matrics CRC algorithm, as describe on pages 4-5 of Stationary Reader/Host Protocol (RS-485) Specification version 2.8 from October 19, 2003.
Calculate the Matrics CRC for $buf, with an intial CRC of $crc. $crc defaults to 0xBEEF, which is usually the right thing.
$buf
$crc
0xBEEF
RFID::Matrics::Reader.
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.
To install RFID::Matrics::Reader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RFID::Matrics::Reader
CPAN shell
perl -MCPAN -e shell install RFID::Matrics::Reader
For more information on module installation, please visit the detailed CPAN module installation guide.