STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
gnss_frame.h
Go to the documentation of this file.
1#ifndef STAR_GNSS_FRAME_H
2#define STAR_GNSS_FRAME_H
3
4/*
5 * Byte-at-a-time validator for what a u-blox M10 sends on its UART:
6 *
7 * NMEA $<body>*<HH> HH = XOR of every body byte (between $ and *)
8 * UBX B5 62 <class> <id> <len16 LE> <payload> <CK_A> <CK_B>
9 * CK = 8-bit Fletcher over class..payload
10 *
11 * Portable (no HAL): the board feeds it UART bytes, the host tests feed it
12 * strings. It only proves a well-formed frame arrived, not a position fix.
13 */
14
15#include <stdint.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21typedef enum {
22 GNSS_FRAME_NONE = 0, /* no complete valid frame ended at this byte */
26
27#define GNSS_FRAME_NMEA_MAX_BODY 96U /* NMEA 0183 says 82 incl. $ and CRLF */
28#define GNSS_FRAME_UBX_MAX_PAYLOAD 1024U
29/* NAV-PVT is 92; NAV-SAT is 8 + 12 per satellite, so 488 holds 40. */
30#define GNSS_FRAME_UBX_CAPTURE 488U
31
32typedef struct {
33 uint8_t state;
34 uint8_t xor_sum;
35 uint8_t ck_a;
36 uint8_t ck_b;
37 uint8_t hex_hi;
38 uint16_t count;
39 uint16_t length;
40 uint32_t rejected; /* frames that started but failed a check */
41 /* Last UBX frame: valid when gnss_frame_feed() returns GNSS_FRAME_UBX.
42 * Payloads longer than GNSS_FRAME_UBX_CAPTURE keep only the first bytes
43 * (ubx_len says the real length). */
44 uint8_t ubx_class, ubx_id;
45 uint16_t ubx_len;
48
51
52#ifdef __cplusplus
53}
54#endif
55#endif
gnss_frame_kind_t
Definition gnss_frame.h:21
@ GNSS_FRAME_NONE
Definition gnss_frame.h:22
@ GNSS_FRAME_UBX
Definition gnss_frame.h:24
@ GNSS_FRAME_NMEA
Definition gnss_frame.h:23
#define GNSS_FRAME_UBX_CAPTURE
Definition gnss_frame.h:30
gnss_frame_kind_t gnss_frame_feed(gnss_frame_parser_t *parser, uint8_t byte)
Definition gnss_frame.c:57
void gnss_frame_init(gnss_frame_parser_t *parser)
Definition gnss_frame.c:35
uint8_t ubx_payload[GNSS_FRAME_UBX_CAPTURE]
Definition gnss_frame.h:46