Larger update #49
@ -18,7 +18,7 @@ paste = "1"
|
|||||||
embed-doc-image = "0.1"
|
embed-doc-image = "0.1"
|
||||||
|
|
||||||
[dependencies.num_enum]
|
[dependencies.num_enum]
|
||||||
version = "0.5"
|
version = "0.6"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.dyn-clone]
|
[dependencies.dyn-clone]
|
||||||
|
@ -630,7 +630,6 @@ impl<Severity: HasSeverity> PartialEq<EventU16TypedSev<Severity>> for EventU16 {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::EventU32TypedSev;
|
use super::EventU32TypedSev;
|
||||||
use super::*;
|
use super::*;
|
||||||
use spacepackets::ecss::EcssEnumeration;
|
|
||||||
use spacepackets::ByteConversionError;
|
use spacepackets::ByteConversionError;
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
|
||||||
|
@ -402,7 +402,8 @@ impl PoolProvider for LocalPool {
|
|||||||
fn modify(&mut self, addr: &StoreAddr) -> Result<&mut [u8], StoreError> {
|
fn modify(&mut self, addr: &StoreAddr) -> Result<&mut [u8], StoreError> {
|
||||||
let curr_size = self.addr_check(addr)?;
|
let curr_size = self.addr_check(addr)?;
|
||||||
let raw_pos = self.raw_pos(addr).unwrap();
|
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)
|
Ok(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,4 +780,25 @@ mod tests {
|
|||||||
drop(rw_guard);
|
drop(rw_guard);
|
||||||
assert!(!local_pool.has_element_at(&addr).expect("Invalid address"));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1446,11 +1446,10 @@ mod tests {
|
|||||||
VerificationReporterWithSender, VerificationToken,
|
VerificationReporterWithSender, VerificationToken,
|
||||||
};
|
};
|
||||||
use crate::pus::{EcssSender, EcssTmtcErrorWithSend};
|
use crate::pus::{EcssSender, EcssTmtcErrorWithSend};
|
||||||
use crate::seq_count::SeqCountProviderSimple;
|
|
||||||
use crate::SenderId;
|
use crate::SenderId;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use alloc::format;
|
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::tc::{PusTc, PusTcSecondaryHeader};
|
||||||
use spacepackets::tm::PusTm;
|
use spacepackets::tm::PusTm;
|
||||||
use spacepackets::util::UnsignedEnum;
|
use spacepackets::util::UnsignedEnum;
|
||||||
@ -1556,15 +1555,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn base_reporter() -> VerificationReporter {
|
fn base_reporter() -> VerificationReporter {
|
||||||
let cfg = VerificationReporterCfg::new(
|
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
|
||||||
TEST_APID,
|
|
||||||
Box::new(SeqCountProviderSimple::default()),
|
|
||||||
Box::new(SeqCountProviderSimple::default()),
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
8,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
VerificationReporter::new(&cfg)
|
VerificationReporter::new(&cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2306,15 +2297,7 @@ mod tests {
|
|||||||
let (verif_tx, verif_rx) = mpsc::channel();
|
let (verif_tx, verif_rx) = mpsc::channel();
|
||||||
let sender =
|
let sender =
|
||||||
MpscVerifSender::new(0, "Verification Sender", shared_tm_pool.clone(), verif_tx);
|
MpscVerifSender::new(0, "Verification Sender", shared_tm_pool.clone(), verif_tx);
|
||||||
let cfg = VerificationReporterCfg::new(
|
let cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap();
|
||||||
TEST_APID,
|
|
||||||
Box::new(SeqCountProviderSimple::default()),
|
|
||||||
Box::new(SeqCountProviderSimple::default()),
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
8,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
let mut reporter = VerificationReporterWithSender::new(&cfg, Box::new(sender));
|
let mut reporter = VerificationReporterWithSender::new(&cfg, Box::new(sender));
|
||||||
|
|
||||||
let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
|
@ -237,7 +237,11 @@ fn main() {
|
|||||||
.set_seq_count(seq_count_provider.get_and_increment());
|
.set_seq_count(seq_count_provider.get_and_increment());
|
||||||
let entry = msg_counter_map.entry(tm.service()).or_insert(0);
|
let entry = msg_counter_map.entry(tm.service()).or_insert(0);
|
||||||
tm.sec_header.msg_counter = *entry;
|
tm.sec_header.msg_counter = *entry;
|
||||||
*entry += 1;
|
if *entry == u16::MAX {
|
||||||
|
*entry = 0;
|
||||||
|
} else {
|
||||||
|
*entry += 1;
|
||||||
|
}
|
||||||
tm.calc_crc_on_serialization = true;
|
tm.calc_crc_on_serialization = true;
|
||||||
tm.write_to_bytes(tm_raw)
|
tm.write_to_bytes(tm_raw)
|
||||||
.expect("Writing PUS TM back failed");
|
.expect("Writing PUS TM back failed");
|
||||||
|
Loading…
Reference in New Issue
Block a user