satrs_core/encoding/
mod.rs1pub mod ccsds;
2pub mod cobs;
3
4pub use crate::encoding::ccsds::parse_buffer_for_ccsds_space_packets;
5pub use crate::encoding::cobs::{encode_packet_with_cobs, parse_buffer_for_cobs_encoded_packets};
6
7#[cfg(test)]
8pub(crate) mod tests {
9 use alloc::{collections::VecDeque, vec::Vec};
10
11 use crate::tmtc::ReceivesTcCore;
12
13 use super::cobs::encode_packet_with_cobs;
14
15 pub(crate) const SIMPLE_PACKET: [u8; 5] = [1, 2, 3, 4, 5];
16 pub(crate) const INVERTED_PACKET: [u8; 5] = [5, 4, 3, 2, 1];
17
18 #[derive(Default)]
19 pub(crate) struct TcCacher {
20 pub(crate) tc_queue: VecDeque<Vec<u8>>,
21 }
22
23 impl ReceivesTcCore for TcCacher {
24 type Error = ();
25
26 fn pass_tc(&mut self, tc_raw: &[u8]) -> Result<(), Self::Error> {
27 self.tc_queue.push_back(tc_raw.to_vec());
28 Ok(())
29 }
30 }
31
32 pub(crate) fn encode_simple_packet(encoded_buf: &mut [u8], current_idx: &mut usize) {
33 encode_packet_with_cobs(&SIMPLE_PACKET, encoded_buf, current_idx);
34 }
35
36 #[allow(dead_code)]
37 pub(crate) fn encode_inverted_packet(encoded_buf: &mut [u8], current_idx: &mut usize) {
38 encode_packet_with_cobs(&INVERTED_PACKET, encoded_buf, current_idx);
39 }
40}