From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CRC 32bit

Solved!
Go to solution

@jay0909 wrote:

[...] HOw is it different from labview implementation?


You should be able to answer that by yourself.

Hint: The C code is for example using a different mask compared to all webpages i searched during trying to answer your questions. It also shifts the data by a different amount of bits.

However, there are multiple implementations for CRC32 (even ones without a table) so it still could be a valid implementation.

 

My guess is that the C code has a typo in the table as LV AND external CRC calculators result in a different CRC compared to the one of your controller.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 31 of 46
(2,400 Views)

So, what i shld do now for calculating proper crc? Any suggestions?

0 Kudos
Message 32 of 46
(2,390 Views)

Well, you stated a frame in your initial post with an expected CRC32. The VIs I linked do calculate exactly this expected behavior for that frame, just like the webpage with the calculator I linked.

A couple of posts before this one, you posted another frame where the online calculator as well as VIs do result in a different CRC32 compared to what you get from the controller. However, the LV and online results are identical.

So either your controller messes things up (as i said, i guess it's a typo in the table) or both LV and online calculator implementation are incorrect.

You might want to find additional calculators for CRC32 to verify the results of LV and the online calculator. With that information, you might be able to identify WHICH one is incorrect.

However, you then have to debug things to find out WHY it is incorrect.


Hint: If the calculator is using a table i would first check all 256 table entries for typos.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 33 of 46
(2,385 Views)

Reminds me that I once worked for a company that implemented an old, proprietary crc calc.  It was very similar, but with slightly different numbers in the table.  It was used only in one old ICD, but because it worked and it would have been a PITA to change throughout their product line, they let it be.  Of course, it's called out in the ICD as the industry standard crc and I went through something very similar to this thread until someone happened by and told me, "Oh, the document is wrong".  Apparently this little tidbit of information was known throughout the company, but only by word of mouth.

 

Thanks a lot.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 34 of 46
(2,378 Views)

Hi,

 

       After some research i found that the implemenatation of UART and calculation of the CRC is from the below link. 

 

http://pubs.opengroup.org/onlinepubs/009695299/utilities/cksum.html 

 

   This is the same implementation in labview as well, but why i get different crc.

0 Kudos
Message 35 of 46
(2,357 Views)

By George I think I got it. It works for the two test cases that the OP provided.

 

 

CRC (ALT).png

0 Kudos
Message 36 of 46
(2,340 Views)

I think there is a bug when the Length is greater than 256. It looks like the C-Code extends the sequence using Least Significant Byte first. I don't have any large data test cases that I can run, so the "reverse 1D Array" may need to be deleted.

 

C_Code.PNG

0 Kudos
Message 37 of 46
(2,329 Views)

HI,

 

        what's the value length of sequence in bytes for this sequence "1C0000009DE50200040400000000000000"?  

 

I gave 34 and tried your example but it resuts in wrong crc?

0 Kudos
Message 38 of 46
(2,286 Views)

@jay0909 wrote:

HI,

 

        what's the value length of sequence in bytes for this sequence "1C0000009DE50200040400000000000000"?  

 

I gave 34 and tried your example but it resuts in wrong crc?


Technically the spec says "octets". (I believe) the definition of an "octet" is 8 bits, whereas "bytes" is machine dependant. 99.99% of the time 1 byte = 8 bits, so octets equals bytes.

 

For your sequence there are 17 bytes. (34 is the number of nibbles)

 

p.s., Do you have a sequence that is longer than 256 bytes?? My snippet may have a bug and I would like to verify that. It appends the sequence with the number of bytes as big endian. I believe it is sppose to be little endian.

0 Kudos
Message 39 of 46
(2,259 Views)

Hi,

 

          The maximum number of bytes is 117. below is the frame. 

 

1500 0000 73A1 0000 0468 0000 0000 0000 0042 02F5 C342 0400 007F FFFF FF3E E76C 8B3C 1374 BC42 4AF0 A444 2566 6642 480F 5C43 6D44 DC42 9CCC 9B42 9ECE 4442 9EEE DAC0 D9D1 F6BE CE63 BBBF 1A27 B1BF 84A4 9E3E A9F4 383E AC67 9E3E AC11 7A43 6C00 8343 6B87 F043 6B9B 23FF FFFF FF7F FFFF FF7F FFFF FF

 

CRC of the above frame : 4705 C23C 

 

Calculation from your program is : EB6E7573. 

0 Kudos
Message 40 of 46
(2,252 Views)