added some test stubs
Some checks are pending
Rust/sat-rs/pipeline/head Build started...

This commit is contained in:
Robin Müller 2024-05-08 21:02:16 +02:00
parent fe4126f7e2
commit b86c2eb1d1
Signed by: muellerr
GPG Key ID: A649FB78196E3849
4 changed files with 27 additions and 5 deletions

View File

@ -340,3 +340,8 @@ impl<ComInterface: SpiInterface, TmSender: EcssTmSender> ModeRequestHandler
Ok(()) Ok(())
} }
} }
#[cfg(test)]
mod tests {
// TODO: Add some basic tests for the modes of the device.
}

View File

@ -226,4 +226,5 @@ pub mod tasks {
pub const FREQ_MS_UDP_TMTC: u64 = 200; pub const FREQ_MS_UDP_TMTC: u64 = 200;
pub const FREQ_MS_AOCS: u64 = 500; pub const FREQ_MS_AOCS: u64 = 500;
pub const FREQ_MS_PUS_STACK: u64 = 200; pub const FREQ_MS_PUS_STACK: u64 = 200;
pub const SIM_CLIENT_IDLE_DELAY_MS: u64 = 5;
} }

View File

@ -5,6 +5,7 @@ use std::{
time::Duration, time::Duration,
}; };
use satrs::pus::HandlingStatus;
use satrs_minisim::{ use satrs_minisim::{
udp::SIM_CTRL_PORT, SerializableSimMsgPayload, SimComponent, SimMessageProvider, SimReply, udp::SIM_CTRL_PORT, SerializableSimMsgPayload, SimComponent, SimMessageProvider, SimReply,
SimRequest, SimRequest,
@ -94,7 +95,7 @@ impl SimClientUdp {
} }
} }
pub fn operation(&mut self) { pub fn operation(&mut self) -> HandlingStatus {
let mut no_sim_requests_handled = true; let mut no_sim_requests_handled = true;
let mut no_data_from_udp_server_received = true; let mut no_data_from_udp_server_received = true;
loop { loop {
@ -157,8 +158,9 @@ impl SimClientUdp {
} }
} }
if no_sim_requests_handled && no_data_from_udp_server_received { if no_sim_requests_handled && no_data_from_udp_server_received {
std::thread::sleep(Duration::from_millis(5)); return HandlingStatus::Empty;
} }
HandlingStatus::HandledOne
} }
pub fn add_reply_recipient( pub fn add_reply_recipient(
@ -169,3 +171,10 @@ impl SimClientUdp {
self.reply_map.0.insert(component, reply_sender); self.reply_map.0.insert(component, reply_sender);
} }
} }
#[cfg(test)]
pub mod tests {
// TODO: Write some basic tests which verify that the ping/pong handling/check for the
// constructor works as expected.
fn test_basic() {}
}

View File

@ -16,10 +16,13 @@ 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;
use satrs::hal::std::udp_server::UdpTcServer; use satrs::hal::std::udp_server::UdpTcServer;
use satrs::pus::HandlingStatus;
use satrs::request::GenericMessage; use satrs::request::GenericMessage;
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::{FREQ_MS_AOCS, FREQ_MS_PUS_STACK, FREQ_MS_UDP_TMTC}; use satrs_example::config::tasks::{
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 crate::acs::mgm::{ use crate::acs::mgm::{
@ -269,7 +272,9 @@ fn static_tmtc_pool_main() {
thread::Builder::new() thread::Builder::new()
.name("sat-rs sim adapter".to_string()) .name("sat-rs sim adapter".to_string())
.spawn(move || loop { .spawn(move || loop {
sim_client.operation(); if sim_client.operation() == HandlingStatus::Empty {
std::thread::sleep(Duration::from_millis(SIM_CLIENT_IDLE_DELAY_MS));
}
}) })
.unwrap(), .unwrap(),
); );
@ -506,7 +511,9 @@ fn dyn_tmtc_pool_main() {
thread::Builder::new() thread::Builder::new()
.name("sat-rs sim adapter".to_string()) .name("sat-rs sim adapter".to_string())
.spawn(move || loop { .spawn(move || loop {
sim_client.operation(); if sim_client.operation() == HandlingStatus::Empty {
std::thread::sleep(Duration::from_millis(SIM_CLIENT_IDLE_DELAY_MS));
}
}) })
.unwrap(), .unwrap(),
); );