Compare commits

...

10 Commits

Author SHA1 Message Date
Robin Müller 73ab7ff148 Merge pull request 'add doctests to github CI' (#93) from github-ci-doctest into main
Rust/spacepackets/pipeline/head There was a failure building this commit Details
Reviewed-on: #93
2024-05-02 14:56:13 +02:00
Robin Müller c59d01174f
add doctests to github CI
Rust/spacepackets/pipeline/head Build queued... Details
2024-05-02 14:48:31 +02:00
Robin Müller eb49bff0c9 Merge pull request 'update github CI' (#92) from update-github-ci into main
Rust/spacepackets/pipeline/head This commit looks good Details
Reviewed-on: #92
2024-05-02 14:29:53 +02:00
Robin Müller af392d40d0
this might work
Rust/spacepackets/pipeline/head Build queued... Details
Rust/spacepackets/pipeline/pr-main Build queued... Details
2024-05-02 14:22:03 +02:00
Robin Müller b78bfe2114
some fixes
Rust/spacepackets/pipeline/head Build queued... Details
Rust/spacepackets/pipeline/pr-main Build queued... Details
2024-05-02 14:16:20 +02:00
Robin Müller 69a3b1d8f3
update github CI
Rust/spacepackets/pipeline/pr-main Build queued... Details
Rust/spacepackets/pipeline/head Build started... Details
2024-05-02 14:12:26 +02:00
Robin Müller e7b3ba9575 Merge pull request 'date correction' (#91) from date-correction into main
Rust/spacepackets/pipeline/head This commit looks good Details
Reviewed-on: #91
2024-04-22 10:19:19 +02:00
Robin Müller c515535ccd
date correction
Rust/spacepackets/pipeline/head Build queued... Details
2024-04-22 10:18:35 +02:00
Robin Müller 95158a8cd2 Merge pull request 'prepare next patch version' (#90) from small-improvements-and-fixes into main
Rust/spacepackets/pipeline/head This commit looks good Details
Reviewed-on: #90
2024-04-22 10:15:21 +02:00
Robin Müller 8b1ccb0cd0
prepare next patch version 2024-04-20 10:42:36 +02:00
4 changed files with 79 additions and 87 deletions

View File

@ -1,42 +1,39 @@
on: [push]
name: ci
on: [push, pull_request]
jobs:
check:
name: Check
name: Check build
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: check
args: --release
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --release
msrv:
name: Check with MSRV
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.65.0
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: check
args: --release
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install nextest
uses: taiki-e/install-action@nextest
- run: cargo nextest run --all-features
- run: cargo test --doc
msrv:
name: Check MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.65.0
- run: cargo check --release
cross-check:
name: Check Cross
name: Check Cross-Compilation
runs-on: ubuntu-latest
strategy:
matrix:
@ -44,70 +41,32 @@ jobs:
- armv7-unknown-linux-gnueabihf
- thumbv7em-none-eabihf
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --release --target=${{ matrix.target }} --no-default-features
targets: "armv7-unknown-linux-gnueabihf, thumbv7em-none-eabihf"
- run: cargo check --release --target=${{matrix.target}} --no-default-features
fmt:
name: Rustfmt
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt --all -- --check
check-doc:
docs:
name: Check Documentation Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: doc
args: --all-features
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo +nightly doc --all-features --config 'build.rustdocflags=["--cfg", "docs_rs"]'
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
ci:
if: ${{ success() }}
# all new jobs must be added to this list
needs: [check, fmt, clippy]
runs-on: ubuntu-latest
steps:
- name: CI succeeded
run: exit 0
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy -- -D warnings

View File

@ -8,6 +8,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased]
# [v0.11.1] 2024-04-22
## Fixed
- The default data length for for `SpHeader` constructors where the data field length is not
specified is now 0.
- The `SpHeader::new_from_fields` is public now.
## Added
- `SpHeader::to_vec` method.
# [v0.11.0] 2024-04-16
## Changed

View File

@ -1,6 +1,6 @@
[package]
name = "spacepackets"
version = "0.11.0"
version = "0.11.1"
edition = "2021"
rust-version = "1.65"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]

View File

@ -505,8 +505,8 @@ pub struct SpHeader {
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.
/// The default function sets the sequence flag field to [SequenceFlags::Unsegmented] and the
/// data length to 0.
#[inline]
fn default() -> Self {
SpHeader {
@ -516,7 +516,7 @@ impl Default for SpHeader {
seq_flags: SequenceFlags::Unsegmented,
seq_count: 0,
},
data_len: 1,
data_len: 0,
}
}
}
@ -532,8 +532,8 @@ impl SpHeader {
}
}
/// This constructor sets the sequence flag field to [SequenceFlags::Unsegmented]. The data
/// length field is set to 1, which denotes an empty space packets.
/// This constructor sets the sequence flag field to [SequenceFlags::Unsegmented] and the data
/// length to 0.
///
/// This constructor will panic if the APID exceeds [MAX_APID].
#[inline]
@ -545,7 +545,7 @@ impl SpHeader {
seq_flags: SequenceFlags::Unsegmented,
seq_count: 0,
},
data_len: 1,
data_len: 0,
}
}
@ -559,7 +559,7 @@ impl SpHeader {
seq_flags: SequenceFlags::Unsegmented,
seq_count: 0,
},
data_len: 1,
data_len: 0,
})
}
@ -568,7 +568,7 @@ impl SpHeader {
///
/// The checked constructor variants can be used to avoid panics.
#[inline]
const fn new_from_fields(
pub const fn new_from_fields(
ptype: PacketType,
sec_header: bool,
apid: u16,
@ -755,6 +755,15 @@ impl SpHeader {
.ok_or(ByteConversionError::ZeroCopyToError)?;
Ok(&mut buf[CCSDS_HEADER_LEN..])
}
/// Create a vector containing the CCSDS header.
#[cfg(feature = "alloc")]
pub fn to_vec(&self) -> alloc::vec::Vec<u8> {
let mut vec = alloc::vec![0; CCSDS_HEADER_LEN];
// This can not fail.
self.write_to_be_bytes(&mut vec[..]).unwrap();
vec
}
}
impl CcsdsPacket for SpHeader {
@ -1260,12 +1269,14 @@ pub(crate) mod tests {
fn sp_header_from_apid() {
let sp_header = SpHeader::new_from_apid(0x03);
assert_eq!(sp_header.apid(), 0x03);
assert_eq!(sp_header.data_len(), 0);
}
#[test]
fn sp_header_from_apid_checked() {
let sp_header = SpHeader::new_from_apid_checked(0x03).unwrap();
assert_eq!(sp_header.apid(), 0x03);
assert_eq!(sp_header.data_len(), 0);
}
#[cfg(feature = "defmt")]
@ -1279,4 +1290,14 @@ pub(crate) mod tests {
expected: 2,
});
}
#[test]
fn test_sp_header_as_vec() {
let sp_header = SpHeader::new_for_unseg_tc(0x42, 25, 1);
let sp_header_as_vec = sp_header.to_vec();
let sp_header_read_back = SpHeader::from_be_bytes(&sp_header_as_vec)
.expect("Error reading back SP header")
.0;
assert_eq!(sp_header, sp_header_read_back);
}
}