STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
flight_e2e.c File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "emmc_log.h"
#include "fake_baro.h"
#include "fake_gnss.h"
#include "fake_regs.h"
#include "gnss_core.h"
#include "sensors_core.h"
Include dependency graph for flight_e2e.c:

Go to the source code of this file.

Classes

struct  card_t
struct  rec_t
struct  image_t
struct  faults_t
struct  world_t
struct  check_t

Macros

#define FLIGHT_US   20000000U
#define T_LAUNCH_US   2000000U /* ARMED -> LAUNCHED */
#define T_BURNOUT_US   4000000U /* boost ends */
#define T_RECOVERY_US   10000000U
#define BS   EMMC_BLOCK_SIZE
#define DATA_START   EMMC_LOG_DEFAULT_DATA_START
#define CAPACITY   (DATA_START + 8192U)
#define MAX_RECS   40000U
#define WAKE_LATENCY_US   37U
#define EXPECT(cond, ...)

Enumerations

enum  { PAD , BOOST , COAST , DESCENT }

Functions

static int phase_at (uint32_t t)
static void imu_truth (uint32_t t, int16_t out[7])
static void highg_truth (uint32_t t, int8_t out[3])
static void gps_truth (uint32_t t, ubx_pvt_t *v)
static emmc_status_t c_start (void *ctx, uint32_t *count)
static emmc_status_t c_read (void *ctx, uint32_t lba, void *buf, uint32_t n, uint32_t budget)
static emmc_status_t c_write (void *ctx, uint32_t lba, const void *buf, uint32_t n, uint32_t budget)
static uint32_t crc32_ref (const uint8_t *p, size_t n)
static uint32_t rd32 (const uint8_t *p)
static void read_image (const card_t *card, image_t *img, unsigned max)
static void sink (void *ctx, uint8_t type, const void *data, uint8_t len)
static void set_chips (world_t *w, uint32_t t)
static void change_state (world_t *w, flight_state_t to)
static void world_init (world_t *w, const faults_t *faults)
static void service_card (world_t *w)
static int32_t diff (uint32_t a, uint32_t b)
static void fly (world_t *w)
static void world_free (world_t *w)
static void note (const char *fmt,...)
static void nominal (void)
static void check_sensor_rates (void)
static void check_sample_values (void)
static void check_timestamps (void)
static void check_conservation (void)
static void check_emmc_roundtrip (void)
static void check_emmc_stall (void)
static void check_fault_imu_silent (void)
static void check_gps (void)
int main (int argc, char **argv)

Variables

struct { 
   uint32_t   d1 
   uint32_t   d2 
   int32_t   temp 
   int32_t   p 
} kBaro []
static char detail [512]
static bool ok
static world_t W
static image_t IMG
static bool flown
static const check_t checks []

Macro Definition Documentation

◆ BS

◆ CAPACITY

#define CAPACITY   (DATA_START + 8192U)

Definition at line 106 of file flight_e2e.c.

Referenced by c_read(), c_start(), c_write(), read_image(), and world_init().

◆ DATA_START

◆ EXPECT

#define EXPECT ( cond,
... )
Value:
do { \
if (!(cond)) { \
snprintf(detail, sizeof(detail), __VA_ARGS__); \
ok = false; \
return; \
} \
} while (0)
static bool ok
Definition flight_e2e.c:435
detail namespace with internal helper functions
Definition json.hpp:249

Definition at line 436 of file flight_e2e.c.

Referenced by check_conservation(), check_emmc_roundtrip(), check_emmc_stall(), check_fault_imu_silent(), check_gps(), check_sample_values(), check_sensor_rates(), and check_timestamps().

◆ FLIGHT_US

#define FLIGHT_US   20000000U

Definition at line 36 of file flight_e2e.c.

Referenced by check_sensor_rates(), and fly().

◆ MAX_RECS

#define MAX_RECS   40000U

Definition at line 214 of file flight_e2e.c.

Referenced by check_emmc_stall(), nominal(), sink(), and world_init().

◆ T_BURNOUT_US

#define T_BURNOUT_US   4000000U /* boost ends */

Definition at line 38 of file flight_e2e.c.

Referenced by phase_at().

◆ T_LAUNCH_US

#define T_LAUNCH_US   2000000U /* ARMED -> LAUNCHED */

Definition at line 37 of file flight_e2e.c.

Referenced by phase_at().

◆ T_RECOVERY_US

#define T_RECOVERY_US   10000000U

Definition at line 39 of file flight_e2e.c.

Referenced by phase_at().

◆ WAKE_LATENCY_US

#define WAKE_LATENCY_US   37U

Definition at line 215 of file flight_e2e.c.

Referenced by fly().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PAD 
BOOST 
COAST 
DESCENT 

Definition at line 41 of file flight_e2e.c.

Function Documentation

◆ c_read()

emmc_status_t c_read ( void * ctx,
uint32_t lba,
void * buf,
uint32_t n,
uint32_t budget )
static

Definition at line 120 of file flight_e2e.c.

References card_t::blocks, BS, CAPACITY, EMMC_ERR_PARAM, and EMMC_OK.

Referenced by world_init().

◆ c_start()

emmc_status_t c_start ( void * ctx,
uint32_t * count )
static

Definition at line 115 of file flight_e2e.c.

References CAPACITY, count(), and EMMC_OK.

Referenced by world_init().

◆ c_write()

emmc_status_t c_write ( void * ctx,
uint32_t lba,
const void * buf,
uint32_t n,
uint32_t budget )
static

◆ change_state()

void change_state ( world_t * w,
flight_state_t to )
static

Definition at line 312 of file flight_e2e.c.

References emmc_log_on_state(), world_t::log, world_t::now, and world_t::state.

Referenced by fly(), and world_init().

◆ check_conservation()

void check_conservation ( void )
static

◆ check_emmc_roundtrip()

void check_emmc_roundtrip ( void )
static

◆ check_emmc_stall()

◆ check_fault_imu_silent()

◆ check_gps()

◆ check_sample_values()

void check_sample_values ( void )
static

◆ check_sensor_rates()

void check_sensor_rates ( void )
static

Definition at line 469 of file flight_e2e.c.

References EXPECT, FLIGHT_US, imu, nominal(), note(), and W.

◆ check_timestamps()

void check_timestamps ( void )
static

◆ crc32_ref()

uint32_t crc32_ref ( const uint8_t * p,
size_t n )
static

Definition at line 160 of file flight_e2e.c.

References p.

Referenced by read_image().

◆ diff()

int32_t diff ( uint32_t a,
uint32_t b )
static

Definition at line 365 of file flight_e2e.c.

References a, and b.

Referenced by fly().

◆ fly()

void fly ( world_t * w)
static

Definition at line 369 of file flight_e2e.c.

References BOOST, change_state(), world_t::core, DESCENT, diff(), world_t::edge_highg, world_t::edge_imu, emmc_log_backlog(), fake_gnss_emit(), FLIGHT_ARMED, FLIGHT_IDLE, FLIGHT_LAUNCHED, FLIGHT_RECOVERY, FLIGHT_US, world_t::gnss, gnss_core_feed(), gnss_core_poll(), gnss_core_set_pps(), world_t::gps, world_t::log, world_t::next_gps_us, world_t::next_highg, world_t::next_imu, world_t::next_pps_us, world_t::next_service, world_t::now, phase_at(), sensors_core_step(), sensors_core_wait_us(), SENSORS_EV_HIGHG, SENSORS_EV_IMU, SENSORS_HIGHG_PERIOD_US, SENSORS_IMU_PERIOD_US, service_card(), set_chips(), world_t::state, and WAKE_LATENCY_US.

Referenced by check_emmc_stall(), check_fault_imu_silent(), check_gps(), nominal(), test_flight_launch_and_report::shipped_flight(), test_vehicle_drag::shipped_flight(), test_flight_ullage_and_depletion::test_a_tank_with_no_ullage_is_refused_by_name(), test_flight_ullage_and_depletion::test_apogee_is_continuous_in_the_load(), test_vehicle_drag::test_drag_grows_with_the_vehicle(), test_flight_ullage_and_depletion::test_impulse_is_the_curve_integral_at_the_edge(), test_flight_launch_and_report::test_launch_angle_costs_what_a_gravity_turn_says(), test_flight_launch_and_report::test_launch_comes_from_the_config(), test_layer2_required_impulse::test_layer2_and_the_flight_agree_on_the_shipped_vehicle(), test_flight_ullage_and_depletion::test_one_percent_short_loses_one_percent_of_impulse(), test_flight_ullage_and_depletion::test_pressurant_moved_into_the_ullage_stays_on_board(), test_flight_launch_and_report::test_requirement_checks_fire_only_when_declared(), test_vehicle_drag::test_rougher_skin_more_drag(), test_flight_ullage_and_depletion::test_small_tank_at_ninety_percent_flies(), test_flight_ullage_and_depletion::test_ullage_gas_fills_the_real_ullage_at_tank_pressure(), and test_vehicle_drag::test_user_table_is_flown_as_given().

◆ gps_truth()

◆ highg_truth()

void highg_truth ( uint32_t t,
int8_t out[3] )
static

Definition at line 67 of file flight_e2e.c.

References phase_at().

Referenced by check_sample_values(), and set_chips().

◆ imu_truth()

void imu_truth ( uint32_t t,
int16_t out[7] )
static

Definition at line 55 of file flight_e2e.c.

References phase_at().

Referenced by check_sample_values(), and set_chips().

◆ main()

int main ( int argc,
char ** argv )

Definition at line 733 of file flight_e2e.c.

References checks, failed(), NULL, and ok.

◆ nominal()

void nominal ( void )
static

◆ note()

◆ phase_at()

int phase_at ( uint32_t t)
static

◆ rd32()

uint32_t rd32 ( const uint8_t * p)
static

Definition at line 169 of file flight_e2e.c.

References p.

Referenced by decode(), read_image(), and test_backpressure().

◆ read_image()

void read_image ( const card_t * card,
image_t * img,
unsigned max )
static

Definition at line 174 of file flight_e2e.c.

References b, BS, CAPACITY, card, crc32_ref(), DATA_START, img, max, o, r, and rd32().

Referenced by check_emmc_stall(), and nominal().

◆ service_card()

void service_card ( world_t * w)
static

Definition at line 356 of file flight_e2e.c.

References world_t::card, emmc_log_backlog(), emmc_log_service(), world_t::log, world_t::now, and card_t::now_ms.

Referenced by fly().

◆ set_chips()

◆ sink()

◆ world_free()

void world_free ( world_t * w)
static

Definition at line 426 of file flight_e2e.c.

References card_t::blocks, world_t::card, and world_t::produced.

Referenced by check_emmc_stall(), check_fault_imu_silent(), and check_gps().

◆ world_init()

Variable Documentation

◆ checks

const check_t checks[]
static
Initial value:
= {
{"sensor_rates",
"IMU 833 Hz, high-g 400 Hz, baro ~50 Hz over a 20 s flight",
{"sample_values", "every sample equals the flight profile (raw, exact)",
{"timestamps", "monotonic; IMU/high-g stamped at the data-ready edge",
{"conservation", "every produced record is on the eMMC card, byte for byte",
{"emmc_roundtrip",
"card image: superblock, block CRCs, one session, states",
{"emmc_stall",
"card times out 0.5 s: sensors unaffected, sealed data intact",
{"gps", "GNSS cold start 9600 -> 115200, 10 Hz fixes = truth, PPS-stamped",
{"fault_imu_silent",
"IMU dead 0.5 s: dropped, retried, recovered; others ok",
}
static void check_fault_imu_silent(void)
Definition flight_e2e.c:635
static void check_emmc_stall(void)
Definition flight_e2e.c:586
static void check_gps(void)
Definition flight_e2e.c:664
static void check_emmc_roundtrip(void)
Definition flight_e2e.c:567
static void check_timestamps(void)
Definition flight_e2e.c:525
static void check_conservation(void)
Definition flight_e2e.c:545
static void check_sample_values(void)
Definition flight_e2e.c:480
static void check_sensor_rates(void)
Definition flight_e2e.c:469

Definition at line 710 of file flight_e2e.c.

Referenced by main().

◆ d1

uint32_t d1

Definition at line 77 of file flight_e2e.c.

Referenced by compensate(), and ms5611_compensate().

◆ d2

uint32_t d2

Definition at line 77 of file flight_e2e.c.

Referenced by compensate(), and ms5611_compensate().

◆ detail

char detail[512]
static

Definition at line 434 of file flight_e2e.c.

◆ flown

bool flown
static

Definition at line 453 of file flight_e2e.c.

Referenced by nominal().

◆ IMG

image_t IMG
static

Definition at line 452 of file flight_e2e.c.

Referenced by check_conservation(), check_emmc_roundtrip(), and nominal().

◆ [struct]

const struct { ... } kBaro[]
Initial value:
= {
{9085466, 8569150, 2007, 100009},
{8900000, 8330000, 1175, 94911},
{8500000, 7300000, -3022, 79839},
{9085466, 8569150, 2007, 100009},
}

Referenced by check_sample_values(), and set_chips().

◆ ok

bool ok
static

Definition at line 435 of file flight_e2e.c.

Referenced by ack(), app_start(), board_adc_read(), fsw::net::anonymous_namespace{DaqInterface.cpp}::canBind(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), check(), anonymous_namespace{test_capture_window.cpp}::clear_on_reconnect(), sequencer::SequencerService::commandLoop(), sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::describeCondition(), emmc_log_append(), emmc_log_on_state(), fsw::elodin::ElodinClient::flush_batch(), sequencer::is_valid_script_filename(), fsw::script::is_valid_slug(), fsw::calibration::SensorCalibrationManager::load_from_csv(), fsw::calibration::SensorCalibrationManager::load_from_json(), main(), main(), main(), fsw::config::detail::parse_t7_boards(), parser::parse_table_header(), refuses(), fsw::elodin::DatabaseConfig::register_ball_valve_calibrated_tables(), fsw::elodin::DatabaseConfig::register_ball_valve_cmd_tables(), fsw::elodin::DatabaseConfig::register_ball_valve_tables(), fsw::elodin::DatabaseConfig::register_environmental_tables(), fsw::elodin::DatabaseConfig::register_non_sensor_tables(), fsw::elodin::DatabaseConfig::register_t7_calibrated_tables(), fsw::elodin::DatabaseConfig::register_t7_raw_tables(), fsw::elodin::anonymous_namespace{DatabaseConfig.cpp}::register_t7_vtable(), sequencer::ActuatorCommander::sendSingleActuator(), setup(), sink(), copv.copv_solve::size_or_check_copv_for_polytropic_N2(), copv.copv_solve_both::size_or_check_copv_for_polytropic_N2(), fsw::elodin::ElodinClient::subscribe_tables(), and test_backpressure().

◆ p

int32_t p

Definition at line 78 of file flight_e2e.c.

Referenced by test_layerx_stability::_ramp_series(), test_pid::_valve_with_one_side_open(), path::append(), path::append(), array_index(), path::assign(), path::assign(), fsw::calibration::PTCalibrationManager::calculate_pressure(), check_sample_values(), compensate(), fsw::calibration::CubicCalibrationStore::compute_fit(), crc32_ref(), anonymous_namespace{test_lc_linear_fit.cpp}::cubic_model_is_unchanged(), dma_reachable(), driveAllSolenoids(), emmc_log_crc32(), esp_ota_get_running_partition(), fsw::calibration::RobustCalibrationFramework::extrapolation_variance(), feed(), feed_str(), anonymous_namespace{test_lc_linear_fit.cpp}::fill(), fill_payload(), finish_probe(), fletcher(), flightStateInit(), detail::from_json(), detail::from_json(), detail::from_json(), detail::from_json_tuple_impl(), get16(), get32(), table_iterator< IsConst >::get_proxy(), radio_link::get_u16(), radio_link::get_u32(), detail::binary_reader< BasicJsonType, InputAdapterType, SAX >::get_ubjson_array(), gnss_frame_feed(), anonymous_namespace{idle_e2e.cpp}::ground_arm(), i32(), le16(), fsw::calibration::CubicCalibrationStore::load(), main(), main(), comms::math::matrix_multiply(), on_frame(), on_valset(), parser::parse_key_value_pair_and_insert(), fsw::config::detail::parse_t7_boards(), parser::parse_table_header(), fsw::t7::plan_stream(), port_valid(), fsw::script::anonymous_namespace{Parser.cpp}::printBlock(), fsw::script::anonymous_namespace{Parser.cpp}::printExpr(), fsw::script::anonymous_namespace{Parser.cpp}::printStmt(), probe_one(), fsw::config::pt_boards(), put16(), put32(), put_record(), radio_link::put_u16(), radio_link::put_u32(), pvt(), rd32(), rd32(), ref_crc(), reject(), fsw::calibration::CubicCalibrationStore::save(), fsw::calibration::LcTareStore::save(), anonymous_namespace{test_cubic_store_namespace.cpp}::scratch(), anonymous_namespace{test_lc_linear_fit.cpp}::scratch(), anonymous_namespace{test_lc_tare.cpp}::scratch(), anonymous_namespace{idle_e2e.cpp}::send_heartbeat(), fsw::calibration::CubicCalibrationStore::serialize(), fsw::calibration::RobustCalibrationFramework::set_rls_P_for_restore(), start(), test_backpressure(), test_corrupt_ubx(), test_datasheet_worked_example(), test_frame_roundtrip_through_parser(), test_init_rejects_bad_input(), test_lowercase_checksum(), test_nav_pvt_through_the_frame_parser(), test_noise_then_frame(), test_overlong_and_binary_nmea(), test_prom_crc_mismatch_and_blank_are_rejected(), test_prom_read_and_crc(), test_second_order_below_20c(), test_session_roundtrip(), test_ubx_length_limit(), test_valid_frames(), test_wrong_nmea_checksum(), detail::to_json(), u16(), u32(), ubx_parse_mon_rf(), ubx_parse_nav_pvt(), ubx_sat_summary(), and USBD_static_free().

◆ temp

int32_t temp

Definition at line 78 of file flight_e2e.c.

Referenced by loop(), and ms5611_compensate().

◆ W