Scott Gifford > RFID-Matrics > RFID::Matrics::CRC

Download:
RFID-Matrics-0.002.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

RFID::Matrics::CRC - Implements the Matrics CRC algorithm.

SYNOPSIS ^

    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");
    }

DESCRIPTION ^

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.

FUNCTIONS

crc($buf [,$crc])

Calculate the Matrics CRC for $buf, with an intial CRC of $crc. $crc defaults to 0xBEEF, which is usually the right thing.

SEE ALSO ^

RFID::Matrics::Reader.

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.

syntax highlighting: