Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^5: How to use perl digest module to calculate CRC?

by BrowserUk (Pope)
on Mar 21, 2013 at 14:35 UTC ( #1024764=note: print w/ replies, xml ) Need Help??


in reply to Re^4: How to use perl digest module to calculate CRC?
in thread How to use perl digest module to calculate CRC?

I'm acting as a transmitter, and I need to calculate the CRC and then send it along with the message.

Okay. But you still need to ensure that you calculate it in the same way that the receiver does; which means you need the full parameterisation of the algorithm used.

What you've supplied so far is not enough information:

The CRC algorithem that I'm using is not standard. P = 1EDC6F41 Init value = FFFFFFFF

Hm. Looks an awful lot like this.

But without the full parameters, this is only guesswork:

#! perl -slw use strict; use Digest::CRC; my $o = Digest::CRC->new( width => 32, init => 0xffffffff, poly => 0x1edc6f41, xorout => 0xffffffff, refout => 1, refin =>1, cont => 1 ); while( <DATA> ) { my( $addrr, @hexBytes ) = split; my $data = pack 'H*', join '', @hexBytes; $o->add( $data ); } print $o->hexdigest; __END__ @0000 FF FF FF 02 24 E0 02 26 A9 02 21 B0 02 21 53 02 @0010 21 6A 02 21 EE 02 21 F5 02 25 55 02 22 7B 02 23 @0090 D2 AF D2 B8 75 1F 01 12 0B B1 75 15 00 E5 0B 20

Note: You'll probably need $o->digest rather than $o->hexdigest.

NB: But the above will probably fail because it is just guesswork. Also, you'll need to retain the packed data for transmission.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^5: How to use perl digest module to calculate CRC?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024764]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-12-18 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls