Nortec HumDigital User Manual
Page 24
Created: 04.06.2007
24
Changed: 21.12.2007
Printed: 02.03.2009
- Zone 3 values: Humidity: 40.8 % rH, temp.: 20.1 °C
(D:1;40.8;20.1)
- Checksum: 32219 (Z32219)
3.1.3 Transfer parameters
19,200 bit/s
Data bits: 8
Stop bit: 1
Parity: none
Flow control: none
3.1.4 CRC checksum
It is not usually necessary to calculate and evaluate the checksum.
If desired, it can be calculated as follows:
Up to and including the “Z” identifier, the function “crc_one_byte()” is
accessed for every figure in the telegram, with "*oldchecksum” initialised to 0
at the start of the telegram.
Algorithm
/* calculate 16-Bit CRC */
/* At start of calculation *oldchecksumP must be */
/* initialised to 0 */
/* oldchecksumP (IO): pointer on (previous) checksum*/
/* b: next byte of data stream */
void crc_one_byte(u16 *oldchecksumP, unsigned char b)
{
u16 result;
unsigned char a=b ^ (*oldchecksumP)>>8 ^ (*oldchecksumP)>>4 ^ (*oldchecksumP)>>1
^ (*oldchecksumP)<<1;
result = (*oldchecksumP)<<8 | a ^ a>>7;
*oldchecksumP = result;
}