TCP Server #77
@ -16,7 +16,7 @@ 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,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// TCP configuration struct.
|
/// Configuration struct for the generic TCP TMTC server
|
||||||
///
|
///
|
||||||
/// ## Parameters
|
/// ## Parameters
|
||||||
///
|
///
|
||||||
@ -26,14 +26,12 @@ pub use crate::hal::std::tcp_with_cobs_server::{
|
|||||||
/// to reduce CPU load.
|
/// to reduce CPU load.
|
||||||
/// * `tm_buffer_size` - Size of the TM buffer used to read TM from the [TmPacketSource] and
|
/// * `tm_buffer_size` - Size of the TM buffer used to read TM from the [TmPacketSource] and
|
||||||
/// encoding of that data. This buffer should at large enough to hold the maximum expected
|
/// encoding of that data. This buffer should at large enough to hold the maximum expected
|
||||||
/// TM size in addition to the COBS encoding overhead. You can use
|
/// TM size read from the packet source.
|
||||||
/// [cobs::max_encoding_length] to calculate this size.
|
|
||||||
/// * `tc_buffer_size` - Size of the TC buffer used to read encoded telecommands sent from
|
/// * `tc_buffer_size` - Size of the TC buffer used to read encoded telecommands sent from
|
||||||
/// the client. It is recommended to make this buffer larger to allow reading multiple
|
/// the client. It is recommended to make this buffer larger to allow reading multiple
|
||||||
/// consecutive packets as well, for example by using 4096 or 8192 byte. The buffer should
|
/// consecutive packets as well, for example by using common buffer sizes like 4096 or 8192
|
||||||
/// at the very least be large enough to hold the maximum expected telecommand size in
|
/// byte. The buffer should at the very least be large enough to hold the maximum expected
|
||||||
/// addition to its COBS encoding overhead. You can use [cobs::max_encoding_length] to
|
/// telecommand size.
|
||||||
/// calculate this size.
|
|
||||||
/// * `reuse_addr` - Can be used to set the `SO_REUSEADDR` option on the raw socket. This is
|
/// * `reuse_addr` - Can be used to set the `SO_REUSEADDR` option on the raw socket. This is
|
||||||
/// especially useful if the address and port are static for the server. Set to false by
|
/// especially useful if the address and port are static for the server. Set to false by
|
||||||
/// default.
|
/// default.
|
||||||
|
@ -16,6 +16,7 @@ use crate::hal::std::tcp_server::{
|
|||||||
ConnectionResult, ServerConfig, TcpTcParser, TcpTmSender, TcpTmtcError, TcpTmtcGenericServer,
|
ConnectionResult, ServerConfig, TcpTcParser, TcpTmSender, TcpTmtcError, TcpTmtcGenericServer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Concrete [TcpTcParser] implementation for the [TcpTmtcInCobsServer].
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct CobsTcParser {}
|
pub struct CobsTcParser {}
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ impl<TmError, TcError> TcpTcParser<TmError, TcError> for CobsTcParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Concrete [TcpTmSender] implementation for the [TcpTmtcInCobsServer].
|
||||||
pub struct CobsTmSender {
|
pub struct CobsTmSender {
|
||||||
tm_encoding_buffer: Vec<u8>,
|
tm_encoding_buffer: Vec<u8>,
|
||||||
}
|
}
|
||||||
@ -116,8 +118,8 @@ impl<TmError: 'static, TcError: 'static> TcpTmtcInCobsServer<TmError, TcError> {
|
|||||||
/// * `cfg` - Configuration of the server.
|
/// * `cfg` - Configuration of the server.
|
||||||
/// * `tm_source` - Generic TM source used by the server to pull telemetry packets which are
|
/// * `tm_source` - Generic TM source used by the server to pull telemetry packets which are
|
||||||
/// then sent back to the client.
|
/// then sent back to the client.
|
||||||
/// * `tc_receiver` - Any received telecommand which was decoded successfully will be forwarded
|
/// * `tc_receiver` - Any received telecommands which were decoded successfully will be
|
||||||
/// to this TC receiver.
|
/// forwarded to this TC receiver.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
cfg: ServerConfig,
|
cfg: ServerConfig,
|
||||||
tm_source: Box<dyn TmPacketSource<Error = TmError> + Send>,
|
tm_source: Box<dyn TmPacketSource<Error = TmError> + Send>,
|
||||||
@ -151,7 +153,7 @@ impl<TmError: 'static, TcError: 'static> TcpTmtcInCobsServer<TmError, TcError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This function parses a given buffer for COBS encoded packets. The packet structure is
|
/// 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.
|
/// expected to be like this, assuming a sentinel value of 0 as the packet delimiter:
|
||||||
///
|
///
|
||||||
/// 0 | ... Packet Data ... | 0 | 0 | ... Packet Data ... | 0
|
/// 0 | ... Packet Data ... | 0 | 0 | ... Packet Data ... | 0
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user