2023-09-20 15:18:20 +02:00
|
|
|
pub mod ccsds;
|
|
|
|
pub mod cobs;
|
|
|
|
|
|
|
|
pub use crate::encoding::ccsds::parse_buffer_for_ccsds_space_packets;
|
2023-09-20 15:20:14 +02:00
|
|
|
pub use crate::encoding::cobs::{encode_packet_with_cobs, parse_buffer_for_cobs_encoded_packets};
|
2023-09-20 15:18:20 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
pub(crate) mod tests {
|
2023-09-21 16:34:18 +02:00
|
|
|
use alloc::{collections::VecDeque, vec::Vec};
|
|
|
|
|
|
|
|
use crate::tmtc::ReceivesTcCore;
|
|
|
|
|
2023-09-20 15:18:20 +02:00
|
|
|
use super::cobs::encode_packet_with_cobs;
|
|
|
|
|
|
|
|
pub(crate) const SIMPLE_PACKET: [u8; 5] = [1, 2, 3, 4, 5];
|
|
|
|
pub(crate) const INVERTED_PACKET: [u8; 5] = [5, 4, 3, 2, 1];
|
|
|
|
|
2023-09-21 16:34:18 +02:00
|
|
|
#[derive(Default)]
|
|
|
|
pub(crate) struct TcCacher {
|
|
|
|
pub(crate) tc_queue: VecDeque<Vec<u8>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ReceivesTcCore for TcCacher {
|
|
|
|
type Error = ();
|
|
|
|
|
|
|
|
fn pass_tc(&mut self, tc_raw: &[u8]) -> Result<(), Self::Error> {
|
|
|
|
self.tc_queue.push_back(tc_raw.to_vec());
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-20 15:18:20 +02:00
|
|
|
pub(crate) fn encode_simple_packet(encoded_buf: &mut [u8], current_idx: &mut usize) {
|
2023-09-21 16:34:18 +02:00
|
|
|
encode_packet_with_cobs(&SIMPLE_PACKET, encoded_buf, current_idx);
|
2023-09-20 15:18:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
pub(crate) fn encode_inverted_packet(encoded_buf: &mut [u8], current_idx: &mut usize) {
|
2023-09-21 16:34:18 +02:00
|
|
|
encode_packet_with_cobs(&INVERTED_PACKET, encoded_buf, current_idx);
|
2023-09-20 15:18:20 +02:00
|
|
|
}
|
|
|
|
}
|