Merge branch 'main' into pus_schedule_implementation

This commit is contained in:
lkoester
2023-01-27 09:53:02 +01:00
11 changed files with 127 additions and 77 deletions

View File

@ -14,16 +14,13 @@ fn main() {
let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true);
let client = UdpSocket::bind("127.0.0.1:7302").expect("Connecting to UDP server failed");
let tc_req_id = RequestId::new(&pus_tc);
println!(
"Packing and sending PUS ping command TC[17,1] with request ID {}",
tc_req_id
);
println!("Packing and sending PUS ping command TC[17,1] with request ID {tc_req_id}");
let size = pus_tc
.write_to_bytes(&mut buf)
.expect("Creating PUS TC failed");
client
.send_to(&buf[0..size], addr)
.unwrap_or_else(|_| panic!("Sending to {:?} failed", addr));
.unwrap_or_else(|_| panic!("Sending to {addr:?} failed"));
client
.set_read_timeout(Some(Duration::from_secs(2)))
.expect("Setting read timeout failed");
@ -44,33 +41,21 @@ fn main() {
}
let req_id = RequestId::from_bytes(src_data).unwrap();
if pus_tm.subservice() == 1 {
println!(
"Received TM[1,1] acceptance success for request ID {}",
req_id
)
println!("Received TM[1,1] acceptance success for request ID {req_id}")
} else if pus_tm.subservice() == 2 {
println!(
"Received TM[1,2] acceptance failure for request ID {}",
req_id
)
println!("Received TM[1,2] acceptance failure for request ID {req_id}")
} else if pus_tm.subservice() == 3 {
println!("Received TM[1,3] start success for request ID {}", req_id)
println!("Received TM[1,3] start success for request ID {req_id}")
} else if pus_tm.subservice() == 4 {
println!("Received TM[1,2] start failure for request ID {}", req_id)
println!("Received TM[1,2] start failure for request ID {req_id}")
} else if pus_tm.subservice() == 5 {
println!("Received TM[1,5] step success for request ID {}", req_id)
println!("Received TM[1,5] step success for request ID {req_id}")
} else if pus_tm.subservice() == 6 {
println!("Received TM[1,6] step failure for request ID {}", req_id)
println!("Received TM[1,6] step failure for request ID {req_id}")
} else if pus_tm.subservice() == 7 {
println!(
"Received TM[1,7] completion success for request ID {}",
req_id
)
println!("Received TM[1,7] completion success for request ID {req_id}")
} else if pus_tm.subservice() == 8 {
println!(
"Received TM[1,8] completion failure for request ID {}",
req_id
);
println!("Received TM[1,8] completion failure for request ID {req_id}");
}
} else {
println!(

View File

@ -49,7 +49,7 @@ fn main() {
let jh0 = thread::spawn(move || {
let data = r0.recv().unwrap();
let raw = data.get_data();
println!("Received data {:?}", raw);
println!("Received data {raw:?}");
});
let jh1 = thread::spawn(|| {});
jh0.join().unwrap();

View File

@ -181,7 +181,7 @@ impl PusReceiver {
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
sender
.send(RequestWithToken(Request::HkRequest(request), token))
.unwrap_or_else(|_| panic!("Sending HK request {:?} failed", request));
.unwrap_or_else(|_| panic!("Sending HK request {request:?} failed"));
};
if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 {
send_request(HkRequest::Enable(addressable_id));

View File

@ -60,10 +60,10 @@ impl Display for MpscStoreAndSendError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
MpscStoreAndSendError::StoreError(s) => {
write!(f, "store error {}", s)
write!(f, "store error {s}")
}
MpscStoreAndSendError::SendError(s) => {
write!(f, "send error {}", s)
write!(f, "send error {s}")
}
}
}
@ -245,8 +245,8 @@ fn core_tmtc_loop(
.ok();
}
Err(e) => {
println!("error creating PUS TC from raw data: {}", e);
println!("raw data: {:x?}", data);
println!("error creating PUS TC from raw data: {e}");
println!("raw data: {data:x?}");
}
}
}
@ -266,7 +266,7 @@ fn poll_tc_server(udp_tmtc_server: &mut UdpTmtcServer) -> bool {
Ok(_) => true,
Err(e) => match e {
ReceiveResult::ReceiverError(e) => match e {
CcsdsError::PacketError(e) => {
CcsdsError::ByteConversionError(e) => {
println!("Got packet error: {e:?}");
true
}
@ -295,7 +295,7 @@ fn core_tm_handling(udp_tmtc_server: &mut UdpTmtcServer, recv_addr: &SocketAddr)
if buf.len() > 9 {
let service = buf[7];
let subservice = buf[8];
println!("Sending PUS TM[{},{}]", service, subservice)
println!("Sending PUS TM[{service},{subservice}]")
} else {
println!("Sending PUS TM");
}