periodic MGM data looks good
This commit is contained in:
parent
49733c8d84
commit
067c731f16
@ -19,7 +19,7 @@ use satrs::mode::{
|
|||||||
};
|
};
|
||||||
use satrs::pus::{EcssTmSender, PusTmVariant};
|
use satrs::pus::{EcssTmSender, PusTmVariant};
|
||||||
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
||||||
use satrs_example::config::components::PUS_MODE_SERVICE;
|
use satrs_example::config::components::{NO_SENDER, PUS_MODE_SERVICE};
|
||||||
|
|
||||||
use crate::hk::PusHkHelper;
|
use crate::hk::PusHkHelper;
|
||||||
use crate::pus::hk::{HkReply, HkReplyVariant};
|
use crate::pus::hk::{HkReply, HkReplyVariant};
|
||||||
@ -421,9 +421,12 @@ impl<
|
|||||||
self.mode_helpers.target = None;
|
self.mode_helpers.target = None;
|
||||||
self.announce_mode(requestor, false);
|
self.announce_mode(requestor, false);
|
||||||
if let Some(requestor) = requestor {
|
if let Some(requestor) = requestor {
|
||||||
|
if requestor.sender_id() == NO_SENDER {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
if requestor.sender_id() != PUS_MODE_SERVICE.id() {
|
if requestor.sender_id() != PUS_MODE_SERVICE.id() {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"can not send back mode reply to sender {}",
|
"can not send back mode reply to sender {:x}",
|
||||||
requestor.sender_id()
|
requestor.sender_id()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +122,7 @@ pub mod mode_err {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod components {
|
pub mod components {
|
||||||
use satrs::request::UniqueApidTargetId;
|
use satrs::{request::UniqueApidTargetId, ComponentId};
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, EnumIter)]
|
#[derive(Copy, Clone, PartialEq, Eq, EnumIter)]
|
||||||
@ -184,6 +184,7 @@ pub mod components {
|
|||||||
UniqueApidTargetId::new(Apid::Tmtc as u16, TmtcId::UdpServer as u32);
|
UniqueApidTargetId::new(Apid::Tmtc as u16, TmtcId::UdpServer as u32);
|
||||||
pub const TCP_SERVER: UniqueApidTargetId =
|
pub const TCP_SERVER: UniqueApidTargetId =
|
||||||
UniqueApidTargetId::new(Apid::Tmtc as u16, TmtcId::TcpServer as u32);
|
UniqueApidTargetId::new(Apid::Tmtc as u16, TmtcId::TcpServer as u32);
|
||||||
|
pub const NO_SENDER: ComponentId = ComponentId::MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod pool {
|
pub mod pool {
|
||||||
|
@ -15,7 +15,10 @@ use satrs::{
|
|||||||
request::{GenericMessage, MessageMetadata, UniqueApidTargetId},
|
request::{GenericMessage, MessageMetadata, UniqueApidTargetId},
|
||||||
spacepackets::ByteConversionError,
|
spacepackets::ByteConversionError,
|
||||||
};
|
};
|
||||||
use satrs_example::{config::components::PUS_MODE_SERVICE, DeviceMode, TimestampHelper};
|
use satrs_example::{
|
||||||
|
config::components::{NO_SENDER, PUS_MODE_SERVICE},
|
||||||
|
DeviceMode, TimestampHelper,
|
||||||
|
};
|
||||||
use satrs_minisim::{
|
use satrs_minisim::{
|
||||||
eps::{
|
eps::{
|
||||||
PcduReply, PcduRequest, PcduSwitch, SwitchMap, SwitchMapBinaryWrapper, SwitchMapWrapper,
|
PcduReply, PcduRequest, PcduSwitch, SwitchMap, SwitchMapBinaryWrapper, SwitchMapWrapper,
|
||||||
@ -60,9 +63,9 @@ impl SerialInterface for SerialInterfaceToSim {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn send(&self, data: &[u8]) -> Result<(), Self::Error> {
|
fn send(&self, data: &[u8]) -> Result<(), Self::Error> {
|
||||||
let request: SimRequest = serde_json::from_slice(data).unwrap();
|
let request: PcduRequest = serde_json::from_slice(data).expect("expected a PCDU request");
|
||||||
self.sim_request_tx
|
self.sim_request_tx
|
||||||
.send(request)
|
.send(SimRequest::new_with_epoch_time(request))
|
||||||
.expect("failed to send request to simulation");
|
.expect("failed to send request to simulation");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -437,6 +440,9 @@ impl<ComInterface: SerialInterface, TmSender: EcssTmSender> ModeRequestHandler
|
|||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
self.announce_mode(requestor, false);
|
self.announce_mode(requestor, false);
|
||||||
if let Some(requestor) = requestor {
|
if let Some(requestor) = requestor {
|
||||||
|
if requestor.sender_id() == NO_SENDER {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
if requestor.sender_id() != PUS_MODE_SERVICE.id() {
|
if requestor.sender_id() != PUS_MODE_SERVICE.id() {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"can not send back mode reply to sender {}",
|
"can not send back mode reply to sender {}",
|
||||||
|
@ -22,13 +22,14 @@ use pus::test::create_test_service_dynamic;
|
|||||||
use satrs::hal::std::tcp_server::ServerConfig;
|
use satrs::hal::std::tcp_server::ServerConfig;
|
||||||
use satrs::hal::std::udp_server::UdpTcServer;
|
use satrs::hal::std::udp_server::UdpTcServer;
|
||||||
use satrs::pus::HandlingStatus;
|
use satrs::pus::HandlingStatus;
|
||||||
use satrs::request::GenericMessage;
|
use satrs::request::{GenericMessage, MessageMetadata};
|
||||||
use satrs::tmtc::{PacketSenderWithSharedPool, SharedPacketPool};
|
use satrs::tmtc::{PacketSenderWithSharedPool, SharedPacketPool};
|
||||||
use satrs_example::config::pool::{create_sched_tc_pool, create_static_pools};
|
use satrs_example::config::pool::{create_sched_tc_pool, create_static_pools};
|
||||||
use satrs_example::config::tasks::{
|
use satrs_example::config::tasks::{
|
||||||
FREQ_MS_AOCS, FREQ_MS_PUS_STACK, FREQ_MS_UDP_TMTC, SIM_CLIENT_IDLE_DELAY_MS,
|
FREQ_MS_AOCS, FREQ_MS_PUS_STACK, FREQ_MS_UDP_TMTC, SIM_CLIENT_IDLE_DELAY_MS,
|
||||||
};
|
};
|
||||||
use satrs_example::config::{OBSW_SERVER_ADDR, PACKET_ID_VALIDATOR, SERVER_PORT};
|
use satrs_example::config::{OBSW_SERVER_ADDR, PACKET_ID_VALIDATOR, SERVER_PORT};
|
||||||
|
use satrs_example::DeviceMode;
|
||||||
|
|
||||||
use crate::acs::mgm::{
|
use crate::acs::mgm::{
|
||||||
MgmHandlerLis3Mdl, MpscModeLeafInterface, SpiDummyInterface, SpiSimInterface,
|
MgmHandlerLis3Mdl, MpscModeLeafInterface, SpiDummyInterface, SpiSimInterface,
|
||||||
@ -46,10 +47,12 @@ use crate::pus::scheduler::{create_scheduler_service_dynamic, create_scheduler_s
|
|||||||
use crate::pus::test::create_test_service_static;
|
use crate::pus::test::create_test_service_static;
|
||||||
use crate::pus::{PusTcDistributor, PusTcMpscRouter};
|
use crate::pus::{PusTcDistributor, PusTcMpscRouter};
|
||||||
use crate::requests::{CompositeRequest, GenericRequestRouter};
|
use crate::requests::{CompositeRequest, GenericRequestRouter};
|
||||||
use satrs::mode::ModeRequest;
|
use satrs::mode::{Mode, ModeAndSubmode, ModeRequest};
|
||||||
use satrs::pus::event_man::EventRequestWithToken;
|
use satrs::pus::event_man::EventRequestWithToken;
|
||||||
use satrs::spacepackets::{time::cds::CdsTime, time::TimeWriter};
|
use satrs::spacepackets::{time::cds::CdsTime, time::TimeWriter};
|
||||||
use satrs_example::config::components::{MGM_HANDLER_0, PCDU_HANDLER, TCP_SERVER, UDP_SERVER};
|
use satrs_example::config::components::{
|
||||||
|
MGM_HANDLER_0, NO_SENDER, PCDU_HANDLER, TCP_SERVER, UDP_SERVER,
|
||||||
|
};
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
use std::sync::{mpsc, Mutex};
|
use std::sync::{mpsc, Mutex};
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
@ -98,7 +101,7 @@ fn static_tmtc_pool_main() {
|
|||||||
.insert(PCDU_HANDLER.id(), pcdu_handler_composite_tx);
|
.insert(PCDU_HANDLER.id(), pcdu_handler_composite_tx);
|
||||||
request_map
|
request_map
|
||||||
.mode_router_map
|
.mode_router_map
|
||||||
.insert(PCDU_HANDLER.id(), pcdu_handler_mode_tx);
|
.insert(PCDU_HANDLER.id(), pcdu_handler_mode_tx.clone());
|
||||||
|
|
||||||
// This helper structure is used by all telecommand providers which need to send telecommands
|
// This helper structure is used by all telecommand providers which need to send telecommands
|
||||||
// to the TC source.
|
// to the TC source.
|
||||||
@ -272,6 +275,7 @@ fn static_tmtc_pool_main() {
|
|||||||
} else {
|
} else {
|
||||||
SerialSimInterfaceWrapper::Dummy(SerialInterfaceDummy::default())
|
SerialSimInterfaceWrapper::Dummy(SerialInterfaceDummy::default())
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut pcdu_handler = PcduHandler::new(
|
let mut pcdu_handler = PcduHandler::new(
|
||||||
PCDU_HANDLER,
|
PCDU_HANDLER,
|
||||||
"PCDU",
|
"PCDU",
|
||||||
@ -283,6 +287,13 @@ fn static_tmtc_pool_main() {
|
|||||||
pcdu_serial_interface,
|
pcdu_serial_interface,
|
||||||
shared_switch_set,
|
shared_switch_set,
|
||||||
);
|
);
|
||||||
|
// The PCDU is a critical component which should be in normal mode immediately.
|
||||||
|
pcdu_handler_mode_tx
|
||||||
|
.send(GenericMessage::new(
|
||||||
|
MessageMetadata::new(0, NO_SENDER),
|
||||||
|
ModeRequest::SetMode(ModeAndSubmode::new(DeviceMode::Normal as Mode, 0)),
|
||||||
|
))
|
||||||
|
.expect("sending initial mode request failed");
|
||||||
|
|
||||||
info!("Starting TMTC and UDP task");
|
info!("Starting TMTC and UDP task");
|
||||||
let jh_udp_tmtc = thread::Builder::new()
|
let jh_udp_tmtc = thread::Builder::new()
|
||||||
@ -420,7 +431,7 @@ fn dyn_tmtc_pool_main() {
|
|||||||
.insert(PCDU_HANDLER.id(), pcdu_handler_composite_tx);
|
.insert(PCDU_HANDLER.id(), pcdu_handler_composite_tx);
|
||||||
request_map
|
request_map
|
||||||
.mode_router_map
|
.mode_router_map
|
||||||
.insert(PCDU_HANDLER.id(), pcdu_handler_mode_tx);
|
.insert(PCDU_HANDLER.id(), pcdu_handler_mode_tx.clone());
|
||||||
|
|
||||||
// Create event handling components
|
// Create event handling components
|
||||||
// These sender handles are used to send event requests, for example to enable or disable
|
// These sender handles are used to send event requests, for example to enable or disable
|
||||||
@ -583,6 +594,13 @@ fn dyn_tmtc_pool_main() {
|
|||||||
pcdu_serial_interface,
|
pcdu_serial_interface,
|
||||||
shared_switch_set,
|
shared_switch_set,
|
||||||
);
|
);
|
||||||
|
// The PCDU is a critical component which should be in normal mode immediately.
|
||||||
|
pcdu_handler_mode_tx
|
||||||
|
.send(GenericMessage::new(
|
||||||
|
MessageMetadata::new(0, NO_SENDER),
|
||||||
|
ModeRequest::SetMode(ModeAndSubmode::new(DeviceMode::Normal as Mode, 0)),
|
||||||
|
))
|
||||||
|
.expect("sending initial mode request failed");
|
||||||
|
|
||||||
info!("Starting TMTC and UDP task");
|
info!("Starting TMTC and UDP task");
|
||||||
let jh_udp_tmtc = thread::Builder::new()
|
let jh_udp_tmtc = thread::Builder::new()
|
||||||
|
@ -33,6 +33,7 @@ pub struct HkReply {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum HkReplyVariant {
|
pub enum HkReplyVariant {
|
||||||
Ack,
|
Ack,
|
||||||
Failed(ResultU16),
|
Failed(ResultU16),
|
||||||
|
@ -16,10 +16,12 @@ use crate::{
|
|||||||
eps::PcduModel,
|
eps::PcduModel,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SIM_CTRL_REQ_WIRETAPPING: bool = true;
|
const WARNING_FOR_STALE_DATA: bool = false;
|
||||||
const MGM_REQ_WIRETAPPING: bool = true;
|
|
||||||
const PCDU_REQ_WIRETAPPING: bool = true;
|
const SIM_CTRL_REQ_WIRETAPPING: bool = false;
|
||||||
const MGT_REQ_WIRETAPPING: bool = true;
|
const MGM_REQ_WIRETAPPING: bool = false;
|
||||||
|
const PCDU_REQ_WIRETAPPING: bool = false;
|
||||||
|
const MGT_REQ_WIRETAPPING: bool = false;
|
||||||
|
|
||||||
// The simulation controller processes requests and drives the simulation.
|
// The simulation controller processes requests and drives the simulation.
|
||||||
pub struct SimController {
|
pub struct SimController {
|
||||||
@ -72,7 +74,7 @@ impl SimController {
|
|||||||
loop {
|
loop {
|
||||||
match self.request_receiver.try_recv() {
|
match self.request_receiver.try_recv() {
|
||||||
Ok(request) => {
|
Ok(request) => {
|
||||||
if request.timestamp < old_timestamp {
|
if request.timestamp < old_timestamp && WARNING_FOR_STALE_DATA {
|
||||||
log::warn!("stale data with timestamp {:?} received", request.timestamp);
|
log::warn!("stale data with timestamp {:?} received", request.timestamp);
|
||||||
}
|
}
|
||||||
if let Err(e) = match request.component() {
|
if let Err(e) = match request.component() {
|
||||||
|
Loading…
Reference in New Issue
Block a user