From 8e1934e604feb557f43fd8a820889e38af4afe0f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Apr 2024 19:15:04 +0200 Subject: [PATCH 1/2] prepare release v0.11.0 --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- README.md | 4 ---- src/ecss/tm.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 6 ++---- 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b1370..11fe4b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [unreleased] +# [v0.11.0] 2024-04-16 + ## Changed - Moved `CCSDS_HEADER_LEN` constant to the crate root. +## Added + +- Added `SpacePacketHeader` type alias for `SpHeader` type. + # [v0.11.0-rc.2] 2024-04-04 ## Changed diff --git a/Cargo.toml b/Cargo.toml index 9624fd2..f951cb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "spacepackets" -version = "0.11.0-rc.2" +version = "0.11.0" edition = "2021" rust-version = "1.65" authors = ["Robin Mueller "] diff --git a/README.md b/README.md index 075fcbc..977efb5 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,6 @@ Currently, this includes the following components: `spacepackets` supports various runtime environments and is also suitable for `no_std` environments. -It also offers optional support for [`serde`](https://serde.rs/). This allows serializing and -deserializing them with an appropriate `serde` provider like -[`postcard`](https://github.com/jamesmunns/postcard). - ## Default features - [`std`](https://doc.rust-lang.org/std/): Enables functionality relying on the standard library. diff --git a/src/ecss/tm.rs b/src/ecss/tm.rs index 745fd7e..63a4f0e 100644 --- a/src/ecss/tm.rs +++ b/src/ecss/tm.rs @@ -1,5 +1,47 @@ //! This module contains all components required to create a ECSS PUS C telemetry packets according //! to [ECSS-E-ST-70-41C](https://ecss.nl/standard/ecss-e-st-70-41c-space-engineering-telemetry-and-telecommand-packet-utilization-15-april-2016/). +//! +//! # Examples +//! +//! ```rust +//! use spacepackets::time::TimeWriter; +//! use spacepackets::time::cds::CdsTime; +//! use spacepackets::{CcsdsPacket, SpHeader}; +//! use spacepackets::ecss::{PusPacket, WritablePusPacket}; +//! use spacepackets::ecss::tm::{PusTmCreator, PusTmReader, PusTmSecondaryHeader}; +//! +//! let mut time_buf: [u8; 7] = [0; 7]; +//! let time_now = CdsTime::now_with_u16_days().expect("creating CDS timestamp failed"); +//! // This can definitely hold the timestamp, so it is okay to unwrap. +//! time_now.write_to_bytes(&mut time_buf).unwrap(); +//! +//! // Create a ping telemetry with no user source data +//! let ping_tm = PusTmCreator::new_no_source_data( +//! SpHeader::new_from_apid(0x02), +//! PusTmSecondaryHeader::new_simple(17, 2, &time_buf), +//! true +//! ); +//! println!("{:?}", ping_tm); +//! assert_eq!(ping_tm.service(), 17); +//! assert_eq!(ping_tm.subservice(), 2); +//! assert_eq!(ping_tm.apid(), 0x02); +//! +//! // Serialize TM into a raw buffer +//! let mut test_buf: [u8; 32] = [0; 32]; +//! let written_size = ping_tm +//! .write_to_bytes(test_buf.as_mut_slice()) +//! .expect("Error writing TC to buffer"); +//! assert_eq!(written_size, 22); +//! println!("{:?}", &test_buf[0..written_size]); +//! +//! // Deserialize from the raw byte representation +//! let (ping_tm_reader, read_size) = PusTmReader::new(&test_buf, 7).expect("Deserialization failed"); +//! assert_eq!(written_size, read_size); +//! assert_eq!(ping_tm_reader.service(), 17); +//! assert_eq!(ping_tm_reader.subservice(), 2); +//! assert_eq!(ping_tm_reader.apid(), 0x02); +//! assert_eq!(ping_tm_reader.timestamp(), &time_buf); +//! ``` use crate::ecss::{ calc_pus_crc16, ccsds_impl, crc_from_raw_data, sp_header_impls, user_data_from_raw, verify_crc16_ccitt_false_from_raw_to_pus_error, CrcType, PusError, PusPacket, PusVersion, diff --git a/src/lib.rs b/src/lib.rs index fa2c3d0..5208da2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,10 +22,6 @@ //! //! `spacepackets` supports various runtime environments and is also suitable for `no_std` environments. //! -//! It also offers optional support for [`serde`](https://serde.rs/). This allows serializing and -//! deserializing them with an appropriate `serde` provider like -//! [`postcard`](https://github.com/jamesmunns/postcard). -//! //! ### Default features //! //! - [`std`](https://doc.rust-lang.org/std/): Enables functionality relying on the standard library. @@ -506,6 +502,8 @@ pub struct SpHeader { pub data_len: u16, } +pub type SpacePacketHeader = SpHeader; + impl Default for SpHeader { /// The default function sets the sequence flag field to [SequenceFlags::Unsegmented]. The data /// length field is set to 1, which denotes an empty space packets. From 55222d92b321ee8113761f9259c2620ad676e0e7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Apr 2024 19:17:17 +0200 Subject: [PATCH 2/2] small typo fix --- src/ecss/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ecss/mod.rs b/src/ecss/mod.rs index 9b7f37c..cfac598 100644 --- a/src/ecss/mod.rs +++ b/src/ecss/mod.rs @@ -1,8 +1,8 @@ //! Common definitions and helpers required to create PUS TMTC packets according to //! [ECSS-E-ST-70-41C](https://ecss.nl/standard/ecss-e-st-70-41c-space-engineering-telemetry-and-telecommand-packet-utilization-15-april-2016/) //! -//! You can find the PUS telecommand definitions in the [tc] module and ithe PUS telemetry definitions -//! inside the [tm] module. +//! You can find the PUS telecommand types in the [tc] module and the the PUS telemetry +//! types inside the [tm] module. use crate::{ByteConversionError, CcsdsPacket, CRC_CCITT_FALSE}; #[cfg(feature = "alloc")] use alloc::vec::Vec;