8 Commits

Author SHA1 Message Date
228f198006 Merge pull request 'prepare next release candidate' (#78) from prep_v0.11.0-rc.1 into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
Reviewed-on: #78
2024-04-03 15:07:06 +02:00
54f065ed74 small fix
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
Rust/spacepackets/pipeline/pr-main This commit looks good
2024-04-03 14:18:12 +02:00
4ef65279ea doc update
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
Rust/spacepackets/pipeline/pr-main This commit looks good
2024-04-03 14:16:42 +02:00
f0af16dc29 prepare next release candidate
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
2024-04-03 14:13:04 +02:00
d05a1077e8 Merge pull request 'consistent ECSS object constructors' (#77) from consistent-ecss-ctors into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
Reviewed-on: #77
2024-04-03 14:09:36 +02:00
fc684a42a8 consistent ECSS object constructors
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
2024-04-03 13:30:01 +02:00
e9ddc316c8 Merge pull request 'update ECSS code' (#75) from update-ecss-code into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
Reviewed-on: #75
2024-03-29 14:22:43 +01:00
4da417dfd2 cargo fmt
Some checks are pending
Rust/spacepackets/pipeline/pr-main Build started...
Rust/spacepackets/pipeline/head This commit looks good
2024-03-29 14:13:44 +01:00
7 changed files with 41 additions and 30 deletions

View File

@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased]
# [v0.11.0-rc.1] 2024-04-03
Major API changes for the time API. If you are using the time API, it is strongly recommended
to check all the API changes in the **Changed** chapter.
@ -28,6 +30,10 @@ to check all the API changes in the **Changed** chapter.
## Changed
- `PusTcCreator::new_simple` now expects a valid slice for the source data instead of an optional
slice. For telecommands without application data, `&[]` can be passed.
- `PusTmSecondaryHeader` constructors now expects a valid slice for the time stamp instead of an
optional slice.
- Renamed `CcsdsTimeProvider::date_time` to `CcsdsTimeProvider::chrono_date_time`
- Renamed `CcsdsTimeCodes` to `CcsdsTimeCode`
- Renamed `cds::TimeProvider` to `cds::CdsTime`

View File

@ -1,6 +1,6 @@
[package]
name = "spacepackets"
version = "0.11.0-rc.0"
version = "0.11.0-rc.1"
edition = "2021"
rust-version = "1.61"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
@ -67,4 +67,4 @@ defmt = ["dep:defmt"]
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
rustdoc-args = ["--cfg", "docs_rs", "--generate-link-to-definition"]

View File

@ -46,7 +46,7 @@ deserializing them with an appropriate `serde` provider like
- [`chrono`](https://crates.io/crates/chrono): Add basic support for the `chrono` time library.
- [`timelib`](https://crates.io/crates/time): Add basic support for the `time` time library.
- [`defmt`](https://defmt.ferrous-systems.com/): Add support for the `defmt` by adding the
`defmt::Format` derive on many objects.
[`defmt::Format`](https://defmt.ferrous-systems.com/format) derive on many types.
# Examples

View File

@ -4,11 +4,11 @@ Checklist for new releases
# Pre-Release
1. Make sure any new modules are documented sufficiently enough and check docs with
`cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docsrs"]' --open`.
`cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]' --open`.
2. Bump version specifier in `Cargo.toml`.
3. Update `CHANGELOG.md`: Convert `unreleased` section into version section with date and add new
`unreleased` section.
4. Run `cargo test --all-features`.
4. Run `cargo test --all-features` or `cargo nextest r --all-features`.
5. Run `cargo fmt` and `cargo clippy`. Check `cargo msrv` against MSRV in `Cargo.toml`.
6. Wait for CI/CD results for EGit and Github. These also check cross-compilation for bare-metal
targets.

View File

@ -267,13 +267,13 @@ impl<'raw_data> PusTcCreator<'raw_data> {
sph: &mut SpHeader,
service: u8,
subservice: u8,
app_data: Option<&'raw_data [u8]>,
app_data: &'raw_data [u8],
set_ccsds_len: bool,
) -> Self {
Self::new(
sph,
PusTcSecondaryHeader::new(service, subservice, ACK_ALL, 0),
app_data.unwrap_or(&[]),
app_data,
set_ccsds_len,
)
}
@ -575,12 +575,12 @@ mod tests {
fn base_ping_tc_simple_ctor() -> PusTcCreator<'static> {
let mut sph = SpHeader::tc_unseg(0x02, 0x34, 0).unwrap();
PusTcCreator::new_simple(&mut sph, 17, 1, None, true)
PusTcCreator::new_simple(&mut sph, 17, 1, &[], true)
}
fn base_ping_tc_simple_ctor_with_app_data(app_data: &'static [u8]) -> PusTcCreator<'static> {
let mut sph = SpHeader::tc_unseg(0x02, 0x34, 0).unwrap();
PusTcCreator::new_simple(&mut sph, 17, 1, Some(app_data), true)
PusTcCreator::new_simple(&mut sph, 17, 1, app_data, true)
}
#[test]
@ -637,7 +637,7 @@ mod tests {
#[test]
fn test_update_func() {
let mut sph = SpHeader::tc_unseg(0x02, 0x34, 0).unwrap();
let mut tc = PusTcCreator::new_simple(&mut sph, 17, 1, None, false);
let mut tc = PusTcCreator::new_simple(&mut sph, 17, 1, &[], false);
assert_eq!(tc.data_len(), 0);
tc.update_ccsds_data_len();
assert_eq!(tc.data_len(), 6);

View File

@ -123,17 +123,17 @@ pub struct PusTmSecondaryHeader<'stamp> {
pub subservice: u8,
pub msg_counter: u16,
pub dest_id: u16,
pub timestamp: &'stamp [u8],
pub time_stamp: &'stamp [u8],
}
impl<'stamp> PusTmSecondaryHeader<'stamp> {
pub fn new_simple(service: u8, subservice: u8, timestamp: &'stamp [u8]) -> Self {
Self::new(service, subservice, 0, 0, Some(timestamp))
pub fn new_simple(service: u8, subservice: u8, time_stamp: &'stamp [u8]) -> Self {
Self::new(service, subservice, 0, 0, time_stamp)
}
/// Like [Self::new_simple] but without a timestamp.
pub fn new_simple_no_timestamp(service: u8, subservice: u8) -> Self {
Self::new(service, subservice, 0, 0, None)
Self::new(service, subservice, 0, 0, &[])
}
pub fn new(
@ -141,7 +141,7 @@ impl<'stamp> PusTmSecondaryHeader<'stamp> {
subservice: u8,
msg_counter: u16,
dest_id: u16,
timestamp: Option<&'stamp [u8]>,
time_stamp: &'stamp [u8],
) -> Self {
PusTmSecondaryHeader {
pus_version: PusVersion::PusC,
@ -150,7 +150,7 @@ impl<'stamp> PusTmSecondaryHeader<'stamp> {
subservice,
msg_counter,
dest_id,
timestamp: timestamp.unwrap_or(&[]),
time_stamp,
}
}
}
@ -192,7 +192,7 @@ impl<'slice> TryFrom<zc::PusTmSecHeader<'slice>> for PusTmSecondaryHeader<'slice
subservice: sec_header.zc_header.subservice(),
msg_counter: sec_header.zc_header.msg_counter(),
dest_id: sec_header.zc_header.dest_id(),
timestamp: sec_header.timestamp,
time_stamp: sec_header.timestamp,
})
}
}
@ -214,7 +214,7 @@ impl<'slice> TryFrom<zc::PusTmSecHeader<'slice>> for PusTmSecondaryHeader<'slice
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct PusTmCreator<'time, 'raw_data> {
pub sp_header: SpHeader,
#[cfg_attr(feature="serde", serde(borrow))]
#[cfg_attr(feature = "serde", serde(borrow))]
pub sec_header: PusTmSecondaryHeader<'time>,
source_data: &'raw_data [u8],
/// If this is set to false, a manual call to [Self::calc_own_crc16] or
@ -284,7 +284,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
}
pub fn timestamp(&self) -> &[u8] {
self.sec_header.timestamp
self.sec_header.time_stamp
}
pub fn source_data(&self) -> &[u8] {
@ -323,7 +323,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
digest.update(sph_zc.as_bytes());
let pus_tc_header = zc::PusTmSecHeaderWithoutTimestamp::try_from(self.sec_header).unwrap();
digest.update(pus_tc_header.as_bytes());
digest.update(self.sec_header.timestamp);
digest.update(self.sec_header.time_stamp);
digest.update(self.source_data);
digest.finalize()
}
@ -352,9 +352,9 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
.write_to_bytes(&mut slice[curr_idx..curr_idx + sec_header_len])
.ok_or(ByteConversionError::ZeroCopyToError)?;
curr_idx += sec_header_len;
slice[curr_idx..curr_idx + self.sec_header.timestamp.len()]
.copy_from_slice(self.sec_header.timestamp);
curr_idx += self.sec_header.timestamp.len();
slice[curr_idx..curr_idx + self.sec_header.time_stamp.len()]
.copy_from_slice(self.sec_header.time_stamp);
curr_idx += self.sec_header.time_stamp.len();
slice[curr_idx..curr_idx + self.source_data.len()].copy_from_slice(self.source_data);
curr_idx += self.source_data.len();
let mut digest = CRC_CCITT_FALSE.digest();
@ -368,14 +368,15 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
#[cfg(feature = "alloc")]
pub fn append_to_vec(&self, vec: &mut Vec<u8>) -> Result<usize, PusError> {
let sph_zc = crate::zc::SpHeader::from(self.sp_header);
let mut appended_len = PUS_TM_MIN_LEN_WITHOUT_SOURCE_DATA + self.sec_header.timestamp.len();
let mut appended_len =
PUS_TM_MIN_LEN_WITHOUT_SOURCE_DATA + self.sec_header.time_stamp.len();
appended_len += self.source_data.len();
let start_idx = vec.len();
vec.extend_from_slice(sph_zc.as_bytes());
// The PUS version is hardcoded to PUS C
let sec_header = zc::PusTmSecHeaderWithoutTimestamp::try_from(self.sec_header).unwrap();
vec.extend_from_slice(sec_header.as_bytes());
vec.extend_from_slice(self.sec_header.timestamp);
vec.extend_from_slice(self.sec_header.time_stamp);
vec.extend_from_slice(self.source_data);
let mut digest = CRC_CCITT_FALSE.digest();
digest.update(&vec[start_idx..start_idx + appended_len - 2]);
@ -387,7 +388,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
impl WritablePusPacket for PusTmCreator<'_, '_> {
fn len_written(&self) -> usize {
PUS_TM_MIN_LEN_WITHOUT_SOURCE_DATA
+ self.sec_header.timestamp.len()
+ self.sec_header.time_stamp.len()
+ self.source_data.len()
}
/// Write the raw PUS byte representation to a provided buffer.
@ -526,7 +527,7 @@ impl<'raw_data> PusTmReader<'raw_data> {
}
pub fn timestamp(&self) -> &[u8] {
self.sec_header.timestamp
self.sec_header.time_stamp
}
/// This function will return the slice [Self] was constructed from.
@ -1146,7 +1147,7 @@ mod tests {
#[test]
fn test_sec_header_without_stamp() {
let sec_header = PusTmSecondaryHeader::new_simple_no_timestamp(17, 1);
assert_eq!(sec_header.timestamp, &[]);
assert_eq!(sec_header.time_stamp, &[]);
}
#[test]

View File

@ -36,7 +36,11 @@
//! ### Optional features
//!
//! - [`serde`](https://serde.rs/): Adds `serde` support for most types by adding `Serialize` and
//! `Deserialize` `derive`s
//! `Deserialize` `derives.
//! - [`chrono`](https://crates.io/crates/chrono): Add basic support for the `chrono` time library.
//! - [`timelib`](https://crates.io/crates/time): Add basic support for the `time` time library.
//! - [`defmt`](https://defmt.ferrous-systems.com/): Add support for the `defmt` by adding the
//! [`defmt::Format`](https://defmt.ferrous-systems.com/format) derive on many types.
//!
//! ## Module
//!
@ -55,7 +59,7 @@
//! println!("{:x?}", &ccsds_buf[0..6]);
//! ```
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(docs_rs, feature(doc_auto_cfg))]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(any(feature = "std", test))]