thats enough for today
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
3207be7ffe
commit
d42999d2ad
@ -2,4 +2,5 @@
|
|||||||
pub mod tcp_server;
|
pub mod tcp_server;
|
||||||
pub mod udp_server;
|
pub mod udp_server;
|
||||||
|
|
||||||
|
mod tcp_spacepackets_server;
|
||||||
mod tcp_with_cobs_server;
|
mod tcp_with_cobs_server;
|
||||||
|
@ -12,6 +12,7 @@ use crate::tmtc::{ReceivesTc, TmPacketSource};
|
|||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
// Re-export the TMTC in COBS server.
|
// Re-export the TMTC in COBS server.
|
||||||
|
pub use crate::hal::std::tcp_spacepackets_server::parse_buffer_for_ccsds_space_packets;
|
||||||
pub use crate::hal::std::tcp_with_cobs_server::{
|
pub use crate::hal::std::tcp_with_cobs_server::{
|
||||||
parse_buffer_for_cobs_encoded_packets, CobsTcParser, CobsTmSender, TcpTmtcInCobsServer,
|
parse_buffer_for_cobs_encoded_packets, CobsTcParser, CobsTmSender, TcpTmtcInCobsServer,
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
use crate::tmtc::ReceivesTc;
|
||||||
|
|
||||||
|
pub trait ApidLookup {
|
||||||
|
fn validate(&self, apid: u16) -> bool;
|
||||||
|
}
|
||||||
|
/// This function parses a given buffer for COBS encoded packets. The packet structure is
|
||||||
|
/// expected to be like this, assuming a sentinel value of 0 as the packet delimiter:
|
||||||
|
///
|
||||||
|
/// 0 | ... Packet Data ... | 0 | 0 | ... Packet Data ... | 0
|
||||||
|
///
|
||||||
|
/// This function is also able to deal with broken tail packets at the end. If broken tail
|
||||||
|
/// packets are detected, they are moved to the front of the buffer, and the write index for
|
||||||
|
/// future write operations will be written to the `next_write_idx` argument.
|
||||||
|
///
|
||||||
|
/// The parser will write all packets which were decoded successfully to the given `tc_receiver`.
|
||||||
|
pub fn parse_buffer_for_ccsds_space_packets<E>(
|
||||||
|
buf: &mut [u8],
|
||||||
|
apid_lookup: &dyn ApidLookup,
|
||||||
|
tc_receiver: &mut dyn ReceivesTc<Error = E>,
|
||||||
|
next_write_idx: &mut usize,
|
||||||
|
) -> Result<u32, E> {
|
||||||
|
let mut start_index_packet = 0;
|
||||||
|
let mut start_found = false;
|
||||||
|
let mut last_byte = false;
|
||||||
|
let mut packets_found = 0;
|
||||||
|
for i in 0..buf.len() {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
// Split frame at the end for a multi-packet frame. Move it to the front of the buffer.
|
||||||
|
if start_index_packet > 0 && start_found && packets_found > 0 {}
|
||||||
|
Ok(packets_found)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user