added first concrete TM being generated
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2024-03-14 16:51:19 +01:00
parent 5f22a067a5
commit 4785446d99
Signed by: muellerr
GPG Key ID: A649FB78196E3849
4 changed files with 50 additions and 29 deletions

View File

@ -198,15 +198,11 @@ pub mod std_mod {
let active_req = active_req.unwrap().clone();
let remove_entry = match action_reply_with_ids.message.variant {
ActionReplyPus::CompletionFailed { error_code, params } => {
let fail_data_len = params.write_to_be_bytes(&mut self.fail_data_buf)?;
let fail_data_len = params.write_to_be_bytes(&mut self.tm_buf)?;
self.verification_reporter
.completion_failure(
active_req.common.token,
FailParams::new(
time_stamp,
&error_code,
&self.fail_data_buf[..fail_data_len],
),
FailParams::new(time_stamp, &error_code, &self.tm_buf[..fail_data_len]),
)
.map_err(|e| e.0)?;
true
@ -216,7 +212,7 @@ pub mod std_mod {
step,
params,
} => {
let fail_data_len = params.write_to_be_bytes(&mut self.fail_data_buf)?;
let fail_data_len = params.write_to_be_bytes(&mut self.tm_buf)?;
self.verification_reporter
.step_failure(
active_req.common.token,
@ -224,7 +220,7 @@ pub mod std_mod {
time_stamp,
&EcssEnumU16::new(step),
&error_code,
&self.fail_data_buf[..fail_data_len],
&self.tm_buf[..fail_data_len],
),
)
.map_err(|e| e.0)?;
@ -325,7 +321,7 @@ mod tests {
};
use crate::{
action::{ActionReplyVariant, ActionRequestVariant},
action::ActionRequestVariant,
params::{self, ParamsRaw, WritableToBeBytes},
pus::{
tests::{

View File

@ -544,7 +544,7 @@ pub mod alloc_mod {
> {
pub active_request_map: ActiveRequestMap,
pub verification_reporter: VerificationReporter,
pub fail_data_buf: alloc::vec::Vec<u8>,
pub tm_buf: alloc::vec::Vec<u8>,
pub current_time: UnixTimestamp,
pub user_hook: UserHook,
pub tm_sender: TmSender,
@ -599,7 +599,7 @@ pub mod alloc_mod {
Self {
active_request_map,
verification_reporter,
fail_data_buf: alloc::vec![0; fail_data_buf_size],
tm_buf: alloc::vec![0; fail_data_buf_size],
current_time: init_time,
user_hook,
tm_sender,

View File

@ -31,15 +31,20 @@ pub mod std_mod {
use core::time::Duration;
use satrs_shared::res_code::ResultU16;
use spacepackets::{
ecss::tm::{PusTmCreator, PusTmSecondaryHeader},
SpHeader,
};
use crate::{
mode::{ModeReply, ModeRequest},
pus::{
mode::Subservice,
verification::{
self, FailParams, TcStateStarted, VerificationReportingProvider, VerificationToken,
},
ActiveRequest, ActiveRequestMapProvider, EcssTmSenderCore, EcssTmtcError,
GenericRoutingError, PusServiceReplyHandler, PusTargetedRequestHandler,
GenericRoutingError, PusServiceReplyHandler, PusTargetedRequestHandler, PusTmWrapper,
ReplyHandlerHook,
},
TargetId,
@ -50,7 +55,7 @@ pub mod std_mod {
fn can_not_reach_mode_result_code(&self) -> ResultU16;
}
use super::GenericModeReplyPus;
use super::{GenericModeReplyPus, MODE_SERVICE_ID};
pub type PusModeServiceRequestHandler<
TcReceiver,
@ -130,24 +135,37 @@ pub mod std_mod {
let active_req = active_req.unwrap().clone();
let remove_entry = match mode_reply_with_id.message {
ModeReply::ModeReply(reply) => {
// TODO: Send dedicated TM to send mode information.
// TODO: Generate TM. Service ID from hook, subservice ID is fixed for
// framework purposes, APID can be retrieved from Request ID.
let req_id = verification::RequestId::from(mode_reply_with_id.request_id);
let mut sp_header = SpHeader::tm_unseg(
req_id.packet_id().apid(),
req_id.packet_seq_ctrl().seq_count(),
0,
)
.expect("space packet header creation error");
let sec_header = PusTmSecondaryHeader::new(
MODE_SERVICE_ID,
Subservice::TmModeReply as u8,
0,
0,
Some(time_stamp),
);
let pus_tm =
PusTmCreator::new(&mut sp_header, sec_header, &mut self.tm_buf, true);
self.tm_sender.send_tm(PusTmWrapper::Direct(pus_tm))?;
self.verification_reporter
.completion_success(active_req.token, time_stamp)
.map_err(|e| e.0)?;
true
}
ModeReply::CantReachMode(reached_mode) => {
let fail_data_len = reached_mode.to_be_bytes(&mut self.fail_data_buf)?;
let fail_data_len = reached_mode.to_be_bytes(&mut self.tm_buf)?;
self.verification_reporter
.completion_failure(
active_req.token,
FailParams::new(
time_stamp,
&self.user_hook.can_not_reach_mode_result_code(),
&self.fail_data_buf[0..fail_data_len],
&self.tm_buf[0..fail_data_len],
),
)
.map_err(|e| e.0)?;

View File

@ -139,12 +139,29 @@ impl PartialEq for RequestId {
impl RequestId {
pub const SIZE_AS_BYTES: usize = size_of::<u32>();
/// This allows extracting the request ID from a given PUS telecommand.
pub fn new(tc: &(impl CcsdsPacket + IsPusTelecommand)) -> Self {
RequestId {
version_number: tc.ccsds_version(),
packet_id: tc.packet_id(),
psc: tc.psc(),
}
}
pub fn raw(&self) -> u32 {
((self.version_number as u32) << 29)
| ((self.packet_id.raw() as u32) << 16)
| self.psc.raw() as u32
}
pub fn packet_id(&self) -> PacketId {
self.packet_id
}
pub fn packet_seq_ctrl(&self) -> PacketSequenceCtrl {
self.psc
}
pub fn to_bytes(&self, buf: &mut [u8]) {
let raw = self.raw();
buf.copy_from_slice(raw.to_be_bytes().as_slice());
@ -162,16 +179,6 @@ impl RequestId {
})
}
}
impl RequestId {
/// This allows extracting the request ID from a given PUS telecommand.
pub fn new(tc: &(impl CcsdsPacket + IsPusTelecommand)) -> Self {
RequestId {
version_number: tc.ccsds_version(),
packet_id: tc.packet_id(),
psc: tc.psc(),
}
}
}
impl From<u32> for RequestId {
fn from(value: u32) -> Self {