doc corrections
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
32059e8682
commit
2a5795c892
@ -920,7 +920,7 @@ pub mod std_mod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function can be used to poll the internal [EcssTcReceiver] object for the next
|
/// This function can be used to poll the internal [EcssTcReceiverCore] object for the next
|
||||||
/// telecommand packet. It will return `Ok(None)` if there are not packets available.
|
/// telecommand packet. It will return `Ok(None)` if there are not packets available.
|
||||||
/// In any other case, it will perform the acceptance of the ECSS TC packet using the
|
/// In any other case, it will perform the acceptance of the ECSS TC packet using the
|
||||||
/// internal [VerificationReportingProvider] object. It will then return the telecommand
|
/// internal [VerificationReportingProvider] object. It will then return the telecommand
|
||||||
|
@ -107,14 +107,11 @@ pub trait CcsdsPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The CCSDS distributor dispatches received CCSDS packets to a user provided packet handler.
|
/// The CCSDS distributor dispatches received CCSDS packets to a user provided packet handler.
|
||||||
///
|
|
||||||
/// The passed APID handler is required to be [Send]able to allow more ergonomic usage with
|
|
||||||
/// threads.
|
|
||||||
pub struct CcsdsDistributor<PacketHandler: CcsdsPacketHandler<Error = E>, E> {
|
pub struct CcsdsDistributor<PacketHandler: CcsdsPacketHandler<Error = E>, E> {
|
||||||
/// User provided APID handler stored as a generic trait object.
|
/// User provided APID handler stored as a generic trait object.
|
||||||
/// It can be cast back to the original concrete type using the [Self::apid_handler_ref] or
|
/// It can be cast back to the original concrete type using [Self::packet_handler] or
|
||||||
/// the [Self::apid_handler_mut] method.
|
/// the [Self::packet_handler_mut] method.
|
||||||
pub apid_handler: PacketHandler,
|
packet_handler: PacketHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
@ -174,28 +171,29 @@ impl<PacketHandler: CcsdsPacketHandler<Error = E>, E: 'static> ReceivesTcCore
|
|||||||
|
|
||||||
impl<PacketHandler: CcsdsPacketHandler<Error = E>, E: 'static> CcsdsDistributor<PacketHandler, E> {
|
impl<PacketHandler: CcsdsPacketHandler<Error = E>, E: 'static> CcsdsDistributor<PacketHandler, E> {
|
||||||
pub fn new(apid_handler: PacketHandler) -> Self {
|
pub fn new(apid_handler: PacketHandler) -> Self {
|
||||||
CcsdsDistributor { apid_handler }
|
CcsdsDistributor { packet_handler: apid_handler }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn packet_handler(&self) -> &PacketHandler {
|
pub fn packet_handler(&self) -> &PacketHandler {
|
||||||
&self.apid_handler
|
&self.packet_handler
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn packet_handler_mut(&mut self) -> &mut PacketHandler {
|
pub fn packet_handler_mut(&mut self) -> &mut PacketHandler {
|
||||||
&mut self.apid_handler
|
&mut self.packet_handler
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_ccsds(&mut self, sp_header: &SpHeader, tc_raw: &[u8]) -> Result<(), CcsdsError<E>> {
|
fn dispatch_ccsds(&mut self, sp_header: &SpHeader, tc_raw: &[u8]) -> Result<(), CcsdsError<E>> {
|
||||||
let apid = sp_header.apid();
|
let apid = sp_header.apid();
|
||||||
let valid_apids = self.apid_handler.valid_apids();
|
let valid_apids = self.packet_handler.valid_apids();
|
||||||
for &valid_apid in valid_apids {
|
for &valid_apid in valid_apids {
|
||||||
if valid_apid == apid {
|
if valid_apid == apid {
|
||||||
return self
|
return self
|
||||||
.apid_handler
|
.packet_handler
|
||||||
.handle_known_apid(sp_header, tc_raw)
|
.handle_known_apid(sp_header, tc_raw)
|
||||||
.map_err(|e| CcsdsError::CustomError(e));
|
.map_err(|e| CcsdsError::CustomError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.apid_handler
|
self.packet_handler
|
||||||
.handle_unknown_apid(sp_header, tc_raw)
|
.handle_unknown_apid(sp_header, tc_raw)
|
||||||
.map_err(|e| CcsdsError::CustomError(e))
|
.map_err(|e| CcsdsError::CustomError(e))
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! The routing components consist of two core components:
|
//! The routing components consist of two core components:
|
||||||
//! 1. [PusDistributor] component which dispatches received packets to a user-provided handler.
|
//! 1. [PusDistributor] component which dispatches received packets to a user-provided handler.
|
||||||
//! 2. [PusServiceProvider] trait which should be implemented by the user-provided PUS packet
|
//! 2. [PusServiceDistributor] trait which should be implemented by the user-provided PUS packet
|
||||||
//! handler.
|
//! handler.
|
||||||
//!
|
//!
|
||||||
//! The [PusDistributor] implements the [ReceivesEcssPusTc], [ReceivesCcsdsTc] and the
|
//! The [PusDistributor] implements the [ReceivesEcssPusTc], [ReceivesCcsdsTc] and the
|
||||||
@ -13,7 +13,7 @@
|
|||||||
//! the raw bytestream. If this process fails, a [PusDistribError::PusError] is returned to the
|
//! the raw bytestream. If this process fails, a [PusDistribError::PusError] is returned to the
|
||||||
//! user.
|
//! user.
|
||||||
//! 2. If it was possible to extract both components, the packet will be passed to the
|
//! 2. If it was possible to extract both components, the packet will be passed to the
|
||||||
//! [PusServiceProvider::handle_pus_tc_packet] method provided by the user.
|
//! [PusServiceDistributor::distribute_packet] method provided by the user.
|
||||||
//!
|
//!
|
||||||
//! # Example
|
//! # Example
|
||||||
//!
|
//!
|
||||||
@ -83,9 +83,6 @@ pub trait PusServiceDistributor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Generic distributor object which dispatches received packets to a user provided handler.
|
/// Generic distributor object which dispatches received packets to a user provided handler.
|
||||||
///
|
|
||||||
/// This distributor expects the passed trait object to be [Send]able to allow more ergonomic
|
|
||||||
/// usage with threads.
|
|
||||||
pub struct PusDistributor<ServiceDistributor: PusServiceDistributor<Error = E>, E> {
|
pub struct PusDistributor<ServiceDistributor: PusServiceDistributor<Error = E>, E> {
|
||||||
service_distributor: ServiceDistributor,
|
service_distributor: ServiceDistributor,
|
||||||
}
|
}
|
||||||
@ -185,7 +182,6 @@ mod tests {
|
|||||||
use spacepackets::CcsdsPacket;
|
use spacepackets::CcsdsPacket;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fmt::format;
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user