STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
radio_fake.h
Go to the documentation of this file.
1#ifndef RADIO_FAKE_H
2#define RADIO_FAKE_H
3
4#include <stdint.h>
5
6#include "radio.h"
7
8// A pretend radio for tests on a laptop. It defines the same three functions
9// as radio.h, but keeps packets in memory. It lives in test/ (not src/) so it
10// can never be built into the rocket next to the real driver.
11namespace radio_link {
12namespace fake {
13
14// Empty the queues and forget everything sent. `chip_present` decides what
15// radio_probe() answers; with no chip, radio_send() answers ErrNotFound.
16// It also puts radio_send() back to answering Ok.
17void reset(bool chip_present = true);
18
19// Make radio_send() give this answer from now on, so a test can check what
20// the caller does when a send fails. A failed send is not recorded.
22
23// Make the next radio_receive() give this answer instead of a packet, once
24// (e.g. ErrNotFound for a radio that stopped answering).
26
27// Pretend a packet arrived. radio_receive() will hand it out.
28// Returns false if the queue is full or `len` is 0.
29bool inject(const uint8_t* bytes, uint8_t len);
30
31// Copy the last packet given to radio_send() into `out`.
32// Returns how many bytes were copied (0 if nothing was sent).
33uint8_t last_sent(uint8_t* out, uint8_t out_cap);
34
35// How many packets radio_send() accepted (answered Ok) since reset().
36unsigned sent_count();
37
38} // namespace fake
39} // namespace radio_link
40
41#endif // RADIO_FAKE_H
json_pointer result
Definition json.hpp:14064