some more optimizations
This commit is contained in:
@ -145,6 +145,16 @@ impl TcpSppClientStd {
|
||||
}
|
||||
|
||||
pub fn operation(&mut self) -> Result<ClientResult, ClientError> {
|
||||
let result = self.operation_inner();
|
||||
if let Ok(client_result) = &result {
|
||||
if *client_result != ClientResult::Ok {
|
||||
std::thread::sleep(self.read_and_idle_delay);
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn operation_inner(&mut self) -> Result<ClientResult, ClientError> {
|
||||
if let Some(client) = &mut self.stream {
|
||||
// Write TM first before blocking on the read call.
|
||||
self.common.write_to_server(client)?;
|
||||
|
13
src/main.rs
13
src/main.rs
@ -24,10 +24,7 @@ use satrs::{
|
||||
pus::event_man::EventRequestWithToken,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
controller::ControllerPathCollection, interface::tcp_spp_client::ClientResult,
|
||||
tmtc::tm_sink::TmFunnelDynamic,
|
||||
};
|
||||
use crate::{controller::ControllerPathCollection, tmtc::tm_sink::TmFunnelDynamic};
|
||||
use crate::{controller::ExperimentController, pus::test::create_test_service};
|
||||
use crate::{
|
||||
events::EventHandler,
|
||||
@ -284,13 +281,7 @@ fn main() {
|
||||
info!("Running TCP SPP client");
|
||||
loop {
|
||||
match tcp_spp_client.operation() {
|
||||
Ok(result) => {
|
||||
// If the client connection was processed regularly, the read timeout takes
|
||||
// care of the sleep time.
|
||||
if result != ClientResult::Ok {
|
||||
std::thread::sleep(STOP_CHECK_FREQUENCY);
|
||||
}
|
||||
}
|
||||
Ok(_result) => (),
|
||||
Err(e) => {
|
||||
log::error!("TCP SPP client error: {}", e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user