Cyclic Redundancy Check

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?

The sender and receiver should use the same CRC algorithm. The sender calculates the CRC value of the sent data and appends the CRC value. The receiver calculates the CRC of the received data and compares it with the following CRC value. The CRC calculation from the data is the same in both cases.

As an aside, I think CRC8 and CRC_8() in your sample code are poorly chosen names since they are similar enough to cause confusion.

(CRC8 ^ 0x18)

Suggests that the polynomial is 0x18.
[edit] but you don't need to know that. Just use the CRC_8 function to generate the CRC for you. The function which tests a CRC on receive is the same function which generates a polynomial for transmission.

Pete