0

unsigned int buffer[] ={
0xffff, 0x1d24, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x0, 0x0, 0x0, 0x0, 0x0}

  • do anyone know, how to fix it – Mehul Dhameliya Jun 19 '23 at 08:52
  • Could you edit your question to explain what is the desired result and which 32 bit CRC polynomial is being used, if the CRC is left shifting or right shifting (reflected), and if there is an initial CRC value other than zero, and if the CRC is post-complemented? – rcgldr Jun 25 '23 at 20:55

1 Answers1

0

Assuming the buffer data is unsigned short, then try the buffer shown below, which should be the same CRC as the original buffer if using a left shifting CRC32.

unsigned short bfrx[] = {0xffff, 0x1d24, 0xffff, 0xffff, 
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0xffff, 0xffff, 0xffff, 0xffff,
                         0x0000, 0x0000, 0x0000, 0x463f,
                         0x2dac};

What the question show is replacing 0xffff with 0x1d24, which is the same a xor'ing 0xffff with 0xe2db. Since there are 4 bytes of zeroes at the end of the buffer a simple approach would be to generate the CRC for a buffer with 4 less bytes:

unsigned short bfrz[] = {0x0000, 0xe2db, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000, 0x0000,
                         0x0000, 0x0000, 0x0000};

Then store the CRC into the last 4 bytes of bfrx.

There is a more generic approach (reverse cycling and|or multiplying by power of 2), but I'm guessing on what the question is actually asking, so unless there is feedback, I can't offer a good explanation.

rcgldr
  • 27,407
  • 3
  • 36
  • 61