Larger update #49

Merged
muellerr merged 41 commits from this-is-complex into main 2023-07-08 15:02:42 +02:00
5 changed files with 32 additions and 24 deletions
Showing only changes of commit da7f929ec0 - Show all commits

View File

@ -18,7 +18,7 @@ paste = "1"
embed-doc-image = "0.1"
[dependencies.num_enum]
version = "0.5"
version = "0.6"
default-features = false
[dependencies.dyn-clone]

View File

@ -630,7 +630,6 @@ impl<Severity: HasSeverity> PartialEq<EventU16TypedSev<Severity>> for EventU16 {
mod tests {
use super::EventU32TypedSev;
use super::*;
use spacepackets::ecss::EcssEnumeration;
use spacepackets::ByteConversionError;
use std::mem::size_of;

View File

@ -402,7 +402,8 @@ impl PoolProvider for LocalPool {
fn modify(&mut self, addr: &StoreAddr) -> Result<&mut [u8], StoreError> {
let curr_size = self.addr_check(addr)?;
let raw_pos = self.raw_pos(addr).unwrap();
let block = &mut self.pool.get_mut(addr.pool_idx as usize).unwrap()[raw_pos..curr_size];
let block =
&mut self.pool.get_mut(addr.pool_idx as usize).unwrap()[raw_pos..raw_pos + curr_size];
Ok(block)
}
@ -779,4 +780,25 @@ mod tests {
drop(rw_guard);
assert!(!local_pool.has_element_at(&addr).expect("Invalid address"));
}
#[test]
fn modify_pool_index_above_0() {
let mut local_pool = basic_small_pool();
let test_buf_0: [u8; 4] = [1; 4];
let test_buf_1: [u8; 4] = [2; 4];
let test_buf_2: [u8; 4] = [3; 4];
let test_buf_3: [u8; 4] = [4; 4];
let addr0 = local_pool.add(&test_buf_0).expect("Adding data failed");
let addr1 = local_pool.add(&test_buf_1).expect("Adding data failed");
let addr2 = local_pool.add(&test_buf_2).expect("Adding data failed");
let addr3 = local_pool.add(&test_buf_3).expect("Adding data failed");
let tm0_raw = local_pool.modify(&addr0).expect("Modifying data failed");
assert_eq!(tm0_raw, test_buf_0);
let tm1_raw = local_pool.modify(&addr1).expect("Modifying data failed");
assert_eq!(tm1_raw, test_buf_1);
let tm2_raw = local_pool.modify(&addr2).expect("Modifying data failed");
assert_eq!(tm2_raw, test_buf_2);
let tm3_raw = local_pool.modify(&addr3).expect("Modifying data failed");
assert_eq!(tm3_raw, test_buf_3);
}
}

View File

@ -1446,11 +1446,10 @@ mod tests {
VerificationReporterWithSender, VerificationToken,
};
use crate::pus::{EcssSender, EcssTmtcErrorWithSend};
use crate::seq_count::SeqCountProviderSimple;
use crate::SenderId;
use alloc::boxed::Box;
use alloc::format;
use spacepackets::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, EcssEnumeration, PusPacket};
use spacepackets::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, PusPacket};
use spacepackets::tc::{PusTc, PusTcSecondaryHeader};
use spacepackets::tm::PusTm;
use spacepackets::util::UnsignedEnum;
@ -1556,15 +1555,7 @@ mod tests {
}
fn base_reporter() -> VerificationReporter {
let cfg = VerificationReporterCfg::new(
TEST_APID,
Box::new(SeqCountProviderSimple::default()),
Box::new(SeqCountProviderSimple::default()),
1,
2,
8,
)
.unwrap();
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
VerificationReporter::new(&cfg)
}
@ -2306,15 +2297,7 @@ mod tests {
let (verif_tx, verif_rx) = mpsc::channel();
let sender =
MpscVerifSender::new(0, "Verification Sender", shared_tm_pool.clone(), verif_tx);
let cfg = VerificationReporterCfg::new(
TEST_APID,
Box::new(SeqCountProviderSimple::default()),
Box::new(SeqCountProviderSimple::default()),
1,
2,
8,
)
.unwrap();
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
let mut reporter = VerificationReporterWithSender::new(&cfg, Box::new(sender));
let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();

View File

@ -237,7 +237,11 @@ fn main() {
.set_seq_count(seq_count_provider.get_and_increment());
let entry = msg_counter_map.entry(tm.service()).or_insert(0);
tm.sec_header.msg_counter = *entry;
if *entry == u16::MAX {
*entry = 0;
} else {
*entry += 1;
}
tm.calc_crc_on_serialization = true;
tm.write_to_bytes(tm_raw)
.expect("Writing PUS TM back failed");