improve example structure #151

Merged
muellerr merged 1 commits from improve-example-structure into main 2024-04-10 13:19:42 +02:00
8 changed files with 14 additions and 56 deletions
Showing only changes of commit 0bbada90ef - Show all commits

View File

@ -0,0 +1,3 @@
//! This module contains all component related to the direct interface of the example.
pub mod tcp;
pub mod udp;

View File

@ -11,7 +11,7 @@ use satrs::{
tmtc::{CcsdsDistributor, CcsdsError, ReceivesCcsdsTc, TmPacketSourceCore}, tmtc::{CcsdsDistributor, CcsdsError, ReceivesCcsdsTc, TmPacketSourceCore},
}; };
use crate::ccsds::CcsdsReceiver; use crate::tmtc::ccsds::CcsdsReceiver;
#[derive(Default)] #[derive(Default)]
pub struct ConnectionFinishedHandler {} pub struct ConnectionFinishedHandler {}

View File

@ -1,18 +1,16 @@
mod acs; mod acs;
mod ccsds;
mod events; mod events;
mod hk; mod hk;
mod interface;
mod logger; mod logger;
mod pus; mod pus;
mod requests; mod requests;
mod tcp;
mod tm_funnel;
mod tmtc; mod tmtc;
mod udp;
use crate::events::EventHandler; use crate::events::EventHandler;
use crate::interface::udp::DynamicUdpTmHandler;
use crate::pus::stack::PusStack; use crate::pus::stack::PusStack;
use crate::tm_funnel::{TmFunnelDynamic, TmFunnelStatic}; use crate::tmtc::tm_funnel::{TmFunnelDynamic, TmFunnelStatic};
use log::info; use log::info;
use pus::test::create_test_service_dynamic; use pus::test::create_test_service_dynamic;
use satrs::hal::std::tcp_server::ServerConfig; use satrs::hal::std::tcp_server::ServerConfig;
@ -25,10 +23,10 @@ use satrs_example::config::tasks::{
}; };
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 tmtc::PusTcSourceProviderDynamic; use tmtc::PusTcSourceProviderDynamic;
use udp::DynamicUdpTmHandler;
use crate::acs::mgm::{MgmHandlerLis3Mdl, MpscModeLeafInterface, SpiDummyInterface}; use crate::acs::mgm::{MgmHandlerLis3Mdl, MpscModeLeafInterface, SpiDummyInterface};
use crate::ccsds::CcsdsReceiver; use crate::interface::tcp::{SyncTcpTmSource, TcpTask};
use crate::interface::udp::{StaticUdpTmHandler, UdpTmtcServer};
use crate::logger::setup_logger; use crate::logger::setup_logger;
use crate::pus::action::{create_action_service_dynamic, create_action_service_static}; use crate::pus::action::{create_action_service_dynamic, create_action_service_static};
use crate::pus::event::{create_event_service_dynamic, create_event_service_static}; use crate::pus::event::{create_event_service_dynamic, create_event_service_static};
@ -38,11 +36,10 @@ 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::{PusReceiver, PusTcMpscRouter}; use crate::pus::{PusReceiver, PusTcMpscRouter};
use crate::requests::{CompositeRequest, GenericRequestRouter}; use crate::requests::{CompositeRequest, GenericRequestRouter};
use crate::tcp::{SyncTcpTmSource, TcpTask}; use crate::tmtc::ccsds::CcsdsReceiver;
use crate::tmtc::{ use crate::tmtc::{
PusTcSourceProviderSharedPool, SharedTcPool, TcSourceTaskDynamic, TcSourceTaskStatic, PusTcSourceProviderSharedPool, SharedTcPool, TcSourceTaskDynamic, TcSourceTaskStatic,
}; };
use crate::udp::{StaticUdpTmHandler, UdpTmtcServer};
use satrs::mode::ModeRequest; use satrs::mode::ModeRequest;
use satrs::pus::event_man::EventRequestWithToken; use satrs::pus::event_man::EventRequestWithToken;
use satrs::pus::TmInSharedPoolSender; use satrs::pus::TmInSharedPoolSender;

View File

@ -1,45 +0,0 @@
/// Generic error type for sending something via a message queue.
#[derive(Debug, Copy, Clone)]
pub enum GenericSendError {
RxDisconnected,
QueueFull(Option<u32>),
}
impl Display for GenericSendError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
GenericSendError::RxDisconnected => {
write!(f, "rx side has disconnected")
}
GenericSendError::QueueFull(max_cap) => {
write!(f, "queue with max capacity of {max_cap:?} is full")
}
}
}
}
#[cfg(feature = "std")]
impl Error for GenericSendError {}
/// Generic error type for sending something via a message queue.
#[derive(Debug, Copy, Clone)]
pub enum GenericRecvError {
Empty,
TxDisconnected,
}
impl Display for GenericRecvError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
Self::TxDisconnected => {
write!(f, "tx side has disconnected")
}
Self::Empty => {
write!(f, "nothing to receive")
}
}
}
}
#[cfg(feature = "std")]
impl Error for GenericRecvError {}

View File

@ -12,6 +12,9 @@ use satrs::spacepackets::ecss::tc::PusTcReader;
use satrs::spacepackets::ecss::PusPacket; use satrs::spacepackets::ecss::PusPacket;
use satrs::tmtc::ReceivesCcsdsTc; use satrs::tmtc::ReceivesCcsdsTc;
pub mod ccsds;
pub mod tm_funnel;
#[derive(Debug, Clone, PartialEq, Eq, Error)] #[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum MpscStoreAndSendError { pub enum MpscStoreAndSendError {
#[error("Store error: {0}")] #[error("Store error: {0}")]

View File

@ -16,7 +16,7 @@ use satrs::{
tmtc::tm_helper::SharedTmPool, tmtc::tm_helper::SharedTmPool,
}; };
use crate::tcp::SyncTcpTmSource; use crate::interface::tcp::SyncTcpTmSource;
#[derive(Default)] #[derive(Default)]
pub struct CcsdsSeqCounterMap { pub struct CcsdsSeqCounterMap {