TargetIdWithApid #63

Merged
muellerr merged 14 commits from TargetIdWithApid into main 2024-01-31 11:06:34 +01:00
9 changed files with 6 additions and 65 deletions
Showing only changes of commit b27842c2bb - Show all commits

View File

@ -17,8 +17,6 @@ zerocopy = "0.6"
csv = "1" csv = "1"
num_enum = "0.7" num_enum = "0.7"
thiserror = "1" thiserror = "1"
embedded-can = "0.4"
#socketcan = "2.0"
derive-new = "0.5" derive-new = "0.5"
num-traits = "0.2" num-traits = "0.2"
num-derive = "0.3" num-derive = "0.3"

View File

@ -1,6 +1,5 @@
use derive_new::new; use derive_new::new;
use satrs_example::TargetIdWithApid; use satrs_example::TargetIdWithApid;
use zerocopy::AsBytes;
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum AcsHkIds { pub enum AcsHkIds {
@ -19,6 +18,7 @@ impl From<u32> for HkUniqueId {
} }
impl HkUniqueId { impl HkUniqueId {
#[allow(dead_code)]
pub fn id(&self) -> u32 { pub fn id(&self) -> u32 {
lkoester marked this conversation as resolved Outdated

target_id

`target_id`
self.id self.id
} }

View File

@ -12,7 +12,6 @@ use thiserror::Error;
use satrs_mib::res_code::{ResultU16, ResultU16Info}; use satrs_mib::res_code::{ResultU16, ResultU16Info};
use satrs_mib::resultcode; use satrs_mib::resultcode;
mod logger;
pub type Apid = u16; pub type Apid = u16;
@ -64,37 +63,6 @@ impl TargetIdWithApid {
} }
} }
// #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, new)]
// #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
// pub struct TargetIdWithUniqueId {
// target_id: TargetIdWithApid,
// unique_id: u32,
// }
//
// impl TargetIdWithUniqueId {
// delegate! {
// to self.target_id {
// pub fn apid(&self) -> Apid;
// pub fn target_id(&self) -> TargetId;
// }
// }
// pub fn unique_id(&self) -> u32 {
// self.unique_id
// }
//
// pub fn write_target_id_and_unique_id_as_pus_header(&self, buf: &mut [u8]) -> Result<usize, ByteConversionError> {
// if buf.len() < 8 {
// return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
// found: buf.len(),
// expected: 8,
// }));
// }
// buf[0..4].copy_from_slice(&self.target_id.target_id().to_be_bytes());
// buf[4..8].copy_from_slice(&self.unique_id.to_be_bytes());
// Ok(8)
// }
// }
//
pub const PUS_APID: u16 = 0x02; pub const PUS_APID: u16 = 0x02;
#[derive(Copy, Clone, PartialEq, Eq, Debug, TryFromPrimitive, IntoPrimitive)] #[derive(Copy, Clone, PartialEq, Eq, Debug, TryFromPrimitive, IntoPrimitive)]

View File

@ -1,8 +1,3 @@
#![allow(unused_imports)]
use chrono;
use log::{debug, error, info, trace, warn};
pub fn setup_logger() -> Result<(), fern::InitError> { pub fn setup_logger() -> Result<(), fern::InitError> {
fern::Dispatch::new() fern::Dispatch::new()
.format(|out, message, record| { .format(|out, message, record| {

View File

@ -1,16 +0,0 @@
pub fn setup_logger() -> Result<(), fern::InitError> {
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{}[{}][{}] {}",
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
record.target(), //(std::thread::current().name().expect("unnamed_thread"),
record.level(),
message
))
})
.level(log::LevelFilter::Debug)
.chain(std::io::stdout())
.apply()?;
Ok(())
}

View File

@ -1,6 +1,6 @@
mod ccsds; mod ccsds;
mod hk; mod hk;
mod logging; mod logger;
mod pus; mod pus;
mod requests; mod requests;
mod tcp; mod tcp;
@ -12,9 +12,8 @@ use satrs_core::hal::std::tcp_server::ServerConfig;
use satrs_core::hal::std::udp_server::UdpTcServer; use satrs_core::hal::std::udp_server::UdpTcServer;
use crate::ccsds::CcsdsReceiver; use crate::ccsds::CcsdsReceiver;
use crate::hk::AcsHkIds;
use crate::hk::{AcsHkIds, HkUniqueId}; use crate::hk::{AcsHkIds, HkUniqueId};
use crate::logging::setup_logger; use crate::logger::setup_logger;
use crate::pus::action::{Pus8Wrapper, PusService8ActionHandler}; use crate::pus::action::{Pus8Wrapper, PusService8ActionHandler};
use crate::pus::event::Pus5Wrapper; use crate::pus::event::Pus5Wrapper;
use crate::pus::hk::{Pus3Wrapper, PusService3HkHandler}; use crate::pus::hk::{Pus3Wrapper, PusService3HkHandler};
@ -51,7 +50,7 @@ use satrs_core::spacepackets::{
SpHeader, SpHeader,
}; };
use satrs_core::tmtc::tm_helper::SharedTmStore; use satrs_core::tmtc::tm_helper::SharedTmStore;
use satrs_core::tmtc::TargetId; use satrs_core::tmtc::{CcsdsDistributor, TargetId};
use satrs_core::ChannelId; use satrs_core::ChannelId;
use satrs_example::{ use satrs_example::{
RequestTargetId, TargetIdWithApid, TcReceiverId, TmSenderId, OBSW_SERVER_ADDR, PUS_APID, RequestTargetId, TargetIdWithApid, TcReceiverId, TmSenderId, OBSW_SERVER_ADDR, PUS_APID,
@ -465,7 +464,7 @@ fn main() {
); );
let mut buf: [u8; 8] = [0; 8]; let mut buf: [u8; 8] = [0; 8];
let hk_id = HkUniqueId::new(1); let hk_id = HkUniqueId::new(unique_id);
hk_id hk_id
.bytes_from_target_id_with_apid(&mut buf, target) .bytes_from_target_id_with_apid(&mut buf, target)
.unwrap(); .unwrap();

View File

@ -10,7 +10,6 @@ use satrs_core::pus::{
}; };
use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::tc::PusTcReader;
use satrs_core::spacepackets::ecss::PusPacket; use satrs_core::spacepackets::ecss::PusPacket;
use satrs_core::tmtc::TargetId;
use satrs_example::{tmtc_err, TargetIdWithApid}; use satrs_example::{tmtc_err, TargetIdWithApid};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;

View File

@ -1,6 +1,6 @@
use crate::requests::{Request, RequestWithToken}; use crate::requests::{Request, RequestWithToken};
use log::{error, warn}; use log::{error, warn};
use satrs_core::hk::{CollectionIntervalFactor, HkRequest, UniqueId}; use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
use satrs_core::pool::{SharedPool, StoreAddr}; use satrs_core::pool::{SharedPool, StoreAddr};
use satrs_core::pus::verification::{ use satrs_core::pus::verification::{
FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken, FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken,
@ -11,7 +11,6 @@ use satrs_core::pus::{
}; };
use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::tc::PusTcReader;
use satrs_core::spacepackets::ecss::{hk, PusPacket}; use satrs_core::spacepackets::ecss::{hk, PusPacket};
use satrs_core::tmtc::TargetId;
use satrs_example::{hk_err, tmtc_err, TargetIdWithApid}; use satrs_example::{hk_err, tmtc_err, TargetIdWithApid};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;

View File

@ -2,7 +2,6 @@ use derive_new::new;
use satrs_core::hk::HkRequest; use satrs_core::hk::HkRequest;
use satrs_core::mode::ModeRequest; use satrs_core::mode::ModeRequest;
use satrs_core::pus::verification::{TcStateAccepted, VerificationToken}; use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
use satrs_core::tmtc::TargetId;
use satrs_example::TargetIdWithApid; use satrs_example::TargetIdWithApid;
#[allow(dead_code)] #[allow(dead_code)]