Compare commits
19 Commits
a24ed18584
...
satrs-mib-
Author | SHA1 | Date | |
---|---|---|---|
9242b8a607 | |||
8195245481
|
|||
f6f7519625 | |||
0f0fbc1a18
|
|||
6e55e2ac95 | |||
2f96bfe992
|
|||
52aafb3aab
|
|||
6ce9cb5ead | |||
273f79d1e6
|
|||
622221835e | |||
e396ad2e7a
|
|||
772927d50b
|
|||
be9a45e55f | |||
eee8a69550
|
|||
f7a6d3ce47 | |||
df97a3a93e
|
|||
42750e08c0
|
|||
786671bbd7 | |||
63f37f0917 |
@@ -7,7 +7,7 @@ use std::{
|
||||
|
||||
use log::{info, warn};
|
||||
use satrs::{
|
||||
encoding::ccsds::{SpacePacketValidation, SpacePacketValidator},
|
||||
encoding::ccsds::{SpValidity, SpacePacketValidator},
|
||||
hal::std::tcp_server::{HandledConnectionHandler, ServerConfig, TcpSpacepacketsServer},
|
||||
spacepackets::{CcsdsPacket, PacketId},
|
||||
tmtc::{PacketSenderRaw, PacketSource},
|
||||
@@ -25,14 +25,14 @@ impl SpacePacketValidator for SimplePacketValidator {
|
||||
&self,
|
||||
sp_header: &satrs::spacepackets::SpHeader,
|
||||
_raw_buf: &[u8],
|
||||
) -> satrs::encoding::ccsds::SpacePacketValidation {
|
||||
) -> satrs::encoding::ccsds::SpValidity {
|
||||
if self.valid_ids.contains(&sp_header.packet_id()) {
|
||||
return SpacePacketValidation::Valid;
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
log::warn!("ignoring space packet with header {:?}", sp_header);
|
||||
// We could perform a CRC check.. but lets keep this simple and assume that TCP ensures
|
||||
// data integrity.
|
||||
SpacePacketValidation::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [unreleased]
|
||||
|
||||
# [v0.1.2] 2024-04-17
|
||||
|
||||
Allow `satrs-shared` from `v0.1.3` to `<v0.2`.
|
||||
|
||||
# [v0.1.1] 2024-02-17
|
||||
|
||||
- Bumped `spacepackets` to v0.10.0
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "satrs-mib"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
rust-version = "1.61"
|
||||
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
||||
@@ -23,13 +23,12 @@ version = "1"
|
||||
optional = true
|
||||
|
||||
[dependencies.satrs-shared]
|
||||
path = "../satrs-shared"
|
||||
version = "0.1.3"
|
||||
version = ">=0.1.3, <0.2"
|
||||
features = ["serde"]
|
||||
|
||||
[dependencies.satrs-mib-codegen]
|
||||
path = "codegen"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "satrs-mib-codegen"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
description = "satrs-mib proc macro implementation"
|
||||
homepage = "https://egit.irs.uni-stuttgart.de/rust/sat-rs"
|
||||
@@ -28,8 +28,7 @@ features = ["full"]
|
||||
trybuild = { version = "1", features = ["diff"] }
|
||||
|
||||
[dev-dependencies.satrs-shared]
|
||||
version = "0.1.3"
|
||||
path = "../../satrs-shared"
|
||||
version = ">=0.1.3, <0.2"
|
||||
|
||||
[dev-dependencies.satrs-mib]
|
||||
path = ".."
|
||||
|
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [unreleased]
|
||||
|
||||
# [v0.1.3] 2024-04-16
|
||||
|
||||
Allow `spacepackets` range starting with v0.10 and v0.11.
|
||||
|
||||
# [v0.1.2] 2024-02-17
|
||||
|
||||
- Bumped `spacepackets` to v0.10.0 for `UnsignedEnum` trait change.
|
||||
|
@@ -18,7 +18,7 @@ default-features = false
|
||||
optional = true
|
||||
|
||||
[dependencies.spacepackets]
|
||||
version = "0.11.0-rc.2"
|
||||
version = ">0.9, <=0.11"
|
||||
default-features = false
|
||||
|
||||
[features]
|
||||
|
@@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
# [unreleased]
|
||||
|
||||
- `spacepackets` v0.11.0
|
||||
# [v0.2.0-rc.1] 2024-04-17
|
||||
|
||||
- `spacepackets` v0.11
|
||||
|
||||
## Added
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "satrs"
|
||||
version = "0.2.0-rc.0"
|
||||
version = "0.2.0-rc.1"
|
||||
edition = "2021"
|
||||
rust-version = "1.61"
|
||||
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
||||
@@ -19,13 +19,26 @@ smallvec = "1"
|
||||
crc = "3"
|
||||
|
||||
[dependencies.satrs-shared]
|
||||
version = "0.1.3"
|
||||
path = "../satrs-shared"
|
||||
version = ">=0.1.3, <0.2"
|
||||
|
||||
[dependencies.num_enum]
|
||||
version = ">0.5, <=0.7"
|
||||
default-features = false
|
||||
|
||||
[dependencies.spacepackets]
|
||||
version = "0.11"
|
||||
default-features = false
|
||||
|
||||
[dependencies.cobs]
|
||||
git = "https://github.com/robamu/cobs.rs.git"
|
||||
version = "0.2.3"
|
||||
branch = "all_features"
|
||||
default-features = false
|
||||
|
||||
[dependencies.num-traits]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
|
||||
[dependencies.dyn-clone]
|
||||
version = "1"
|
||||
optional = true
|
||||
@@ -38,10 +51,6 @@ optional = true
|
||||
version = "0.7"
|
||||
optional = true
|
||||
|
||||
[dependencies.num-traits]
|
||||
version = "0.2"
|
||||
default-features = false
|
||||
|
||||
[dependencies.downcast-rs]
|
||||
version = "1.2"
|
||||
default-features = false
|
||||
@@ -75,17 +84,6 @@ version = "0.8"
|
||||
features = ["os-poll", "net"]
|
||||
optional = true
|
||||
|
||||
[dependencies.spacepackets]
|
||||
# git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
|
||||
version = "0.11.0-rc.2"
|
||||
default-features = false
|
||||
|
||||
[dependencies.cobs]
|
||||
git = "https://github.com/robamu/cobs.rs.git"
|
||||
version = "0.2.3"
|
||||
branch = "all_features"
|
||||
default-features = false
|
||||
|
||||
[dev-dependencies]
|
||||
serde = "1"
|
||||
zerocopy = "0.7"
|
||||
|
@@ -3,11 +3,11 @@ use spacepackets::{CcsdsPacket, SpHeader};
|
||||
use crate::{tmtc::PacketSenderRaw, ComponentId};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum SpacePacketValidation {
|
||||
pub enum SpValidity {
|
||||
Valid,
|
||||
/// The space packet can be assumed to have a valid format, but the packet should
|
||||
/// be ignored.
|
||||
Ignore,
|
||||
/// be skipped.
|
||||
Skip,
|
||||
/// The space packet or space packet header has an invalid format, for example a CRC check
|
||||
/// failed. In that case, the parser loses the packet synchronization and needs to check for
|
||||
/// the start of a new space packet header start again. The space packet header
|
||||
@@ -18,7 +18,7 @@ pub enum SpacePacketValidation {
|
||||
|
||||
/// Simple trait to allow user code to check the validity of a space packet.
|
||||
pub trait SpacePacketValidator {
|
||||
fn validate(&self, sp_header: &SpHeader, raw_buf: &[u8]) -> SpacePacketValidation;
|
||||
fn validate(&self, sp_header: &SpHeader, raw_buf: &[u8]) -> SpValidity;
|
||||
}
|
||||
|
||||
/// This function parses a given buffer for tightly packed CCSDS space packets. It uses the
|
||||
@@ -30,13 +30,16 @@ pub trait SpacePacketValidator {
|
||||
/// 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 forward all packets for which the user provided [SpacePacketValidator] returned
|
||||
/// [SpacePacketValidation::Valid] to the given `packet_sender` and return the number of packets
|
||||
/// found. If the [PacketSenderRaw::send_packet] calls fails, the error will be returned.
|
||||
/// The parses will behave differently based on the [SpValidity] returned from the user provided
|
||||
/// [SpacePacketValidator]:
|
||||
///
|
||||
/// If the user provided [SpacePacketValidator] returns [SpacePacketValidation::Invalid], the
|
||||
/// parser assumes that the synchronization is lost and tries to find the start of a new space
|
||||
/// packet header by scanning all the following bytes.
|
||||
/// 1. [SpValidity::Valid]: The parser will forward all packets to the given `packet_sender` and
|
||||
/// return the number of packets found.If the [PacketSenderRaw::send_packet] calls fails, the
|
||||
/// error will be returned.
|
||||
/// 2. [SpValidity::Invalid]: The parser assumes that the synchronization is lost and tries to
|
||||
/// find the start of a new space packet header by scanning all the following bytes.
|
||||
/// 3. [SpValidity::Skip]: The parser skips the packet using the packet length determined from the
|
||||
/// space packet header.
|
||||
pub fn parse_buffer_for_ccsds_space_packets<SendError>(
|
||||
buf: &mut [u8],
|
||||
packet_validator: &(impl SpacePacketValidator + ?Sized),
|
||||
@@ -55,7 +58,7 @@ pub fn parse_buffer_for_ccsds_space_packets<SendError>(
|
||||
let sp_header = SpHeader::from_be_bytes(&buf[current_idx..]).unwrap().0;
|
||||
// let packet_id = u16::from_be_bytes(buf[current_idx..current_idx + 2].try_into().unwrap());
|
||||
match packet_validator.validate(&sp_header, &buf[current_idx..]) {
|
||||
SpacePacketValidation::Valid => {
|
||||
SpValidity::Valid => {
|
||||
let packet_size = sp_header.total_len();
|
||||
if (current_idx + packet_size) <= buf_len {
|
||||
packet_sender
|
||||
@@ -71,11 +74,11 @@ pub fn parse_buffer_for_ccsds_space_packets<SendError>(
|
||||
current_idx += packet_size;
|
||||
continue;
|
||||
}
|
||||
SpacePacketValidation::Ignore => {
|
||||
SpValidity::Skip => {
|
||||
current_idx += sp_header.total_len();
|
||||
}
|
||||
// We might have lost sync. Try to find the start of a new space packet header.
|
||||
SpacePacketValidation::Invalid => {
|
||||
SpValidity::Invalid => {
|
||||
current_idx += 1;
|
||||
}
|
||||
}
|
||||
@@ -92,9 +95,7 @@ mod tests {
|
||||
|
||||
use crate::{encoding::tests::TcCacher, ComponentId};
|
||||
|
||||
use super::{
|
||||
parse_buffer_for_ccsds_space_packets, SpacePacketValidation, SpacePacketValidator,
|
||||
};
|
||||
use super::{parse_buffer_for_ccsds_space_packets, SpValidity, SpacePacketValidator};
|
||||
|
||||
const PARSER_ID: ComponentId = 0x05;
|
||||
const TEST_APID_0: u16 = 0x02;
|
||||
@@ -116,13 +117,13 @@ mod tests {
|
||||
}
|
||||
|
||||
impl SpacePacketValidator for SimpleVerificator {
|
||||
fn validate(&self, sp_header: &SpHeader, _raw_buf: &[u8]) -> super::SpacePacketValidation {
|
||||
fn validate(&self, sp_header: &SpHeader, _raw_buf: &[u8]) -> super::SpValidity {
|
||||
if sp_header.packet_id() == TEST_PACKET_ID_0
|
||||
|| (self.enable_second_id && sp_header.packet_id() == TEST_PACKET_ID_1)
|
||||
{
|
||||
return SpacePacketValidation::Valid;
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
SpacePacketValidation::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -185,7 +185,7 @@ mod tests {
|
||||
};
|
||||
|
||||
use crate::{
|
||||
encoding::ccsds::{SpacePacketValidation, SpacePacketValidator},
|
||||
encoding::ccsds::{SpValidity, SpacePacketValidator},
|
||||
hal::std::tcp_server::{
|
||||
tests::{ConnectionFinishedHandler, SyncTmSource},
|
||||
ConnectionResult, ServerConfig,
|
||||
@@ -207,12 +207,12 @@ mod tests {
|
||||
pub struct SimpleValidator(pub HashSet<PacketId>);
|
||||
|
||||
impl SpacePacketValidator for SimpleValidator {
|
||||
fn validate(&self, sp_header: &SpHeader, _raw_buf: &[u8]) -> SpacePacketValidation {
|
||||
fn validate(&self, sp_header: &SpHeader, _raw_buf: &[u8]) -> SpValidity {
|
||||
if self.0.contains(&sp_header.packet_id()) {
|
||||
return SpacePacketValidation::Valid;
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
// Simple case: Assume that the interface always contains valid space packets.
|
||||
SpacePacketValidation::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,6 @@ use spacepackets::{
|
||||
ecss::{
|
||||
tc::PusTcReader,
|
||||
tm::{PusTmCreator, PusTmReader},
|
||||
WritablePusPacket,
|
||||
},
|
||||
SpHeader,
|
||||
};
|
||||
@@ -226,6 +225,7 @@ pub mod std_mod {
|
||||
|
||||
#[cfg(feature = "crossbeam")]
|
||||
use crossbeam_channel as cb;
|
||||
use spacepackets::ecss::WritablePusPacket;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::pool::PoolProvider;
|
||||
|
@@ -24,7 +24,7 @@ use std::{
|
||||
use hashbrown::HashSet;
|
||||
use satrs::{
|
||||
encoding::{
|
||||
ccsds::{SpacePacketValidation, SpacePacketValidator},
|
||||
ccsds::{SpValidity, SpacePacketValidator},
|
||||
cobs::encode_packet_with_cobs,
|
||||
},
|
||||
hal::std::tcp_server::{
|
||||
@@ -205,11 +205,11 @@ impl SpacePacketValidator for SimpleVerificator {
|
||||
&self,
|
||||
sp_header: &SpHeader,
|
||||
_raw_buf: &[u8],
|
||||
) -> satrs::encoding::ccsds::SpacePacketValidation {
|
||||
) -> satrs::encoding::ccsds::SpValidity {
|
||||
if self.valid_ids.contains(&sp_header.packet_id()) {
|
||||
return SpacePacketValidation::Valid;
|
||||
return SpValidity::Valid;
|
||||
}
|
||||
SpacePacketValidation::Ignore
|
||||
SpValidity::Skip
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user