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

I have a file containing data in HEX.

example:

@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

etc..

I need to calculate the CRC for this data:

my poly is non-standard.

P=1edc6f41

init value = 0xFFFFFFFF

I'm going to use the digect::CRC to do it and I want some kind of a model as a reference to know that I do it correctly.

By the way, as far as I understand, the digest::CRC consider the data as an ASCII string.

Meaning it takes each char, gets it ascii value, and then convert it to BIN.

This is not what I need.

Ineed it to take the chars and consider them as a HEX value, and just convert them to BIN.

Any idea on how I should achive it?

Thx a lot

Guy.

  • Comment on Re^4: How to use perl digest module to calculate CRC?

Replies are listed 'Best First'.
Re^5: How to use perl digest module to calculate CRC?
by BrowserUk (Patriarch) on Mar 21, 2013 at 13:07 UTC
    I need to calculate the CRC

    You still aren't answering the question of why you need this?

    That is, the normal reason for calculating a crc is to detect transmission errors; but to do that, you need the crc as calculated prior to transmission to compare against. (Or if you are the transmitter; then a full description of the CRC algorithm expected by the receiver.

    I'll be more specific: is the CRC algorithm you wish to use 'Rocksoft Model CRC Algorithm'?

    If so, the full parameter set for teh algorithm should read something like:

    Name : "CRC-32C" Width : 32 Poly : 1EDC6F41 (note that the leading "1" is implied) Init : FFFFFFFF RefIn : True RefOut : True XorOut : FFFFFFFF Check : E3069283
    By the way, as far as I understand, the digest::CRC consider the data as an ASCII string. Meaning it takes each char, gets it ascii value, and then convert it to BIN. This is not what I need.

    Then you'll need to pre-pack the data before giving it to Digest::CRC.

    To do that, you'll need to know whether the CRC should be calculated for the data bytes alone; or should the preceding addresses be included some how?

    What format is the data file in? Ie. Where does it come from? What produces it?


    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.