small changes to scheduler and main

This commit is contained in:
lkoester 2023-01-30 09:52:11 +01:00
parent d25f4aad87
commit 3fb028a239
3 changed files with 9 additions and 11 deletions

View File

@ -19,9 +19,9 @@ use std::time::SystemTimeError;
pub enum ScheduleError {
PusError(PusError),
TimeMarginTooShort(UnixTimestamp, UnixTimestamp),
NestedScheduledTC,
NestedScheduledTc,
StoreError(StoreError),
TCDataEmpty,
TcDataEmpty,
TimestampError(TimestampError),
WrongSubservice,
WrongService,
@ -40,14 +40,14 @@ impl Display for ScheduleError {
current_time, timestamp
)
}
ScheduleError::NestedScheduledTC => {
ScheduleError::NestedScheduledTc => {
write!(f, "Error: nested scheduling is not allowed")
}
ScheduleError::StoreError(e) => {
write!(f, "Store Error: {}", e)
}
ScheduleError::TCDataEmpty => {
write!(f, "Error: empty TC Data field")
ScheduleError::TcDataEmpty => {
write!(f, "Error: empty Tc Data field")
}
ScheduleError::TimestampError(e) => {
write!(f, "Timestamp Error: {}", e)
@ -134,7 +134,6 @@ impl PusScheduler {
}
/// Like [Self::new], but sets the `init_current_time` parameter to the current system time.
#[cfg(feature = "std")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
pub fn new_with_current_init_time(time_margin: Duration) -> Result<Self, SystemTimeError> {
@ -221,8 +220,7 @@ impl PusScheduler {
) -> Result<StoreAddr, ScheduleError> {
let check_tc = PusTc::from_bytes(tc)?;
if PusPacket::service(&check_tc.0) == 11 && PusPacket::subservice(&check_tc.0) == 4 {
// TODO: should not be able to schedule a scheduled tc
return Err(ScheduleError::NestedScheduledTC);
return Err(ScheduleError::NestedScheduledTc);
}
match pool.add(tc) {
@ -254,7 +252,7 @@ impl PusScheduler {
let stamp_len = stamp.len_as_bytes();
self.insert_unwrapped_tc(unix_stamp, &user_data[stamp_len..], pool)
} else {
Err(ScheduleError::TCDataEmpty)
Err(ScheduleError::TcDataEmpty)
};
}

View File

@ -1,5 +1,3 @@
extern crate core;
mod ccsds;
mod hk;
mod pus;

View File

@ -229,6 +229,7 @@ fn core_tmtc_loop(
scheduler
.release_telecommands(releaser, pool.as_mut())
.expect("error releasing tc");
drop(pool);
while poll_tc_server(udp_tmtc_server) {}
match tc_args.tc_receiver.try_recv() {
@ -263,6 +264,7 @@ fn core_tmtc_loop(
}
fn poll_tc_server(udp_tmtc_server: &mut UdpTmtcServer) -> bool {
match udp_tmtc_server.udp_tc_server.try_recv_tc() {
Ok(_) => true,
Err(e) => match e {