finished new ids

This commit is contained in:
lkoester 2023-01-19 10:06:00 +01:00
parent 7ae4701e5f
commit e7600891ec
9 changed files with 153 additions and 126 deletions

0
src/aocs.rs Normal file
View File

View File

@ -19,7 +19,6 @@ use std::io;
use std::mem::size_of;
use std::sync::mpsc::Sender;
pub struct CanRxHandler {
interface: &'static str,
socket: socket::CanSocket,

View File

@ -14,7 +14,8 @@ use strum_macros::EnumIter; // 0.17.1
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
pub enum ThreadId {
AOCSThread,
TMThread,
PowerThread,
PLDThread,
}
#[derive(Debug, EnumIter, Eq, Hash, PartialEq, Copy, Clone, FromPrimitive)]
@ -32,31 +33,34 @@ pub enum PackageId {
AOCSControlMGT1 = 31,
AOCSControlMGT2 = 32,
AOCSControlMGT3 = 33,
AOCSControlRWL1 = 34,
AOCSControlRWL2 = 35,
AOCSControlRWL3 = 36,
AOCSDataMGM1 = 41,
AOCSDataMGM2 = 42,
AOCSDataMGM3 = 43,
AOCSDataSunSensor1 = 44,
AOCSDataSunSensor2 = 45,
AOCSDataSunSensor3 = 46,
AOCSDataStarTracker = 47,
HousekeepingRequest = 61,
HousekeepingMGM1 = 62,
HousekeepingMGM2 = 63,
HousekeepingMGM3 = 64,
HousekeepingSunSensor1 = 65,
HousekeepingSunSensor2 = 66,
HousekeepingSunSensor3 = 67,
HousekeepingStarTracker = 68,
HousekeepingMGT1 = 69,
HousekeepingMGT2 = 70,
HousekeepingMGT3 = 71,
HousekeepingRWL1 = 72,
HousekeepingRWL2 = 73,
HousekeepingRWL3 = 74,
CameraImageRequest = 101,
AOCSControlMGT4 = 34,
AOCSControlRWL1 = 35,
AOCSControlRWL2 = 36,
AOCSControlRWL3 = 37,
AOCSControlRWL4 = 38,
AOCSDataRequestMGM1 = 41,
AOCSDataRequestMGM2 = 42,
AOCSDataRequestMGM3 = 43,
AOCSDataRequestMGM4 = 44,
AOCSDataRequestSunSensor1 = 45,
AOCSDataRequestSunSensor2 = 46,
AOCSDataRequestSunSensor3 = 47,
AOCSDataRequestSunSensor4 = 48,
AOCSDataRequestSunSensor5 = 49,
AOCSDataRequestSunSensor6 = 50,
AOCSDataRequestStarTracker = 51,
AOCSDataMGM1 = 61,
AOCSDataMGM2 = 62,
AOCSDataMGM3 = 63,
AOCSDataMGM4 = 64,
AOCSDataSunSensor1 = 65,
AOCSDataSunSensor2 = 66,
AOCSDataSunSensor3 = 67,
AOCSDataSunSensor4 = 68,
AOCSDataSunSensor5 = 69,
AOCSDataSunSensor6 = 70,
AOCSDataStarTracker = 71,
CameraImageRequest = 101 ,
CameraImageRequestConfirmation = 102,
CameraImageExecutionStart = 103,
CameraImageExectutionEnd = 104,
@ -69,18 +73,24 @@ pub enum DeviceId {
MGM1 = 3,
MGM2 = 4,
MGM3 = 5,
SunSensor1 = 6,
SunSensor2 = 7,
SunSensor3 = 8,
StarTracker = 9,
MGT1 = 10,
MGT2 = 11,
MGT3 = 12,
RWL1 = 13,
RWL2 = 14,
RWL3 = 15,
Camera = 16,
All = 17,
MGM4 = 6,
SunSensor1 = 7,
SunSensor2 = 8,
SunSensor3 = 9,
SunSensor4 = 10,
SunSensor5 = 11,
SunSensor6 = 12,
StarTracker = 13,
MGT1 = 14,
MGT2 = 15,
MGT3 = 16,
MGT4 = 17,
RWL1 = 18,
RWL2 = 19,
RWL3 = 20,
RWL4 = 21,
Camera = 22,
All = 23,
}
#[derive(Debug)]
@ -142,47 +152,50 @@ pub fn load_package_ids() -> HashMap<PackageId, SenderReceiverThread> {
let mut package_map: HashMap<PackageId, SenderReceiverThread> = HashMap::new();
let properties = vec![
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::PCDU, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::PCDU, DeviceId::OBC, ThreadId::PowerThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT1, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT2, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT3, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGT4, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL1, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL2, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL3, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::RWL4, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGM1, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGM2, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGM3, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::MGM4, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::SunSensor1, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::SunSensor2, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::SunSensor3, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::SunSensor4, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::SunSensor5, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::SunSensor6, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::StarTracker, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM1, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM2, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM3, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::MGM4, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor1, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor2, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor3, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor4, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor5, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::SunSensor6, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::StarTracker, DeviceId::OBC, ThreadId::AOCSThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::All, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGM1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGM2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGM3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::SunSensor1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::SunSensor2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::SunSensor3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::StarTracker, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGT1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGT2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::MGT3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::RWL1, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::RWL2, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::RWL3, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::OBC, DeviceId::Camera, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::TMThread),
SenderReceiverThread::new(DeviceId:: OBC , DeviceId:: Camera , ThreadId:: PLDThread ),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::PLDThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::PLDThread),
SenderReceiverThread::new(DeviceId::Camera, DeviceId::OBC, ThreadId::PLDThread),
];
let mut i = 0;

View File

@ -1,6 +1,6 @@
use crate::tmtc::{MpscStoreAndSendError, PusTcSource, PUS_APID};
use satrs_core::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
use satrs_core::spacepackets::{CcsdsPacket, SpHeader};
use satrs_core::tmtc::{CcsdsPacketHandler, ReceivesCcsdsTc};
pub struct CcsdsReceiver {
pub tc_source: PusTcSource,

View File

@ -1,5 +1,5 @@
use socketcan::{errors, frame, socket, CanFrame, Socket};
use crate::can_ids::DeviceId;
use socketcan::{errors, frame, socket, CanFrame, Socket};
#[derive(Copy, Clone)]
pub enum DeviceState {

View File

@ -3,6 +3,7 @@ use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{
core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID,
};
use eurosim_obsw::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs_core::event_man::{
EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider,
};
@ -18,21 +19,20 @@ use satrs_core::pus::verification::{
};
use satrs_core::pus::{EcssTmError, EcssTmSenderCore};
use satrs_core::seq_count::{SeqCountProviderSyncClonable, SequenceCountProvider};
use eurosim_obsw::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs_core::{
spacepackets::time::cds::TimeProvider,
spacepackets::time::TimeWriter,
spacepackets::tm::{PusTm, PusTmSecondaryHeader},
spacepackets::{SequenceFlags, SpHeader}
spacepackets::{SequenceFlags, SpHeader},
};
use crate::EventTmSender;
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::sync::mpsc::{channel, TryRecvError};
use std::sync::{mpsc, Arc, RwLock};
use std::thread;
use std::time::Duration;
use crate::EventTmSender;
fn example_main() {
let tm_pool = LocalPool::new(PoolCfg::new(vec![
@ -66,12 +66,12 @@ fn example_main() {
let verif_cfg = VerificationReporterCfg::new(
PUS_APID,
#[allow(clippy::box_default)]
Box::new(SeqCountProviderSyncClonable::default()),
Box::new(SeqCountProviderSyncClonable::default()),
1,
2,
8,
)
.unwrap();
.unwrap();
let verif_reporter = VerificationReporterWithSender::new(&verif_cfg, Box::new(verif_sender));
// Create event handling components

View File

@ -1,19 +1,21 @@
mod can;
mod can_ids;
mod ccsds;
mod device_handler;
mod example_main;
mod hk;
mod logger;
mod pus;
mod requests;
mod tmtc;
mod example_main;
mod can;
mod can_ids;
mod device_handler;
mod logger;
mod aocs;
use crate::hk::{AcsHkIds, HkRequest};
use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{
core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID,
};
use eurosim_obsw::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs_core::event_man::{
EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider,
};
@ -28,8 +30,9 @@ use satrs_core::pus::verification::{
MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender,
};
use satrs_core::pus::{EcssTmError, EcssTmErrorWithSend, EcssTmSenderCore};
use satrs_core::seq_count::{SeqCountProviderSyncClonable, SequenceCountProvider, SequenceCountProviderCore};
use eurosim_obsw::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use satrs_core::seq_count::{
SeqCountProviderSyncClonable, SequenceCountProvider, SequenceCountProviderCore,
};
use satrs_core::{
spacepackets::time::cds::TimeProvider,
spacepackets::time::TimeWriter,
@ -37,16 +40,16 @@ use satrs_core::{
spacepackets::{SequenceFlags, SpHeader},
};
use crate::can_ids::{can_id_to_package_id, load_package_ids, PackageId, PackageModel, ThreadId};
use embedded_can::{Id, StandardId};
use log::{info, warn};
use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper;
use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr};
use std::sync::mpsc::{channel, TryRecvError};
use std::sync::{mpsc, Arc, RwLock};
use std::thread;
use std::time::Duration;
use embedded_can::{Id, StandardId};
use log::{info, warn};
use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper;
use crate::can_ids::{can_id_to_package_id, load_package_ids, PackageId, PackageModel, ThreadId};
#[derive(Clone)]
struct EventTmSender {
@ -68,7 +71,9 @@ impl EcssTmSenderCore for EventTmSender {
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmErrorWithSend<Self::Error>> {
let addr = self.store_helper.add_pus_tm(&tm);
self.sender.send(addr).map_err(EcssTmErrorWithSend::SendError)
self.sender
.send(addr)
.map_err(EcssTmErrorWithSend::SendError)
}
}
@ -111,13 +116,12 @@ fn main() {
let verif_cfg = VerificationReporterCfg::new(
PUS_APID,
#[allow(clippy::box_default)]
Box::new(seq_count_provider.clone()),
Box::new(seq_count_provider.clone()),
1,
2,
8,
)
.unwrap();
.unwrap();
let verif_reporter = VerificationReporterWithSender::new(&verif_cfg, Box::new(verif_sender));
@ -166,12 +170,14 @@ fn main() {
};
let (aocs_can_tx, aocs_can_rx) = mpsc::channel::<PackageModel>();
let (tm_can_tx, tm_can_rx) = mpsc::channel::<PackageModel>();
let (power_can_tx, power_can_rx) = mpsc::channel::<PackageModel>();
let (pld_can_tx, pld_can_rx) = mpsc::channel::<PackageModel>();
// make tx thread id hashmap
let mut can_senders = HashMap::new();
can_senders.insert(ThreadId::AOCSThread, aocs_can_tx);
can_senders.insert(ThreadId::TMThread, tm_can_tx);
can_senders.insert(ThreadId::PowerThread, power_can_tx);
can_senders.insert(ThreadId::PLDThread, pld_can_tx);
// get package id hashmap
let package_ids_rx = load_package_ids();
@ -232,11 +238,9 @@ fn main() {
let msg = aocs_can_rx.try_recv();
//current_mgm_data.x = new_data
match aocs_can_rx.try_recv() {
Ok(package) => {
match package.package_id() {
_ => warn!("Incorrect Id"),
}
}
Ok(package) => match package.package_id() {
_ => warn!("Incorrect Id"),
},
Err(_) => {}
}
@ -249,29 +253,45 @@ fn main() {
HkRequest::OneShot(id) => {
assert_eq!(id.target_id, RequestTargetId::AcsSubsystem as u32);
if id.unique_id == 0 {
let mut sp_header = SpHeader::tm_unseg(0x02, aocs_seq_count_provider.get_and_increment(), 0).unwrap();
let cds_stamp = TimeProvider::from_now_with_u16_days().unwrap();
let mut sp_header = SpHeader::tm_unseg(
0x02,
aocs_seq_count_provider.get_and_increment(),
0,
)
.unwrap();
let cds_stamp =
TimeProvider::from_now_with_u16_days().unwrap();
cds_stamp.write_to_bytes(&mut time_stamp_buf);
let mut len = id.write_to_be_bytes(&mut huge_buf).unwrap();
let json_string = "asdf";
huge_buf[8..json_string.len()+8].copy_from_slice(json_string.as_bytes());
huge_buf[8..json_string.len() + 8]
.copy_from_slice(json_string.as_bytes());
len += json_string.len();
let tm_sec_header = PusTmSecondaryHeader::new_simple(3, Subservice::TmHkPacket as u8, &time_stamp_buf);
let hk_tm = PusTm::new(&mut sp_header, tm_sec_header, Some(&huge_buf[0..len]), true);
let tm_sec_header = PusTmSecondaryHeader::new_simple(
3,
Subservice::TmHkPacket as u8,
&time_stamp_buf,
);
let hk_tm = PusTm::new(
&mut sp_header,
tm_sec_header,
Some(&huge_buf[0..len]),
true,
);
let addr = aocs_tm_store.add_pus_tm(&hk_tm);
aocs_tm_funnel_tx.send(addr).expect("sending failed");
/* let start_token = self //implement this for verification
.verif_reporter
.start_success(token, &self.time_stamp)
.expect("Error sending start success");
self.tm_tx
.send(addr)
.expect("Sending TM to TM funnel failed");
self.verif_reporter
.completion_success(start_token, &self.time_stamp)
.expect("Error sending completion success");
.verif_reporter
.start_success(token, &self.time_stamp)
.expect("Error sending start success");
self.tm_tx
.send(addr)
.expect("Sending TM to TM funnel failed");
self.verif_reporter
.completion_success(start_token, &self.time_stamp)
.expect("Error sending completion success");
*/
*/
}
}
HkRequest::Enable(_) => {}
@ -284,8 +304,7 @@ fn main() {
Err(_) => {}
}
}
}
);
});
println!("Starting TM funnel task");
let jh3 = thread::spawn(move || {
@ -304,7 +323,9 @@ fn main() {
});
jh0.join().expect("Joining UDP TMTC server thread failed");
jh1.unwrap().join().expect("Joining CAN Bus Listening thread failed");
jh1.unwrap()
.join()
.expect("Joining CAN Bus Listening thread failed");
jh2.unwrap().join().expect("Joing AOCS thread failed");
jh3.join().expect("Joing AOCS thread failed");
@ -318,5 +339,5 @@ fn main() {
struct MgmData {
x: i16,
y: i16,
z: i16
}
z: i16,
}

View File

@ -1,6 +1,7 @@
use crate::hk::{CollectionIntervalFactor, HkRequest};
use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{PusTcSource, TmStore};
use eurosim_obsw::{hk_err, tmtc_err};
use satrs_core::events::EventU32;
use satrs_core::pool::StoreAddr;
use satrs_core::pus::event::Subservices;
@ -12,13 +13,9 @@ use satrs_core::pus::verification::{
use satrs_core::res_code::ResultU16;
use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper;
use satrs_core::tmtc::{AddressableId, PusServiceProvider};
use eurosim_obsw::{hk_err, tmtc_err};
use satrs_core::{
spacepackets::ecss::PusPacket,
spacepackets::tc::PusTc,
spacepackets::time::cds::TimeProvider,
spacepackets::time::TimeWriter,
spacepackets::SpHeader,
spacepackets::ecss::PusPacket, spacepackets::tc::PusTc, spacepackets::time::cds::TimeProvider,
spacepackets::time::TimeWriter, spacepackets::SpHeader,
};
use std::collections::HashMap;

View File

@ -20,13 +20,10 @@ use satrs_core::tmtc::{
};
use satrs_core::{
spacepackets::ecss::PusPacket,
spacepackets::tc::PusTc,
spacepackets::tm::PusTm,
spacepackets::ecss::PusPacket, spacepackets::tc::PusTc, spacepackets::tm::PusTm,
spacepackets::SpHeader,
};
pub const PUS_APID: u16 = 0x02;
pub struct OtherArgs {