1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! The flight computer -> ground station data logging format.
//!
//! This format is a one to one mapping of the fields that are available on the ground station
//!
//! # Overview
//! Flight computer data can be thought of as a stream of messages.
//! Each message carries a piece of information about the flight computer along with a timestamp
//! of when that message was generated.
//!
//! Because standardizing time on embedded system is hard, this format uses a ticks based system,
//! where the tick rate can be changed inside the format itself. This gives the flight computer
//! lots of flexability to manage its time, while being able to very percisely report exactly when
//! data samples were recorded.
//! Tick 0 is when the flight computer wakes up and there are 1024 ticks per second by default.
//!
//! The data stream generally starts with [`BarometerCalibration`], so that the
//! ground station has the calibration constants it needs, and [`Data::TicksPerSecond`] to
//! establish a custom data rate other than 1024.
//! This is because these actions are done when the flight computer wakes up.
//! The order of messages follows very closley with what the flight computer is doing at any one time,
//! because the current implementation simply reads data, and then immediately records it.
//!
//! # Associated State
//!
//! Any state change on the flight computer (such as a change in calibration constants, or tick
//! rate) that would effect the reconstruction of the data format is always emitted and must be
//! handled.
//! Because of this, decoding implementations must maintain a certain abount of state and update it
//! as new state messages are recieved in order to accuratly reconstruct what happened from the
//! flight computer's point of view.
//!
//! # Assumptions
//!
//! This is the gereral format, however implementations must not make assumptions about the order
//! or quantity of each message type, with the following exceptions:
//! 1. [`Data::BarometerData`] messages will only follow after [`Data::BarometerCalibration`] messages have been
//! sent before.
//!
//! # Ticks State Example
//!
//! If the first message is a calibration message with [`Message::ticks_since_last_message`] set to 1024,
//! because the default tick rate is 1024, we know that this message was emitted 1 second after
//! flight computer woke up.
//! If the second message is a `TicksPerSecond` message which changes the tick rate to 1,000,000/s,
//! and `ticks_since_last_message` is set to 1024, this change happened 1 second after the calibration
//! message, so 2 seconds total since wakeup.
//! Once this message is processed, all future tick calculations must use the new tick rate.
//! If the third message is a `BarometerData` message recieved 500,000 ticks after the
//! `TicksPerSecond` message, because the new tick rate is 1,000,000 ticks per second,
//! it has been 0.5 seconds since the last message or 2.5 seconds total since wakeup.
//!
//! # Format on the Wire
//!
//! The format of the actual data on the wire is unstable and subject to change, however we plan
//! to use postcard plus serde with these structs until a more efficent bit for bit format can be
//! implemented. Perhaps we could make a crate that automates this process using smaller bit wrapper
//! types U14, U20, u6, etc. to give hints to a proc macro so that enum tags can be packed with data
//! more efficently.
use ;
/// Calibration values from the barometer's internal memroy,
/// used to convert raw values into unit values
/// Raw data values that come from a single sample of the barometer
/// Raw data values that come from a single sample of the barometer
/// A message from the flight computer.
/// Many of these messages compose its data stream throughout a flight