SF000 LiDAR Sensor
Product guide
C/C++
uint16_t
createCRC
(
uint8_t
* Data,
uint16_t
Size)
{
uint16_t
crc =
0
;
for
(
uint32_t
i =
0
; i < Size; ++i)
{
uint16_t
code = crc >>
8
;
code ^= Data[i];
code ^= code >>
4
;
crc = crc <<
8
;
crc ^= code;
code = code <<
5
;
crc ^= code;
code = code <<
7
;
crc ^= code;
}
return
crc;
}
JavaScript
function
createCRC
(data, size) {
let
crc =
0
;
for
(
let
i =
0
; i < size; ++i) {
let
code = crc >>>
8
&
0xFF
;
code ^= data[i] &
0xFF
;
code ^= code >>>
4
;
crc = crc <<
8
&
0xFFFF
;
crc ^= code;
code = code <<
5
&
0xFFFF
;
crc ^= code;
code = code <<
7
&
0xFFFF
;
crc ^= code;
}
return
crc;
}
26 of 47
SF000 microLiDAR™ sensor - Product guide(Rev 5) | © LightWare Optoelectronics (Pty) Ltd, 2021 |