XX XX XX XX is hexadecimal float.
1089625758==0x40F25E9E==7.57405f==7.6m
And this is how I think crc is calculated:
+ couple commands to test with bluetooth(I don't have BT device)
/* BOSCH laser serial data crc value computing */
/* Program prints out crc value of byte array */
/* [0xC0][command][length][data][crc] */
//#include "stdafx.h"
#include "stdio.h"
#include "stdint.h"
#define POLYNOMIAL 166;
#define SEED 170;
//http://www.ti.com/lit/an/slua363/slua363.pdf
int calc_crc(int data_byte, int crc)
{
int bit_mask = 0, carry_check = 0, temp_data = 0;
temp_data = data_byte;
for (bit_mask = 0; bit_mask <= 7; bit_mask++)
{
data_byte = data_byte ^ crc;
crc = crc << 1;
temp_data = temp_data << 1;
carry_check = data_byte & 0x80;
if (carry_check)
{
crc = crc ^ POLYNOMIAL;
}
data_byte = temp_data;
}
return (crc);
}
int main()
{ //test arrays
//received data:
uint8_t data[] = { 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x08, 0xC1, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //serial number received from device last byte 0xD4 removed(crc)
//commands:
//uint8_t data[] = { 0xC0, 0x55, 0x02, 0x01, 0x00 }; //crc should be 0x1A. PRL30C Set device as BT master
// these commands might work after device is set as BT master
//uint8_t data[] = { 0xC0, 0x51, 0x02, 0xFF, 0xFF }; //crc should be 0x9C. Get how many measurements in device memory
//uint8_t data[] = { 0xC0, 0x51, 0x02, 0x01, 0x01 }; //crc should be 0x18. Get measurement 1
//uint8_t data[] = { 0xC0, 0x51, 0x02, 0x01, 0x0A }; //crc should be 0x80. Get measurement 10
uint8_t crc = 0;
uint8_t newseed = SEED;
uint32_t bytearraysize = sizeof(data) ;
uint32_t bytepos = 0;
//calculate crc
do
{
newseed = calc_crc(data[bytepos++], newseed);
}while (bytepos < bytearraysize);
crc = newseed;
printf("crc: 0x%X ", crc);
getchar();
return 0;
}