added first concrete TM being generated
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
This commit is contained in:
parent
5f22a067a5
commit
4785446d99
@ -198,15 +198,11 @@ pub mod std_mod {
|
|||||||
let active_req = active_req.unwrap().clone();
|
let active_req = active_req.unwrap().clone();
|
||||||
let remove_entry = match action_reply_with_ids.message.variant {
|
let remove_entry = match action_reply_with_ids.message.variant {
|
||||||
ActionReplyPus::CompletionFailed { error_code, params } => {
|
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
|
self.verification_reporter
|
||||||
.completion_failure(
|
.completion_failure(
|
||||||
active_req.common.token,
|
active_req.common.token,
|
||||||
FailParams::new(
|
FailParams::new(time_stamp, &error_code, &self.tm_buf[..fail_data_len]),
|
||||||
time_stamp,
|
|
||||||
&error_code,
|
|
||||||
&self.fail_data_buf[..fail_data_len],
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.map_err(|e| e.0)?;
|
.map_err(|e| e.0)?;
|
||||||
true
|
true
|
||||||
@ -216,7 +212,7 @@ pub mod std_mod {
|
|||||||
step,
|
step,
|
||||||
params,
|
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
|
self.verification_reporter
|
||||||
.step_failure(
|
.step_failure(
|
||||||
active_req.common.token,
|
active_req.common.token,
|
||||||
@ -224,7 +220,7 @@ pub mod std_mod {
|
|||||||
time_stamp,
|
time_stamp,
|
||||||
&EcssEnumU16::new(step),
|
&EcssEnumU16::new(step),
|
||||||
&error_code,
|
&error_code,
|
||||||
&self.fail_data_buf[..fail_data_len],
|
&self.tm_buf[..fail_data_len],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.map_err(|e| e.0)?;
|
.map_err(|e| e.0)?;
|
||||||
@ -325,7 +321,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{ActionReplyVariant, ActionRequestVariant},
|
action::ActionRequestVariant,
|
||||||
params::{self, ParamsRaw, WritableToBeBytes},
|
params::{self, ParamsRaw, WritableToBeBytes},
|
||||||
pus::{
|
pus::{
|
||||||
tests::{
|
tests::{
|
||||||
|
@ -544,7 +544,7 @@ pub mod alloc_mod {
|
|||||||
> {
|
> {
|
||||||
pub active_request_map: ActiveRequestMap,
|
pub active_request_map: ActiveRequestMap,
|
||||||
pub verification_reporter: VerificationReporter,
|
pub verification_reporter: VerificationReporter,
|
||||||
pub fail_data_buf: alloc::vec::Vec<u8>,
|
pub tm_buf: alloc::vec::Vec<u8>,
|
||||||
pub current_time: UnixTimestamp,
|
pub current_time: UnixTimestamp,
|
||||||
pub user_hook: UserHook,
|
pub user_hook: UserHook,
|
||||||
pub tm_sender: TmSender,
|
pub tm_sender: TmSender,
|
||||||
@ -599,7 +599,7 @@ pub mod alloc_mod {
|
|||||||
Self {
|
Self {
|
||||||
active_request_map,
|
active_request_map,
|
||||||
verification_reporter,
|
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,
|
current_time: init_time,
|
||||||
user_hook,
|
user_hook,
|
||||||
tm_sender,
|
tm_sender,
|
||||||
|
@ -31,15 +31,20 @@ pub mod std_mod {
|
|||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
|
|
||||||
use satrs_shared::res_code::ResultU16;
|
use satrs_shared::res_code::ResultU16;
|
||||||
|
use spacepackets::{
|
||||||
|
ecss::tm::{PusTmCreator, PusTmSecondaryHeader},
|
||||||
|
SpHeader,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
mode::{ModeReply, ModeRequest},
|
mode::{ModeReply, ModeRequest},
|
||||||
pus::{
|
pus::{
|
||||||
|
mode::Subservice,
|
||||||
verification::{
|
verification::{
|
||||||
self, FailParams, TcStateStarted, VerificationReportingProvider, VerificationToken,
|
self, FailParams, TcStateStarted, VerificationReportingProvider, VerificationToken,
|
||||||
},
|
},
|
||||||
ActiveRequest, ActiveRequestMapProvider, EcssTmSenderCore, EcssTmtcError,
|
ActiveRequest, ActiveRequestMapProvider, EcssTmSenderCore, EcssTmtcError,
|
||||||
GenericRoutingError, PusServiceReplyHandler, PusTargetedRequestHandler,
|
GenericRoutingError, PusServiceReplyHandler, PusTargetedRequestHandler, PusTmWrapper,
|
||||||
ReplyHandlerHook,
|
ReplyHandlerHook,
|
||||||
},
|
},
|
||||||
TargetId,
|
TargetId,
|
||||||
@ -50,7 +55,7 @@ pub mod std_mod {
|
|||||||
fn can_not_reach_mode_result_code(&self) -> ResultU16;
|
fn can_not_reach_mode_result_code(&self) -> ResultU16;
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::GenericModeReplyPus;
|
use super::{GenericModeReplyPus, MODE_SERVICE_ID};
|
||||||
|
|
||||||
pub type PusModeServiceRequestHandler<
|
pub type PusModeServiceRequestHandler<
|
||||||
TcReceiver,
|
TcReceiver,
|
||||||
@ -130,24 +135,37 @@ pub mod std_mod {
|
|||||||
let active_req = active_req.unwrap().clone();
|
let active_req = active_req.unwrap().clone();
|
||||||
let remove_entry = match mode_reply_with_id.message {
|
let remove_entry = match mode_reply_with_id.message {
|
||||||
ModeReply::ModeReply(reply) => {
|
ModeReply::ModeReply(reply) => {
|
||||||
// TODO: Send dedicated TM to send mode information.
|
let req_id = verification::RequestId::from(mode_reply_with_id.request_id);
|
||||||
// TODO: Generate TM. Service ID from hook, subservice ID is fixed for
|
let mut sp_header = SpHeader::tm_unseg(
|
||||||
// framework purposes, APID can be retrieved from Request ID.
|
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
|
self.verification_reporter
|
||||||
.completion_success(active_req.token, time_stamp)
|
.completion_success(active_req.token, time_stamp)
|
||||||
.map_err(|e| e.0)?;
|
.map_err(|e| e.0)?;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
ModeReply::CantReachMode(reached_mode) => {
|
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
|
self.verification_reporter
|
||||||
.completion_failure(
|
.completion_failure(
|
||||||
active_req.token,
|
active_req.token,
|
||||||
FailParams::new(
|
FailParams::new(
|
||||||
time_stamp,
|
time_stamp,
|
||||||
&self.user_hook.can_not_reach_mode_result_code(),
|
&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)?;
|
.map_err(|e| e.0)?;
|
||||||
|
@ -139,12 +139,29 @@ impl PartialEq for RequestId {
|
|||||||
impl RequestId {
|
impl RequestId {
|
||||||
pub const SIZE_AS_BYTES: usize = size_of::<u32>();
|
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 {
|
pub fn raw(&self) -> u32 {
|
||||||
((self.version_number as u32) << 29)
|
((self.version_number as u32) << 29)
|
||||||
| ((self.packet_id.raw() as u32) << 16)
|
| ((self.packet_id.raw() as u32) << 16)
|
||||||
| self.psc.raw() as u32
|
| 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]) {
|
pub fn to_bytes(&self, buf: &mut [u8]) {
|
||||||
let raw = self.raw();
|
let raw = self.raw();
|
||||||
buf.copy_from_slice(raw.to_be_bytes().as_slice());
|
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 {
|
impl From<u32> for RequestId {
|
||||||
fn from(value: u32) -> Self {
|
fn from(value: u32) -> Self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user