bonzi has asked for the wisdom of the Perl Monks concerning the following question:
I need to calculate CRC-16/X25 checksum/digest in order to communicate with some instrument. I am using Digest::CRC module and https://crccalc.com/ site for both the source of appropriate parameters and to check the result. (The examples in the instrument manual agree with results on csccalc.com.) However, I cannot seem to get correct results. Here is a snippet of may code:
I am either interpreting the parameters incorrectly, on missunderstand the arcana of pack/unpack functions and the need for them, or something else entirely. A bit of enlightenment would be appreciated.use Digest::CRC; my ($crc, $input, $width, $init, $xorout, $refout, $poly, $refin, $con +t, $digest, $ctx); $width = 16; $init = 0xffff; $xorout = 0xffff; $refout = 1; $poly = 0x1021; $refin = 1; $cont = 0; # ??? $input = 0xaabbccdd; $ctx = Digest::CRC->new(width=>$width, init=>$init, xorout=>$xorout, refout=>$refout, poly=>$poly, refin=>$refin, cont=>$cont); $ctx->add($input); $digest = $ctx->hexdigest; say $digest;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CRC-16/X25 problem
by pryrt (Abbot) on Mar 16, 2024 at 20:07 UTC | |
|
Re: CRC-16/X25 problem
by Danny (Chaplain) on Mar 16, 2024 at 19:39 UTC | |
by bonzi (Acolyte) on Mar 16, 2024 at 19:58 UTC | |
by GrandFather (Saint) on Mar 17, 2024 at 20:27 UTC | |
|
Re: CRC-16/X25 problem
by bonzi (Acolyte) on Mar 16, 2024 at 19:57 UTC | |
by ikegami (Patriarch) on Mar 17, 2024 at 23:07 UTC | |
by Danny (Chaplain) on Mar 16, 2024 at 20:01 UTC |