From 406d731bbe9f4c096ab3ae2c0cd9b9230ca90535 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Aug 2023 18:45:24 +0200 Subject: [PATCH] fix zerocopy usage --- Cargo.toml | 5 ++++- src/ecss/tc.rs | 4 ++-- src/ecss/tm.rs | 4 ++-- src/lib.rs | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e58b118..589bdb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,10 +13,13 @@ categories = ["aerospace", "aerospace::space-protocols", "no-std", "hardware-sup # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -zerocopy = ">0.5, <=0.7" crc = "3" delegate = ">=0.8, <0.11" +[dependencies.zerocopy] +version = ">0.5, <=0.7" +features = ["derive"] + [dependencies.thiserror] version = "1" optional = true diff --git a/src/ecss/tc.rs b/src/ecss/tc.rs index 19d4e16..1a55433 100644 --- a/src/ecss/tc.rs +++ b/src/ecss/tc.rs @@ -82,9 +82,9 @@ pub trait GenericPusTcSecondaryHeader { pub mod zc { use crate::ecss::tc::GenericPusTcSecondaryHeader; use crate::ecss::{PusError, PusVersion}; - use zerocopy::{AsBytes, FromBytes, NetworkEndian, Unaligned, U16}; + use zerocopy::{AsBytes, FromBytes, FromZeroes, NetworkEndian, Unaligned, U16}; - #[derive(FromBytes, AsBytes, Unaligned)] + #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)] #[repr(C)] pub struct PusTcSecondaryHeader { version_ack: u8, diff --git a/src/ecss/tm.rs b/src/ecss/tm.rs index aee3685..4ea54d0 100644 --- a/src/ecss/tm.rs +++ b/src/ecss/tm.rs @@ -40,9 +40,9 @@ pub trait GenericPusTmSecondaryHeader { pub mod zc { use super::GenericPusTmSecondaryHeader; use crate::ecss::{PusError, PusVersion}; - use zerocopy::{AsBytes, FromBytes, NetworkEndian, Unaligned, U16}; + use zerocopy::{AsBytes, FromBytes, FromZeroes, NetworkEndian, Unaligned, U16}; - #[derive(FromBytes, AsBytes, Unaligned)] + #[derive(FromBytes, FromZeroes, AsBytes, Unaligned)] #[repr(C)] pub struct PusTmSecHeaderWithoutTimestamp { pus_version_and_sc_time_ref_status: u8, diff --git a/src/lib.rs b/src/lib.rs index e096135..df09922 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -641,9 +641,9 @@ sph_from_other!(SpHeader, crate::zc::SpHeader); pub mod zc { use crate::{CcsdsPacket, CcsdsPrimaryHeader, PacketId, PacketSequenceCtrl, VERSION_MASK}; use zerocopy::byteorder::NetworkEndian; - use zerocopy::{AsBytes, FromBytes, Unaligned, U16}; + use zerocopy::{AsBytes, FromBytes, FromZeroes, Unaligned, U16}; - #[derive(FromBytes, AsBytes, Unaligned, Debug)] + #[derive(FromBytes, FromZeroes, AsBytes, Unaligned, Debug)] #[repr(C)] pub struct SpHeader { version_packet_id: U16,