Convert binary to char string for CRC Library

Hopefully a simple one, I just can't figure out with all these datatypes.

I am using the CRC library for Arduino.

The CRC requires a constructor which is a char string (I think this is in ASCII):

char str[24] =  "123456789";
crc8((uint8_t *)str, 9, 0x07), HEX); 

I need to use CRC for a one byte message, for example:

uint8_t buff = 0b01110001;

I have tried a for loop to convert:

  for(int i=0; i<8; i++){
    charArr[i] = bitRead(buff,i);
  }

But receiving the wrong CRC8 Value when using a CRC Calculator.

Any suggestions appreciated. Please keep it simple :slight_smile:

isn't this the same as

char str[1] =  0x71;
1 Like
uint8_t buff = 0b01110001;
uint8_t result = crc8(&buff, 1, 0x07); // strange polynomial here
1 Like

Ah knew it was going to be a simple fix! Thanks