Implementation of scheduler in pus and tmtc handler #29
@ -19,9 +19,9 @@ use std::time::SystemTimeError;
|
|||||||
pub enum ScheduleError {
|
pub enum ScheduleError {
|
||||||
PusError(PusError),
|
PusError(PusError),
|
||||||
TimeMarginTooShort(UnixTimestamp, UnixTimestamp),
|
TimeMarginTooShort(UnixTimestamp, UnixTimestamp),
|
||||||
NestedScheduledTC,
|
NestedScheduledTc,
|
||||||
lkoester marked this conversation as resolved
Outdated
|
|||||||
StoreError(StoreError),
|
StoreError(StoreError),
|
||||||
TCDataEmpty,
|
TcDataEmpty,
|
||||||
TimestampError(TimestampError),
|
TimestampError(TimestampError),
|
||||||
WrongSubservice,
|
WrongSubservice,
|
||||||
WrongService,
|
WrongService,
|
||||||
@ -40,14 +40,14 @@ impl Display for ScheduleError {
|
|||||||
current_time, timestamp
|
current_time, timestamp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ScheduleError::NestedScheduledTC => {
|
ScheduleError::NestedScheduledTc => {
|
||||||
write!(f, "Error: nested scheduling is not allowed")
|
write!(f, "Error: nested scheduling is not allowed")
|
||||||
}
|
}
|
||||||
ScheduleError::StoreError(e) => {
|
ScheduleError::StoreError(e) => {
|
||||||
write!(f, "Store Error: {}", e)
|
write!(f, "Store Error: {}", e)
|
||||||
}
|
}
|
||||||
ScheduleError::TCDataEmpty => {
|
ScheduleError::TcDataEmpty => {
|
||||||
write!(f, "Error: empty TC Data field")
|
write!(f, "Error: empty Tc Data field")
|
||||||
}
|
}
|
||||||
ScheduleError::TimestampError(e) => {
|
ScheduleError::TimestampError(e) => {
|
||||||
write!(f, "Timestamp Error: {}", 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.
|
/// Like [Self::new], but sets the `init_current_time` parameter to the current system time.
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
lkoester marked this conversation as resolved
Outdated
muellerr
commented
I think this newline is problematic I think this newline is problematic
|
|||||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
||||||
pub fn new_with_current_init_time(time_margin: Duration) -> Result<Self, SystemTimeError> {
|
pub fn new_with_current_init_time(time_margin: Duration) -> Result<Self, SystemTimeError> {
|
||||||
@ -221,8 +220,7 @@ impl PusScheduler {
|
|||||||
) -> Result<StoreAddr, ScheduleError> {
|
) -> Result<StoreAddr, ScheduleError> {
|
||||||
let check_tc = PusTc::from_bytes(tc)?;
|
let check_tc = PusTc::from_bytes(tc)?;
|
||||||
if PusPacket::service(&check_tc.0) == 11 && PusPacket::subservice(&check_tc.0) == 4 {
|
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);
|
|
||||||
}
|
}
|
||||||
lkoester marked this conversation as resolved
Outdated
muellerr
commented
TODO can be removed probably TODO can be removed probably
|
|||||||
|
|
||||||
match pool.add(tc) {
|
match pool.add(tc) {
|
||||||
@ -254,7 +252,7 @@ impl PusScheduler {
|
|||||||
let stamp_len = stamp.len_as_bytes();
|
let stamp_len = stamp.len_as_bytes();
|
||||||
self.insert_unwrapped_tc(unix_stamp, &user_data[stamp_len..], pool)
|
self.insert_unwrapped_tc(unix_stamp, &user_data[stamp_len..], pool)
|
||||||
} else {
|
} else {
|
||||||
Err(ScheduleError::TCDataEmpty)
|
Err(ScheduleError::TcDataEmpty)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
extern crate core;
|
|
||||||
|
|
||||||
mod ccsds;
|
mod ccsds;
|
||||||
lkoester marked this conversation as resolved
Outdated
muellerr
commented
What does this do? What does this do?
lkoester
commented
Not entirely sure, I think it was an IDE auto import, commented it out and everything seems to work fine so I think it can be deleted Not entirely sure, I think it was an IDE auto import, commented it out and everything seems to work fine so I think it can be deleted
|
|||||||
mod hk;
|
mod hk;
|
||||||
mod pus;
|
mod pus;
|
||||||
|
@ -229,6 +229,7 @@ fn core_tmtc_loop(
|
|||||||
scheduler
|
scheduler
|
||||||
.release_telecommands(releaser, pool.as_mut())
|
.release_telecommands(releaser, pool.as_mut())
|
||||||
.expect("error releasing tc");
|
.expect("error releasing tc");
|
||||||
|
drop(pool);
|
||||||
|
|
||||||
while poll_tc_server(udp_tmtc_server) {}
|
while poll_tc_server(udp_tmtc_server) {}
|
||||||
match tc_args.tc_receiver.try_recv() {
|
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 {
|
fn poll_tc_server(udp_tmtc_server: &mut UdpTmtcServer) -> bool {
|
||||||
|
|
||||||
match udp_tmtc_server.udp_tc_server.try_recv_tc() {
|
match udp_tmtc_server.udp_tc_server.try_recv_tc() {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
|
Loading…
Reference in New Issue
Block a user
TC -> Tc for consistency
Passt