Hello,

I am trying to generate a a CRC-16/XMODEM checksum. I have been using: http://reveng.sourceforge.net/crc-catalogue/16.htm#crc.cat.crc-16-xmodem and crccalc.com as a guide. As well as Digest/CRC.pm however I have been unable to get the perl module Digest::CRC to give me the expected result.

#!/usr/bin/perl -w use strict; use Digest::CRC qw(crc64 crc32 crc16 crcccitt crc crc8 crcopenpgparmor +); my @s=( { 's'=>"9848C503738276ADCA02BF5DC1A3ABF2", 'crc16'=>"9F4B" }, { 's'=>"841374844ADDF4A36CEDB127C82086B9", 'crc16'=>"408E" }, { 's'=>"8AC1070ACD1659BB4F507191E33F7AD4", 'crc16'=>"E1E3" }, { 's'=>"34623A01DCDA35BED462953B4E2458DA", 'crc16'=>"7B40" }, { 's'=>"E29107CB32975E859D76A885BF57BE35", 'crc16'=>"2B92" }, { 's'=>"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 'crc16'=>"0041" }, ); # width=16 poly=0x1021 init=0x0000 refin=false refout=false xorout=0x0 +000 check=0x31c3 residue=0x0000 name="CRC-16/XMODEM" my $width = 16; my $init = 0x0000; my $xorout = 0x0000; my $refout = 0; my $poly = 0x1021; my $refin = 0; my $cont = 0x31c3; for my $tv (@s) { my $crc16 = crc($tv->{s},$width,$init,$xorout,$refout,$poly,$refin +,$cont); print qq{ Input was: $tv->{s} crc: $crc16 -- Should be: $tv->{crc16} }; }
I have another issue in that I do not understand what "cont" is here.

In reply to Generating a CRC-16/XMODEM checksum in Hex by Djinni

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.