Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions firmware-common-new/src/can_bus/messages/vl_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use super::{CanBusMessage, CanBusMessageEnum};

/// may skip stages, may go back to a previous stage
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(PrimitiveEnum_u8, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize)]
#[repr(C)]
#[derive(PrimitiveEnum_u8, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
#[rkyv(derive(Clone, Copy, Debug))]
#[repr(u8)]
pub enum FlightStage {
LowPower = 0,
SelfTest = 1,
Expand Down
57 changes: 57 additions & 0 deletions firmware-common-new/src/flight_data_record.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use crate::{
can_bus::messages::vl_status::FlightStage, gps::GPSData,
vlp::packets::gps_beacon::GPSBeaconPacket,
};

#[derive(rkyv::Serialize, rkyv::Deserialize, rkyv::Archive, Debug, Clone, PartialEq)]
pub struct FlightDataRecord {
pub record_count: u32,
// theoretically, since the recording will start at boot, and we know boot time, we may not need to log the timestamp, this is just in case.
pub timestamp_us: u64,

// [f32;3] is used because Vector3<f32> wouldve been a pain to make serialisable for rkyv
// IMU data
pub acc: [f32; 3],
pub gyro: [f32; 3],

// Barometer data
pub temperature: f32,
pub pressure: f32,
///
pub mag: [f32; 3],
///
pub battery_voltage: f32,
///
// bitmask for if each of the data points is valid, (exists cause GPS data is inconsistent and rkyv cant work with option)
pub valid: u8,
///
// gps data
pub lat_lon: (f64, f64),
pub altitude: f32,
pub num_of_fixed_satalites: u8,
pub hdop: f32,
pub vdop: f32,
pub pdop: f32,
///
pub flight_stage: FlightStage,

// bitmask for ContinuityUpdate (which is in vlf5/firmware)
pub pyro_flags: u8,
}

// `valid` bitmask: which fields in a record held trustworthy data when it was
// logged. Shared between the firmware logger and the host CLI so both agree on
// the meaning of every bit.
pub const VALID_IMU: u8 = 1 << 0;
pub const VALID_BARO: u8 = 1 << 1;
pub const VALID_MAG: u8 = 1 << 2;
pub const VALID_GPS_FIX: u8 = 1 << 3;
pub const VALID_GPS_ALT: u8 = 1 << 4;
pub const VALID_BATTERY: u8 = 1 << 5;

// `pyro_flags` bitmask layout (see vlf5 firmware `ContinuityUpdate`).
pub const PYRO_MAIN_CONTINUITY: u8 = 1 << 0;
pub const PYRO_MAIN_FIRE: u8 = 1 << 1;
pub const PYRO_DROGUE_CONTINUITY: u8 = 1 << 2;
pub const PYRO_DROGUE_FIRE: u8 = 1 << 3;
pub const PYRO_SHORT_CIRCUIT: u8 = 1 << 4;
Loading