Merge pull request 'Some bugfixes and docs' (#31) from some-bugfixes into main
Reviewed-on: #31
This commit is contained in:
commit
d37da28efb
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -172,7 +172,8 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "cobs"
|
name = "cobs"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
source = "git+https://github.com/robamu/cobs.rs.git?branch=all_features#c70a7f30fd00a7cbdb7666dec12b437977385d40"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colorchoice"
|
name = "colorchoice"
|
||||||
@ -780,8 +781,9 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "satrs"
|
name = "satrs"
|
||||||
version = "0.2.0-rc.5"
|
version = "0.2.0"
|
||||||
source = "git+https://egit.irs.uni-stuttgart.de/rust/sat-rs.git?branch=main#9ffe4d0ae02064444da606b2cd1a3c0dd6858fbb"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9de5d1f732620b9623289e0e5e3cb480f6bc8d8704f528ca2875dfe200ba90b2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bus",
|
"bus",
|
||||||
"cobs",
|
"cobs",
|
||||||
|
@ -24,9 +24,9 @@ socket2 = "0.5"
|
|||||||
once_cell = "1.19"
|
once_cell = "1.19"
|
||||||
|
|
||||||
[dependencies.satrs]
|
[dependencies.satrs]
|
||||||
version = "0.2.0-rc.5"
|
version = "0.2.0"
|
||||||
git = "https://egit.irs.uni-stuttgart.de/rust/sat-rs.git"
|
# git = "https://egit.irs.uni-stuttgart.de/rust/sat-rs.git"
|
||||||
branch = "main"
|
# branch = "main"
|
||||||
features = ["test_util"]
|
features = ["test_util"]
|
||||||
|
|
||||||
[dependencies.satrs-mib]
|
[dependencies.satrs-mib]
|
||||||
|
11
README.md
11
README.md
@ -17,6 +17,17 @@ You might need to set the [`CROSS_CONTAINER_ENGINE`](https://github.com/cross-rs
|
|||||||
and [`CROSS_ROOTLESS_CONTAINER_ENGINE`](https://github.com/cross-rs/cross/blob/main/docs/environment_variables.md#configuring-cross-with-environment-variables)
|
and [`CROSS_ROOTLESS_CONTAINER_ENGINE`](https://github.com/cross-rs/cross/blob/main/docs/environment_variables.md#configuring-cross-with-environment-variables)
|
||||||
variables manually before calling cross.
|
variables manually before calling cross.
|
||||||
|
|
||||||
|
The OPS-SAT software filesystem handling will determine a home path at the start of the software.
|
||||||
|
This home path is used for various mechanisms inside the OPS-SAT infrastructure.
|
||||||
|
|
||||||
|
Currently, there are 3 possible configurations:
|
||||||
|
|
||||||
|
1. If the software is built with the `host` feature, the HOME path will be the current path the
|
||||||
|
software is run at.
|
||||||
|
2. If the `host` feature is not set and the `/home/exp278` folder exists, that folder will be
|
||||||
|
the home directory.
|
||||||
|
3. Otherwise, the default OS home directory will be the home directory.
|
||||||
|
|
||||||
### Debug Build
|
### Debug Build
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -55,32 +55,30 @@ pub enum GroupId {
|
|||||||
pub const TEST_EVENT: EventU32TypedSev<SeverityInfo> =
|
pub const TEST_EVENT: EventU32TypedSev<SeverityInfo> =
|
||||||
EventU32TypedSev::<SeverityInfo>::new(GroupId::Tmtc as u16, 0);
|
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 mut home_path = PathBuf::new();
|
||||||
|
if cfg!(feature = "host") {
|
||||||
|
home_path = std::env::current_dir()
|
||||||
|
.expect("getting current dir failed")
|
||||||
|
.to_path_buf();
|
||||||
|
} else {
|
||||||
let home_path_default = homedir::get_my_home()
|
let home_path_default = homedir::get_my_home()
|
||||||
.expect("Getting home dir from OS failed.")
|
.expect("Getting home dir from OS failed.")
|
||||||
.expect("No home dir found.");
|
.expect("No home dir found.");
|
||||||
|
if Path::new(HOME_FOLDER_EXPERIMENT).exists() {
|
||||||
home_path.push(if Path::new(HOME_FOLDER_EXPERIMENT).exists() {
|
home_path.push(HOME_FOLDER_EXPERIMENT);
|
||||||
HOME_FOLDER_EXPERIMENT
|
|
||||||
} else {
|
} else {
|
||||||
home_path_default
|
home_path = home_path_default;
|
||||||
.to_str()
|
}
|
||||||
.expect("Error converting to string.")
|
}
|
||||||
});
|
|
||||||
HOME_PATH
|
HOME_PATH
|
||||||
.set(home_path)
|
.set(home_path.clone())
|
||||||
.expect("attempting to set once cell twice")
|
.expect("attempting to set once cell twice");
|
||||||
|
home_path
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_up_low_prio_ground_dir(base_path: PathBuf) {
|
pub fn set_up_low_prio_ground_dir(home_path: PathBuf) {
|
||||||
/*
|
let mut to_ground_lp_dir = home_path.to_path_buf();
|
||||||
#[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();
|
|
||||||
to_ground_lp_dir.push(TO_GROUND_LP_FOLDER_NAME);
|
to_ground_lp_dir.push(TO_GROUND_LP_FOLDER_NAME);
|
||||||
if !Path::new(&to_ground_lp_dir).exists() {
|
if !Path::new(&to_ground_lp_dir).exists() {
|
||||||
log::info!(
|
log::info!(
|
||||||
@ -99,14 +97,8 @@ pub fn set_up_low_prio_ground_dir(base_path: PathBuf) {
|
|||||||
.expect("attemting to set once cell twice");
|
.expect("attemting to set once cell twice");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_up_ground_dir(base_path: PathBuf) {
|
pub fn set_up_ground_dir(home_path: PathBuf) {
|
||||||
/*
|
let mut to_ground_dir = home_path.to_path_buf();
|
||||||
#[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();
|
|
||||||
to_ground_dir.push(TO_GROUND_FOLDER_NAME);
|
to_ground_dir.push(TO_GROUND_FOLDER_NAME);
|
||||||
if !Path::new(&to_ground_dir).exists() {
|
if !Path::new(&to_ground_dir).exists() {
|
||||||
log::info!("creating to ground directory at {:?}", to_ground_dir);
|
log::info!("creating to ground directory at {:?}", to_ground_dir);
|
||||||
|
@ -54,11 +54,10 @@ pub struct ControllerPathCollection {
|
|||||||
pub to_ground_low_prio_dir: PathBuf,
|
pub to_ground_low_prio_dir: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ControllerPathCollection {
|
impl ControllerPathCollection {
|
||||||
fn default() -> Self {
|
pub fn new(base_path: &Path) -> Self {
|
||||||
let home_path = HOME_PATH.get().unwrap();
|
let home_path = base_path.to_path_buf();
|
||||||
let mut home_path_stop_file = PathBuf::new();
|
let mut home_path_stop_file = home_path.clone();
|
||||||
home_path_stop_file.push(home_path);
|
|
||||||
home_path_stop_file.push(STOP_FILE_NAME);
|
home_path_stop_file.push(STOP_FILE_NAME);
|
||||||
let mut tmp_path_stop_file = temp_dir();
|
let mut tmp_path_stop_file = temp_dir();
|
||||||
tmp_path_stop_file.push(STOP_FILE_NAME);
|
tmp_path_stop_file.push(STOP_FILE_NAME);
|
||||||
@ -77,6 +76,7 @@ impl Default for ControllerPathCollection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ExperimentController {
|
pub struct ExperimentController {
|
||||||
pub composite_request_rx: mpsc::Receiver<GenericMessage<CompositeRequest>>,
|
pub composite_request_rx: mpsc::Receiver<GenericMessage<CompositeRequest>>,
|
||||||
pub action_reply_tx: mpsc::Sender<GenericMessage<ActionReplyPus>>,
|
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);
|
println!("OPS-SAT Rust Experiment OBSW v{}", version_str);
|
||||||
setup_logger().expect("setting up logging with fern failed");
|
setup_logger().expect("setting up logging with fern failed");
|
||||||
|
|
||||||
set_up_home_path();
|
let home_path = set_up_home_path();
|
||||||
#[cfg(feature = "host")]
|
set_up_low_prio_ground_dir(home_path.clone());
|
||||||
let base_dir = std::env::current_dir()
|
set_up_ground_dir(home_path.clone());
|
||||||
.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 app_cfg = create_app_config(base_dir.clone());
|
let app_cfg = create_app_config(home_path.clone());
|
||||||
info!("App Configuration: {:?}", app_cfg);
|
info!("App Configuration: {:?}", app_cfg);
|
||||||
|
|
||||||
let stop_signal = Arc::new(AtomicBool::new(false));
|
let stop_signal = Arc::new(AtomicBool::new(false));
|
||||||
@ -201,7 +195,7 @@ fn main() {
|
|||||||
stop_signal.clone(),
|
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);
|
home_path_stop_file.push(STOP_FILE_NAME);
|
||||||
let mut tmp_path_stop_file = temp_dir();
|
let mut tmp_path_stop_file = temp_dir();
|
||||||
tmp_path_stop_file.push(STOP_FILE_NAME);
|
tmp_path_stop_file.push(STOP_FILE_NAME);
|
||||||
@ -209,7 +203,7 @@ fn main() {
|
|||||||
controller_composite_rx,
|
controller_composite_rx,
|
||||||
pus_action_reply_tx.clone(),
|
pus_action_reply_tx.clone(),
|
||||||
stop_signal.clone(),
|
stop_signal.clone(),
|
||||||
ControllerPathCollection::default(),
|
ControllerPathCollection::new(&home_path),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut tcp_spp_client = TcpSppClientStd::new(
|
let mut tcp_spp_client = TcpSppClientStd::new(
|
||||||
|
@ -66,7 +66,8 @@ impl DirectPusService for EventServiceWrapper {
|
|||||||
Self::SERVICE_STR,
|
Self::SERVICE_STR,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
return HandlingStatus::HandledOne;
|
// To avoid permanent loops.
|
||||||
|
return HandlingStatus::Empty;
|
||||||
}
|
}
|
||||||
match result.unwrap() {
|
match result.unwrap() {
|
||||||
DirectPusPacketHandlerResult::Handled(handling_status) => return handling_status,
|
DirectPusPacketHandlerResult::Handled(handling_status) => return handling_status,
|
||||||
|
@ -187,7 +187,7 @@ pub trait TargetedPusService {
|
|||||||
self.poll_and_handle_next_reply(time_stamp)
|
self.poll_and_handle_next_reply(time_stamp)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
warn!(
|
warn!(
|
||||||
"PUS servce {}({}): Handling reply failed with error {:?}",
|
"PUS service {}({}): handling reply failed with error {:?}",
|
||||||
Self::SERVICE_ID,
|
Self::SERVICE_ID,
|
||||||
Self::SERVICE_STR,
|
Self::SERVICE_STR,
|
||||||
e
|
e
|
||||||
|
@ -57,7 +57,8 @@ impl DirectPusService for SchedulingService {
|
|||||||
Self::SERVICE_STR,
|
Self::SERVICE_STR,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
return HandlingStatus::HandledOne;
|
// To avoid permanent loops.
|
||||||
|
return HandlingStatus::Empty;
|
||||||
}
|
}
|
||||||
match result.unwrap() {
|
match result.unwrap() {
|
||||||
DirectPusPacketHandlerResult::Handled(handling_status) => return handling_status,
|
DirectPusPacketHandlerResult::Handled(handling_status) => return handling_status,
|
||||||
|
@ -67,7 +67,8 @@ impl DirectPusService for TestCustomServiceWrapper {
|
|||||||
Self::SERVICE_STR,
|
Self::SERVICE_STR,
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
return HandlingStatus::HandledOne;
|
// To avoid permanent loops.
|
||||||
|
return HandlingStatus::Empty;
|
||||||
}
|
}
|
||||||
match res.unwrap() {
|
match res.unwrap() {
|
||||||
DirectPusPacketHandlerResult::Handled(handling_status) => {
|
DirectPusPacketHandlerResult::Handled(handling_status) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user