some bugfixes
This commit is contained in:
parent
f4d0a86d7d
commit
9282526392
@ -55,32 +55,30 @@ pub enum GroupId {
|
||||
pub const TEST_EVENT: EventU32TypedSev<SeverityInfo> =
|
||||
EventU32TypedSev::<SeverityInfo>::new(GroupId::Tmtc as u16, 0);
|
||||
|
||||
pub fn set_up_home_path() {
|
||||
pub fn set_up_home_path() -> PathBuf {
|
||||
let mut home_path = PathBuf::new();
|
||||
let home_path_default = homedir::get_my_home()
|
||||
.expect("Getting home dir from OS failed.")
|
||||
.expect("No home dir found.");
|
||||
|
||||
home_path.push(if Path::new(HOME_FOLDER_EXPERIMENT).exists() {
|
||||
HOME_FOLDER_EXPERIMENT
|
||||
if cfg!(feature = "host") {
|
||||
home_path = std::env::current_dir()
|
||||
.expect("getting current dir failed")
|
||||
.to_path_buf();
|
||||
} else {
|
||||
home_path_default
|
||||
.to_str()
|
||||
.expect("Error converting to string.")
|
||||
});
|
||||
let home_path_default = homedir::get_my_home()
|
||||
.expect("Getting home dir from OS failed.")
|
||||
.expect("No home dir found.");
|
||||
if Path::new(HOME_FOLDER_EXPERIMENT).exists() {
|
||||
home_path.push(HOME_FOLDER_EXPERIMENT);
|
||||
} else {
|
||||
home_path = home_path_default;
|
||||
}
|
||||
}
|
||||
HOME_PATH
|
||||
.set(home_path)
|
||||
.expect("attempting to set once cell twice")
|
||||
.set(home_path.clone())
|
||||
.expect("attempting to set once cell twice");
|
||||
home_path
|
||||
}
|
||||
|
||||
pub fn set_up_low_prio_ground_dir(base_path: PathBuf) {
|
||||
/*
|
||||
#[cfg(feature = "host")]
|
||||
let mut to_ground_lp_dir = std::env::current_dir().expect("getting current dir failed");
|
||||
#[cfg(not(feature = "host"))]
|
||||
let mut to_ground_lp_dir = home_path;
|
||||
*/
|
||||
let mut to_ground_lp_dir = base_path.to_path_buf();
|
||||
pub fn set_up_low_prio_ground_dir(home_path: PathBuf) {
|
||||
let mut to_ground_lp_dir = home_path.to_path_buf();
|
||||
to_ground_lp_dir.push(TO_GROUND_LP_FOLDER_NAME);
|
||||
if !Path::new(&to_ground_lp_dir).exists() {
|
||||
log::info!(
|
||||
@ -99,14 +97,8 @@ pub fn set_up_low_prio_ground_dir(base_path: PathBuf) {
|
||||
.expect("attemting to set once cell twice");
|
||||
}
|
||||
|
||||
pub fn set_up_ground_dir(base_path: PathBuf) {
|
||||
/*
|
||||
#[cfg(feature = "host")]
|
||||
let mut to_ground_dir = std::env::current_dir().expect("getting current dir failed");
|
||||
#[cfg(not(feature = "host"))]
|
||||
let mut to_ground_dir = HOME_PATH.clone();
|
||||
*/
|
||||
let mut to_ground_dir = base_path.to_path_buf();
|
||||
pub fn set_up_ground_dir(home_path: PathBuf) {
|
||||
let mut to_ground_dir = home_path.to_path_buf();
|
||||
to_ground_dir.push(TO_GROUND_FOLDER_NAME);
|
||||
if !Path::new(&to_ground_dir).exists() {
|
||||
log::info!("creating to ground directory at {:?}", to_ground_dir);
|
||||
|
@ -54,11 +54,10 @@ pub struct ControllerPathCollection {
|
||||
pub to_ground_low_prio_dir: PathBuf,
|
||||
}
|
||||
|
||||
impl Default for ControllerPathCollection {
|
||||
fn default() -> Self {
|
||||
let home_path = HOME_PATH.get().unwrap();
|
||||
let mut home_path_stop_file = PathBuf::new();
|
||||
home_path_stop_file.push(home_path);
|
||||
impl ControllerPathCollection {
|
||||
pub fn new(base_path: &Path) -> Self {
|
||||
let home_path = base_path.to_path_buf();
|
||||
let mut home_path_stop_file = home_path.clone();
|
||||
home_path_stop_file.push(STOP_FILE_NAME);
|
||||
let mut tmp_path_stop_file = temp_dir();
|
||||
tmp_path_stop_file.push(STOP_FILE_NAME);
|
||||
@ -77,6 +76,7 @@ impl Default for ControllerPathCollection {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExperimentController {
|
||||
pub composite_request_rx: mpsc::Receiver<GenericMessage<CompositeRequest>>,
|
||||
pub action_reply_tx: mpsc::Sender<GenericMessage<ActionReplyPus>>,
|
||||
|
18
src/main.rs
18
src/main.rs
@ -58,17 +58,11 @@ fn main() {
|
||||
println!("OPS-SAT Rust Experiment OBSW v{}", version_str);
|
||||
setup_logger().expect("setting up logging with fern failed");
|
||||
|
||||
set_up_home_path();
|
||||
#[cfg(feature = "host")]
|
||||
let base_dir = std::env::current_dir()
|
||||
.expect("getting current dir failed")
|
||||
.to_path_buf();
|
||||
#[cfg(not(feature = "host"))]
|
||||
let base_dir = HOME_PATH.get().unwrap();
|
||||
set_up_low_prio_ground_dir(base_dir.clone());
|
||||
set_up_ground_dir(base_dir.clone());
|
||||
let home_path = set_up_home_path();
|
||||
set_up_low_prio_ground_dir(home_path.clone());
|
||||
set_up_ground_dir(home_path.clone());
|
||||
|
||||
let app_cfg = create_app_config(base_dir.clone());
|
||||
let app_cfg = create_app_config(home_path.clone());
|
||||
info!("App Configuration: {:?}", app_cfg);
|
||||
|
||||
let stop_signal = Arc::new(AtomicBool::new(false));
|
||||
@ -201,7 +195,7 @@ fn main() {
|
||||
stop_signal.clone(),
|
||||
);
|
||||
|
||||
let mut home_path_stop_file = base_dir.clone();
|
||||
let mut home_path_stop_file = home_path.clone();
|
||||
home_path_stop_file.push(STOP_FILE_NAME);
|
||||
let mut tmp_path_stop_file = temp_dir();
|
||||
tmp_path_stop_file.push(STOP_FILE_NAME);
|
||||
@ -209,7 +203,7 @@ fn main() {
|
||||
controller_composite_rx,
|
||||
pus_action_reply_tx.clone(),
|
||||
stop_signal.clone(),
|
||||
ControllerPathCollection::default(),
|
||||
ControllerPathCollection::new(&home_path),
|
||||
);
|
||||
|
||||
let mut tcp_spp_client = TcpSppClientStd::new(
|
||||
|
@ -66,7 +66,8 @@ impl DirectPusService for EventServiceWrapper {
|
||||
Self::SERVICE_STR,
|
||||
e
|
||||
);
|
||||
return HandlingStatus::HandledOne;
|
||||
// To avoid permanent loops.
|
||||
return HandlingStatus::Empty;
|
||||
}
|
||||
match result.unwrap() {
|
||||
DirectPusPacketHandlerResult::Handled(handling_status) => return handling_status,
|
||||
|
@ -171,7 +171,7 @@ pub trait TargetedPusService {
|
||||
let result = self.poll_and_handle_next_tc(time_stamp);
|
||||
if let Err(e) = result {
|
||||
log::error!(
|
||||
"PUS service {}({})packet handling error: {:?}",
|
||||
"PUS service {}({}) packet handling error: {:?}",
|
||||
Self::SERVICE_ID,
|
||||
Self::SERVICE_STR,
|
||||
e
|
||||
@ -187,7 +187,7 @@ pub trait TargetedPusService {
|
||||
self.poll_and_handle_next_reply(time_stamp)
|
||||
.unwrap_or_else(|e| {
|
||||
warn!(
|
||||
"PUS servce {}({}): Handling reply failed with error {:?}",
|
||||
"PUS service {}({}): handling reply failed with error {:?}",
|
||||
Self::SERVICE_ID,
|
||||
Self::SERVICE_STR,
|
||||
e
|
||||
|
@ -57,7 +57,8 @@ impl DirectPusService for SchedulingService {
|
||||
Self::SERVICE_STR,
|
||||
e
|
||||
);
|
||||
return HandlingStatus::HandledOne;
|
||||
// To avoid permanent loops.
|
||||
return HandlingStatus::Empty;
|
||||
}
|
||||
match result.unwrap() {
|
||||
DirectPusPacketHandlerResult::Handled(handling_status) => return handling_status,
|
||||
|
@ -67,7 +67,8 @@ impl DirectPusService for TestCustomServiceWrapper {
|
||||
Self::SERVICE_STR,
|
||||
e
|
||||
);
|
||||
return HandlingStatus::HandledOne;
|
||||
// To avoid permanent loops.
|
||||
return HandlingStatus::Empty;
|
||||
}
|
||||
match res.unwrap() {
|
||||
DirectPusPacketHandlerResult::Handled(handling_status) => {
|
||||
|
Loading…
Reference in New Issue
Block a user