Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re^5: How to use perl digest module to calculate CRC? by BrowserUk
in thread How to use perl digest module to calculate CRC? by guyra

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-16 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found