MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / validateCRC24

Function validateCRC24

app/rcc/scripts/parser/js/rtcm_corrections.js:134–157  ·  view source on GitHub ↗

* Validates the RTCM CRC-24Q checksum. * RTCM3 uses the CRC-24Q polynomial 0x1864CFB.

(data)

Source from the content-addressed store, hash-verified

132 * RTCM3 uses the CRC-24Q polynomial 0x1864CFB.
133 */
134function validateCRC24(data) {
135 if (data.length < 6)
136 return false;
137
138 var crcPolynomial = 0x1864CFB;
139 var crc = 0;
140
141 for (var i = 0; i < data.length - 3; i++) {
142 crc ^= (data[i] << 16);
143 for (var j = 0; j < 8; j++) {
144 crc <<= 1;
145 if (crc & 0x1000000)
146 crc ^= crcPolynomial;
147 }
148 }
149
150 crc &= 0xFFFFFF;
151
152 var receivedCRC = (data[data.length - 3] << 16) |
153 (data[data.length - 2] << 8) |
154 data[data.length - 1];
155
156 return crc === receivedCRC;
157}
158
159//------------------------------------------------------------------------------
160// Frame Parser Function

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected