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

Function parse

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

* Parses an RTCM3 message frame into the predefined array structure. * * RTCM3 frame structure: * Byte 0: Preamble (0xD3) * Bytes 1-2: Reserved (6 bits) + Message length (10 bits) * Bytes 3-n: Message payload * Bytes n+1-n+3: CRC-24Q checksum * * Message payload struct

(frame)

Source from the content-addressed store, hash-verified

185 * @returns {array} Array of values mapped according to messageTypeMap
186 */
187function parse(frame) {
188 if (frame.length < 6)
189 return parsedValues;
190
191 if (frame[0] !== 0xD3) {
192 console.error("Invalid RTCM3 preamble");
193 return parsedValues;
194 }
195
196 var msgLength = ((frame[1] & 0x03) << 8) | frame[2];
197
198 if (frame.length < 3 + msgLength + 3) {
199 console.error("Incomplete RTCM3 frame");
200 return parsedValues;
201 }
202
203 if (!validateCRC24(frame)) {
204 console.error("RTCM3 CRC validation failed");
205 return parsedValues;
206 }
207
208 var payload = [];
209 for (var i = 3; i < 3 + msgLength; i++)
210 payload.push(frame[i]);
211
212 var messageType = readBits(payload, 0, 12);
213
214 if (!messageTypeMap.hasOwnProperty(messageType))
215 return parsedValues;
216
217 var config = messageTypeMap[messageType];
218
219 try {
220 var values = config.parser(payload, 12);
221 for (var i = 0; i < values.length && i < config.indices.length; i++)
222 parsedValues[config.indices[i]] = values[i];
223 }
224 catch (e) {
225 console.error("RTCM3 parsing error:", e.message);
226 }
227
228 return parsedValues;
229}

Callers

nothing calls this directly

Calls 4

validateCRC24Function · 0.85
readBitsFunction · 0.85
errorMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected