Hey guys,
I've got some code that I use that I've copied from another source. It is as follows:
void Rx_Decode(){ //
rx_bayt = Serial.read();
// CRC8 PyroIgnitorControl
if (rx_bayt == 0xFF && rx_count ==0){
CRC8=0;
rx_count++;
}
else if (rx_count == 1){
CRC_8(rx_bayt);
Adress_rx = rx_bayt;
rx_count++;
}
else if (rx_count == 2){
CRC_8(rx_bayt);
CH_rx = rx_bayt;
rx_count++;
}
else if (rx_count == 3){
if (CRC8 == rx_bayt ){
Fire();
}
rx_count=0;
}
}
This function reads incoming serial in 4 byte lots: A start byte of 0xFF, an address byte, a channel byte and a CRC8 byte.
void CRC_8(unsigned char b){
for(char i = 0; i < 8; b = b >> 1, i++){
if((b ^ CRC8) & 1) CRC8 = ((CRC8 ^ 0x18) >> 1) | 0x80;
else CRC8 = (CRC8 >> 1) & ~0x80;
}
}
This code works fine and is very reliable, but until now I've been using the software that this code was designed for which sends out the serial automatically. I'd like to make my own transmitter which means I need to know what to send for the CRC byte. From what I can tell it is dependent on the polynomial used in the CRC but is there any way to tell what the polynomial is based on this code?