#include int main() { unsigned long time; signed long tempInt; float temp, hour; unsigned int scratchpad[9], inputBit, crc; int i, j; while ( !feof(stdin) ) { scanf ("%lu ", &time); for (i = 0; i < 9; i++) { scanf ("%02X ", &scratchpad[i]); } if ( (scratchpad[6] < 9) != (scratchpad[0] & 1) ) { printf ("ERROR at time = %lu: COUNT REMAIN and Temperature inconsistent\n", time); } crc = 0; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { inputBit = ( (scratchpad[i] & (1 << j)) != 0 ); inputBit ^= (crc & 1); crc >>= 1; if (inputBit) { crc ^= 0x8C; } } } if (scratchpad[8] != crc) { printf ("ERROR at time = %lu: CRC received = %02X, but CRC calculated = %02X\n", time, scratchpad[8], crc); } tempInt = scratchpad[1]; tempInt <<= 7; tempInt += (scratchpad[0] >> 1); if (tempInt >= 0x8000) { tempInt -= 0x10000; } temp = tempInt - 0.25 + ((float) (16 - scratchpad[6])) / 16; hour = ((float) (time - 1149742800)) / 3600; printf ("%f\t%f\n", hour, temp); } return 0; }