2024-04-04 15:18:53 +02:00
|
|
|
use lazy_static::lazy_static;
|
|
|
|
use satrs::{
|
|
|
|
res_code::ResultU16,
|
|
|
|
spacepackets::{PacketId, PacketType},
|
|
|
|
};
|
2024-02-07 18:10:47 +01:00
|
|
|
use satrs_mib::res_code::ResultU16Info;
|
|
|
|
use satrs_mib::resultcode;
|
2024-04-04 15:18:53 +02:00
|
|
|
use std::{collections::HashSet, net::Ipv4Addr};
|
|
|
|
use strum::IntoEnumIterator;
|
2024-02-07 18:10:47 +01:00
|
|
|
|
|
|
|
use num_enum::{IntoPrimitive, TryFromPrimitive};
|
2024-02-12 15:51:37 +01:00
|
|
|
use satrs::{
|
2024-02-07 18:10:47 +01:00
|
|
|
events::{EventU32TypedSev, SeverityInfo},
|
|
|
|
pool::{StaticMemoryPool, StaticPoolConfig},
|
|
|
|
};
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, TryFromPrimitive, IntoPrimitive)]
|
|
|
|
#[repr(u8)]
|
|
|
|
pub enum CustomPusServiceId {
|
|
|
|
Mode = 200,
|
|
|
|
Health = 201,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
|
|
|
pub enum RequestTargetId {
|
|
|
|
AcsSubsystem = 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const AOCS_APID: u16 = 1;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum GroupId {
|
|
|
|
Tmtc = 0,
|
|
|
|
Hk = 1,
|
2024-04-04 15:18:53 +02:00
|
|
|
Mode = 2,
|
2024-02-07 18:10:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
|
|
|
|
pub const SERVER_PORT: u16 = 7301;
|
|
|
|
|
|
|
|
pub const TEST_EVENT: EventU32TypedSev<SeverityInfo> =
|
|
|
|
EventU32TypedSev::<SeverityInfo>::const_new(0, 0);
|
|
|
|
|
2024-04-04 15:18:53 +02:00
|
|
|
lazy_static! {
|
|
|
|
pub static ref PACKET_ID_VALIDATOR: HashSet<PacketId> = {
|
|
|
|
let mut set = HashSet::new();
|
|
|
|
for id in components::Apid::iter() {
|
|
|
|
set.insert(PacketId::new(PacketType::Tc, true, id as u16));
|
|
|
|
}
|
|
|
|
set
|
|
|
|
};
|
|
|
|
pub static ref APID_VALIDATOR: HashSet<u16> = {
|
|
|
|
let mut set = HashSet::new();
|
|
|
|
for id in components::Apid::iter() {
|
|
|
|
set.insert(id as u16);
|
|
|
|
}
|
|
|
|
set
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-02-07 18:10:47 +01:00
|
|
|
pub mod tmtc_err {
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 0);
|
2024-02-07 18:10:47 +01:00
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 1);
|
2024-02-07 18:10:47 +01:00
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const PUS_SERVICE_NOT_IMPLEMENTED: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 2);
|
2024-02-07 18:10:47 +01:00
|
|
|
#[resultcode]
|
2024-02-20 14:33:21 +01:00
|
|
|
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);
|
2024-04-04 15:18:53 +02:00
|
|
|
#[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);
|
2024-02-07 18:10:47 +01:00
|
|
|
|
|
|
|
#[resultcode(
|
|
|
|
info = "Not enough data inside the TC application data field. Optionally includes: \
|
|
|
|
8 bytes of failure data containing 2 failure parameters, \
|
|
|
|
P1 (u32 big endian): Expected data length, P2: Found data length"
|
|
|
|
)]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::new(GroupId::Tmtc as u8, 2);
|
2024-02-07 18:10:47 +01:00
|
|
|
|
|
|
|
pub const TMTC_RESULTS: &[ResultU16Info] = &[
|
|
|
|
INVALID_PUS_SERVICE_EXT,
|
|
|
|
INVALID_PUS_SUBSERVICE_EXT,
|
2024-02-20 14:33:21 +01:00
|
|
|
PUS_SERVICE_NOT_IMPLEMENTED_EXT,
|
|
|
|
UNKNOWN_TARGET_ID_EXT,
|
|
|
|
ROUTING_ERROR_EXT,
|
2024-02-07 18:10:47 +01:00
|
|
|
NOT_ENOUGH_APP_DATA_EXT,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod hk_err {
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const TARGET_ID_MISSING: ResultU16 = ResultU16::new(GroupId::Hk as u8, 0);
|
2024-02-07 18:10:47 +01:00
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const UNIQUE_ID_MISSING: ResultU16 = ResultU16::new(GroupId::Hk as u8, 1);
|
2024-02-07 18:10:47 +01:00
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const UNKNOWN_TARGET_ID: ResultU16 = ResultU16::new(GroupId::Hk as u8, 2);
|
2024-02-07 18:10:47 +01:00
|
|
|
#[resultcode]
|
2024-02-12 15:51:37 +01:00
|
|
|
pub const COLLECTION_INTERVAL_MISSING: ResultU16 = ResultU16::new(GroupId::Hk as u8, 3);
|
2024-02-20 14:33:21 +01:00
|
|
|
|
|
|
|
pub const HK_ERR_RESULTS: &[ResultU16Info] = &[
|
|
|
|
TARGET_ID_MISSING_EXT,
|
|
|
|
UNKNOWN_TARGET_ID_EXT,
|
|
|
|
UNKNOWN_TARGET_ID_EXT,
|
|
|
|
COLLECTION_INTERVAL_MISSING_EXT,
|
|
|
|
];
|
2024-02-07 18:10:47 +01:00
|
|
|
}
|
|
|
|
|
2024-04-04 15:18:53 +02:00
|
|
|
pub mod mode_err {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[resultcode]
|
|
|
|
pub const WRONG_MODE: ResultU16 = ResultU16::new(GroupId::Mode as u8, 0);
|
2024-02-07 18:10:47 +01:00
|
|
|
}
|
|
|
|
|
2024-04-04 15:18:53 +02:00
|
|
|
pub mod components {
|
|
|
|
use satrs::request::UniqueApidTargetId;
|
|
|
|
use strum::EnumIter;
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, EnumIter)]
|
|
|
|
pub enum Apid {
|
|
|
|
Sched = 1,
|
|
|
|
GenericPus = 2,
|
|
|
|
Acs = 3,
|
|
|
|
Cfdp = 4,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Component IDs for components with the PUS APID.
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
|
|
|
pub enum PusId {
|
|
|
|
PusEventManagement = 0,
|
|
|
|
PusRouting = 1,
|
|
|
|
PusTest = 2,
|
|
|
|
PusAction = 3,
|
|
|
|
PusMode = 4,
|
|
|
|
PusHk = 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
|
|
|
pub enum AcsId {
|
|
|
|
Mgm0 = 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const PUS_ACTION_SERVICE: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::GenericPus as u16, PusId::PusAction as u32);
|
|
|
|
pub const PUS_EVENT_MANAGEMENT: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::GenericPus as u16, 0);
|
|
|
|
pub const PUS_ROUTING_SERVICE: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::GenericPus as u16, PusId::PusRouting as u32);
|
|
|
|
pub const PUS_TEST_SERVICE: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::GenericPus as u16, PusId::PusTest as u32);
|
|
|
|
pub const PUS_MODE_SERVICE: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::GenericPus as u16, PusId::PusMode as u32);
|
|
|
|
pub const PUS_HK_SERVICE: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::GenericPus as u16, PusId::PusHk as u32);
|
|
|
|
pub const PUS_SCHED_SERVICE: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::Sched as u16, 0);
|
|
|
|
pub const MGM_HANDLER_0: UniqueApidTargetId =
|
|
|
|
UniqueApidTargetId::new(Apid::Acs as u16, AcsId::Mgm0 as u32);
|
2024-02-07 18:10:47 +01:00
|
|
|
}
|
2024-04-04 15:18:53 +02:00
|
|
|
|
2024-02-07 18:10:47 +01:00
|
|
|
pub mod pool {
|
|
|
|
use super::*;
|
|
|
|
pub fn create_static_pools() -> (StaticMemoryPool, StaticMemoryPool) {
|
|
|
|
(
|
2024-02-12 11:35:10 +01:00
|
|
|
StaticMemoryPool::new(StaticPoolConfig::new(
|
|
|
|
vec![
|
|
|
|
(30, 32),
|
|
|
|
(15, 64),
|
|
|
|
(15, 128),
|
|
|
|
(15, 256),
|
|
|
|
(15, 1024),
|
|
|
|
(15, 2048),
|
|
|
|
],
|
|
|
|
true,
|
|
|
|
)),
|
|
|
|
StaticMemoryPool::new(StaticPoolConfig::new(
|
|
|
|
vec![
|
|
|
|
(30, 32),
|
|
|
|
(15, 64),
|
|
|
|
(15, 128),
|
|
|
|
(15, 256),
|
|
|
|
(15, 1024),
|
|
|
|
(15, 2048),
|
|
|
|
],
|
|
|
|
true,
|
|
|
|
)),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn create_sched_tc_pool() -> StaticMemoryPool {
|
|
|
|
StaticMemoryPool::new(StaticPoolConfig::new(
|
|
|
|
vec![
|
2024-02-07 18:10:47 +01:00
|
|
|
(30, 32),
|
|
|
|
(15, 64),
|
|
|
|
(15, 128),
|
|
|
|
(15, 256),
|
|
|
|
(15, 1024),
|
|
|
|
(15, 2048),
|
2024-02-12 11:35:10 +01:00
|
|
|
],
|
|
|
|
true,
|
|
|
|
))
|
2024-02-07 18:10:47 +01: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;
|
|
|
|
}
|