STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
fake_gnss.h
Go to the documentation of this file.
1#ifndef STAR_FAKE_GNSS_H
2#define STAR_FAKE_GNSS_H
3
4/*
5 * A pretend MAX-M10S on the far end of UART9, behaving as its data sheet and
6 * Interface Description say:
7 * - powers up at 9600 baud sending NMEA once a second (data sheet p.13)
8 * - hears the board only when both sides use the same baud
9 * - parses UBX-CFG-VALSET itself, reading each value's size from the key
10 * ID (bits 30..28, Interface Description p.124), not from the sender
11 * - CFG-UART1-BAUDRATE switches its baud; the other keys ACK and turn on
12 * NAV-PVT at the requested rate with NMEA off
13 * Plugs into gnss_core as its gnss_io_t; fake_gnss_emit() returns what the
14 * module transmitted by now_us (garbage bytes if the bauds disagree).
15 */
16
17#include <stdbool.h>
18#include <stddef.h>
19#include <stdint.h>
20
21#include "gnss_core.h"
22
23typedef void (*fake_gnss_truth_t)(uint32_t t_us, ubx_pvt_t* out);
24
25typedef struct {
28 uint16_t rate_ms;
29 uint8_t dynmodel;
30 bool nak_next; /* answer the next config VALSET with a NAK */
35 uint8_t pending[512];
38
39void fake_gnss_init(fake_gnss_t* f, uint32_t baud, fake_gnss_truth_t truth);
41/* Bytes the module sent up to now_us, as the board's UART sees them. */
42size_t fake_gnss_emit(fake_gnss_t* f, uint32_t now_us, uint8_t* out,
43 size_t cap);
44/* Power cycle: back to 9600, NMEA, no NAV-PVT (RAM config lost). */
45void fake_gnss_power_cycle(fake_gnss_t* f, uint32_t now_us);
46
47#endif
void fake_gnss_power_cycle(fake_gnss_t *f, uint32_t now_us)
Definition fake_gnss.c:128
size_t fake_gnss_emit(fake_gnss_t *f, uint32_t now_us, uint8_t *out, size_t cap)
Definition fake_gnss.c:177
gnss_io_t fake_gnss_io(fake_gnss_t *f)
Definition fake_gnss.c:136
void(* fake_gnss_truth_t)(uint32_t t_us, ubx_pvt_t *out)
Definition fake_gnss.h:23
void fake_gnss_init(fake_gnss_t *f, uint32_t baud, fake_gnss_truth_t truth)
Definition fake_gnss.c:118
uint32_t next_pvt_us
Definition fake_gnss.h:31
uint32_t module_baud
Definition fake_gnss.h:26
unsigned acks
Definition fake_gnss.h:33
gnss_frame_parser_t rx
Definition fake_gnss.h:32
bool nak_next
Definition fake_gnss.h:30
uint16_t rate_ms
Definition fake_gnss.h:28
fake_gnss_truth_t truth
Definition fake_gnss.h:34
uint32_t uart_baud
Definition fake_gnss.h:26
uint8_t pending[512]
Definition fake_gnss.h:35
size_t pending_len
Definition fake_gnss.h:36
unsigned garbled_rx
Definition fake_gnss.h:33
uint32_t next_nmea_us
Definition fake_gnss.h:31
uint8_t dynmodel
Definition fake_gnss.h:29
unsigned naks
Definition fake_gnss.h:33
bool pvt_on
Definition fake_gnss.h:27
unsigned valsets
Definition fake_gnss.h:33
unsigned baud_changes
Definition fake_gnss.h:33
bool nmea_on
Definition fake_gnss.h:27
static void truth(uint32_t t, ubx_pvt_t *v)