build: move the int/stream type mapping into a simdata module shared by the build script

This commit is contained in:
2025-12-24 09:59:12 +01:00
parent 2630c97609
commit 83e4614d10
5 changed files with 54 additions and 22 deletions

View File

@@ -5,6 +5,11 @@ use std::fs::File;
use image::GenericImageView;
use csv::Reader;
#[path ="src/simdata.rs"]
mod simdata;
use crate::simdata::StreamType;
fn main() {
linker_be_nice();
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
@@ -205,17 +210,17 @@ fn write_sim_data() {
let mut motion_output = File::open(motion_output).unwrap();
let mut gps_output = File::open(gps_output).unwrap();
let mut annotation_output = File::open(annotation_output).unwrap();
rmp::encode::write_ext_meta(&mut unified_fd, motion_output.metadata().unwrap().len() as u32, 1).unwrap();
rmp::encode::write_ext_meta(&mut unified_fd, motion_output.metadata().unwrap().len() as u32, StreamType::IMU.into()).unwrap();
let mut buf = Vec::new();
motion_output.read_to_end(&mut buf).unwrap();
unified_fd.write_all(buf.as_slice()).unwrap();
rmp::encode::write_ext_meta(&mut unified_fd, gps_output.metadata().unwrap().len() as u32, 2).unwrap();
rmp::encode::write_ext_meta(&mut unified_fd, gps_output.metadata().unwrap().len() as u32, StreamType::GPS.into()).unwrap();
let mut buf = Vec::new();
gps_output.read_to_end(&mut buf).unwrap();
unified_fd.write_all(buf.as_slice()).unwrap();
rmp::encode::write_ext_meta(&mut unified_fd, annotation_output.metadata().unwrap().len() as u32, 3).unwrap();
rmp::encode::write_ext_meta(&mut unified_fd, annotation_output.metadata().unwrap().len() as u32, StreamType::Annotations.into()).unwrap();
let mut buf = Vec::new();
annotation_output.read_to_end(&mut buf).unwrap();
unified_fd.write_all(buf.as_slice()).unwrap();