ops-sat-rs/src/config.rs

134 lines
4.5 KiB
Rust
Raw Normal View History

2024-04-10 17:13:29 +02:00
use lazy_static::lazy_static;
2024-04-09 13:52:02 +02:00
use num_enum::{IntoPrimitive, TryFromPrimitive};
use satrs_mib::res_code::ResultU16Info;
use satrs_mib::resultcode;
2024-04-10 17:13:29 +02:00
use std::env;
2024-04-10 14:59:34 +02:00
use std::net::Ipv4Addr;
2024-04-10 17:13:29 +02:00
use std::path::{Path, PathBuf};
2024-04-08 17:29:18 +02:00
2024-04-09 17:07:39 +02:00
pub const STOP_FILE_NAME: &str = "stop-experiment";
2024-04-10 17:03:56 +02:00
pub const HOME_FOLER_EXPERIMENT: &str = "/home/exp278";
2024-04-09 17:07:39 +02:00
2024-04-08 17:29:18 +02:00
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
pub const SERVER_PORT: u16 = 7301;
2024-04-13 15:16:53 +02:00
pub const TCP_SPP_SERVER_PORT: u16 = 4096;
2024-04-10 14:59:34 +02:00
pub const EXPERIMENT_ID: u32 = 278;
pub const EXPERIMENT_APID: u16 = 1024 + EXPERIMENT_ID as u16;
2024-04-08 17:29:18 +02:00
2024-04-09 11:18:54 +02:00
#[derive(Copy, Clone, PartialEq, Eq, Debug, TryFromPrimitive, IntoPrimitive)]
#[repr(u8)]
pub enum CustomPusServiceId {
Mode = 200,
Health = 201,
}
#[derive(Debug)]
pub enum GroupId {
Tmtc = 0,
Hk = 1,
Mode = 2,
2024-04-10 15:37:24 +02:00
Action = 3,
2024-04-09 11:18:54 +02:00
}
2024-04-10 17:13:29 +02:00
lazy_static! {
pub static ref HOME_PATH: PathBuf = {
let home_path_default = env::var("HOME").expect("HOME env variable not set");
let mut home_path = PathBuf::new();
home_path.push(if Path::new(HOME_FOLER_EXPERIMENT).exists() {
HOME_FOLER_EXPERIMENT
} else {
&home_path_default
});
home_path
};
}
2024-04-09 11:18:54 +02:00
pub mod tmtc_err {
use super::*;
2024-04-09 13:52:02 +02:00
use satrs::res_code::ResultU16;
2024-04-09 11:18:54 +02:00
#[resultcode]
pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 0);
#[resultcode]
pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 1);
#[resultcode]
pub const PUS_SERVICE_NOT_IMPLEMENTED: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 2);
#[resultcode]
pub const PUS_SUBSERVICE_NOT_IMPLEMENTED: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 3);
#[resultcode]
pub const UNKNOWN_TARGET_ID: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 4);
#[resultcode]
pub const ROUTING_ERROR: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 5);
#[resultcode(info = "Request timeout for targeted PUS request. P1: Request ID. P2: Target ID")]
pub const REQUEST_TIMEOUT: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 6);
#[resultcode(
2024-04-09 13:52:02 +02:00
info = "Not enough data inside the TC application data field. Optionally includes: \
2024-04-09 11:18:54 +02:00
8 bytes of failure data containing 2 failure parameters, \
P1 (u32 big endian): Expected data length, P2: Found data length"
)]
pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 2);
pub const TMTC_RESULTS: &[ResultU16Info] = &[
INVALID_PUS_SERVICE_EXT,
INVALID_PUS_SUBSERVICE_EXT,
PUS_SERVICE_NOT_IMPLEMENTED_EXT,
UNKNOWN_TARGET_ID_EXT,
ROUTING_ERROR_EXT,
NOT_ENOUGH_APP_DATA_EXT,
];
}
2024-04-10 15:37:24 +02:00
pub mod action_err {
use super::*;
use satrs::res_code::ResultU16;
#[resultcode]
pub const INVALID_ACTION_ID: ResultU16 = ResultU16::new(GroupId::Action as u8, 0);
pub const ACTION_RESULTS: &[ResultU16Info] = &[INVALID_ACTION_ID_EXT];
}
2024-04-08 17:29:18 +02:00
pub mod components {
use satrs::request::UniqueApidTargetId;
2024-04-10 14:59:34 +02:00
use super::EXPERIMENT_APID;
2024-04-08 17:29:18 +02:00
// Component IDs for components with the PUS APID.
#[derive(Copy, Clone, PartialEq, Eq)]
2024-04-10 14:59:34 +02:00
pub enum UniqueId {
Controller = 0,
PusEventManagement = 1,
PusRouting = 2,
PusTest = 3,
PusAction = 4,
PusMode = 5,
PusHk = 6,
2024-04-08 17:29:18 +02:00
}
2024-04-10 14:59:34 +02:00
pub const CONTROLLER_ID: UniqueApidTargetId =
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::Controller as u32);
2024-04-08 17:29:18 +02:00
pub const PUS_ACTION_SERVICE: UniqueApidTargetId =
2024-04-10 14:59:34 +02:00
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::PusAction as u32);
2024-04-08 17:29:18 +02:00
pub const PUS_EVENT_MANAGEMENT: UniqueApidTargetId =
2024-04-10 14:59:34 +02:00
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::PusEventManagement as u32);
2024-04-08 17:29:18 +02:00
pub const PUS_ROUTING_SERVICE: UniqueApidTargetId =
2024-04-10 14:59:34 +02:00
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::PusRouting as u32);
2024-04-08 17:29:18 +02:00
pub const PUS_TEST_SERVICE: UniqueApidTargetId =
2024-04-10 14:59:34 +02:00
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::PusTest as u32);
2024-04-08 17:29:18 +02:00
pub const PUS_MODE_SERVICE: UniqueApidTargetId =
2024-04-10 14:59:34 +02:00
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::PusMode as u32);
2024-04-08 17:29:18 +02:00
pub const PUS_HK_SERVICE: UniqueApidTargetId =
2024-04-10 14:59:34 +02:00
UniqueApidTargetId::new(EXPERIMENT_APID, UniqueId::PusHk as u32);
2024-04-08 17:29:18 +02:00
}
pub mod tasks {
pub const FREQ_MS_UDP_TMTC: u64 = 200;
pub const FREQ_MS_EVENT_HANDLING: u64 = 400;
pub const FREQ_MS_AOCS: u64 = 500;
pub const FREQ_MS_PUS_STACK: u64 = 200;
2024-04-09 17:07:39 +02:00
pub const FREQ_MS_CTRL: u64 = 400;
2024-04-10 12:47:26 +02:00
pub const STOP_CHECK_FREQUENCY: u64 = 400;
2024-04-08 17:29:18 +02:00
}