I am writing a class for handling multiple DS18B20 1-Wire digital temperature sensors on the same 1-wire bus. I have my code successfully performing bus scans, and reading temeratures but I cant’ seem to get my head wraped around re-calculating the CRC codes and comparing them to the CRC values from the DS18B20 using a ‘polynomial generator’. As I understand it you compare CRC values to make sure that there was not a data collision on the bus causing bit flips or otherwise corrupted data.
REFERENCE: http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf (see CRC GENERATION pg. 8)
Then I discovered this function: Microsoft.SPOT.Hardware.Utility.ComputeCRC (see below)…
Does anyone have any idea if it will calculate the CRC code I need and if it will, what the heck is the “seed for the CRC calculation”?
[MethodImplAttribute]
public static UInt32 ComputeCRC (
byte[] buf,
int offset,
int length,
UInt32 crc
)
buf A buffer of data from which the CRC is computed.
offset The offset from the beginning of the specified array to the beginning of the data to be checked.
length The number of bytes of data to be checked, starting from the offset. The value -1 indicates that all data in the buffer starting from the offset is to be checked.
crc A seed for the CRC calculation.