some test code

This commit is contained in:
Robin Müller 2022-10-22 15:00:48 +02:00
parent 1ef3e13b3d
commit ed30bef4aa
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 15 additions and 0 deletions

1
Cargo.lock generated
View File

@ -254,6 +254,7 @@ dependencies = [
"delegate 0.8.0", "delegate 0.8.0",
"fsrc-core", "fsrc-core",
"spacepackets", "spacepackets",
"zerocopy",
] ]
[[package]] [[package]]

View File

@ -7,6 +7,7 @@ authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
[dependencies] [dependencies]
crossbeam-channel = "0.5" crossbeam-channel = "0.5"
delegate = "0.8" delegate = "0.8"
zerocopy = "0.6.1"
[dependencies.spacepackets] [dependencies.spacepackets]
path = "../spacepackets" path = "../spacepackets"

View File

@ -1,5 +1,6 @@
use crossbeam_channel::{bounded, Receiver, Sender}; use crossbeam_channel::{bounded, Receiver, Sender};
use std::thread; use std::thread;
use zerocopy::{FromBytes, AsBytes, Unaligned, U16, NetworkEndian};
trait FieldDataProvider: Send { trait FieldDataProvider: Send {
fn get_data(&self) -> &[u8]; fn get_data(&self) -> &[u8];
@ -26,6 +27,18 @@ impl FieldDataProvider for FixedFieldDataWrapper {
type FieldDataTraitObj = Box<dyn FieldDataProvider>; type FieldDataTraitObj = Box<dyn FieldDataProvider>;
struct ExampleMgmSet {
mgm_vec: [f32; 3],
temperature: u16
}
#[derive(FromBytes, AsBytes, Unaligned)]
#[repr(C)]
struct ExampleMgmSetZc {
mgm_vec: [u8; 12],
temperatur: U16<NetworkEndian>
}
fn main() { fn main() {
let (s0, r0): (Sender<FieldDataTraitObj>, Receiver<FieldDataTraitObj>) = bounded(5); let (s0, r0): (Sender<FieldDataTraitObj>, Receiver<FieldDataTraitObj>) = bounded(5);
let data_wrapper = FixedFieldDataWrapper::from_two_u32(2, 3); let data_wrapper = FixedFieldDataWrapper::from_two_u32(2, 3);